-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…large values in tables
- Loading branch information
1 parent
636bc82
commit 9c9a72e
Showing
7 changed files
with
161 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { useState } from "react"; | ||
import classNames from "classnames"; | ||
|
||
import { str } from "../../utils/i18n"; | ||
|
||
export const Spoiler = ({children, enabled = false}) => { | ||
if (! enabled) return children; | ||
|
||
const [opened, setOpened] = useState(false); | ||
|
||
const open = () => { | ||
console.log("open", opened); | ||
! opened && setOpened(true) | ||
}; | ||
const close = () => { | ||
console.log("close", opened); | ||
opened && setOpened(false); | ||
} | ||
|
||
const limiterClasses = ! opened ? ["vsm-spoiler__limiter"] : []; | ||
|
||
return ( | ||
<div className="vsm-spoiler"> | ||
{opened && <ToggleButton type="top" onClick={close} />} | ||
|
||
<div className={classNames(limiterClasses)} onClick={open}> | ||
{! opened && <div className="vsm-spoiler__overflow" />} | ||
{children} | ||
</div> | ||
|
||
{opened && <ToggleButton type="bottom" onClick={close} />} | ||
</div> | ||
); | ||
}; | ||
|
||
const ToggleButton = ({ type, onClick }) => { | ||
const classes = classNames([ | ||
"vsm-spoiler__button", | ||
`vsm-spoiler__button--${type}` | ||
]); | ||
|
||
return <div className={classes} onClick={onClick}>{str("close")}</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters