diff options
Diffstat (limited to 'src/components/Buttons/ButtonHelp')
| -rw-r--r-- | src/components/Buttons/ButtonHelp/ButtonHelp.module.scss | 52 | ||||
| -rw-r--r-- | src/components/Buttons/ButtonHelp/ButtonHelp.tsx | 41 |
2 files changed, 93 insertions, 0 deletions
diff --git a/src/components/Buttons/ButtonHelp/ButtonHelp.module.scss b/src/components/Buttons/ButtonHelp/ButtonHelp.module.scss new file mode 100644 index 0000000..b2a05d7 --- /dev/null +++ b/src/components/Buttons/ButtonHelp/ButtonHelp.module.scss @@ -0,0 +1,52 @@ +@use "@styles/abstracts/functions" as fun; +@use "@styles/abstracts/mixins" as mix; + +.icon { + color: var(--color-primary-dark); + font-weight: 600; +} + +.active { + .icon { + color: var(--color-fg-inverted); + } +} + +.wrapper { + width: fun.convert-px(44); + height: fun.convert-px(44); + background: var(--color-bg); + border: fun.convert-px(3) solid var(--color-primary-dark); + border-radius: 50%; + box-shadow: fun.convert-px(1) fun.convert-px(1) 0 0 var(--color-shadow); + transition: all 0.3s ease-in-out 0s; + + @include mix.pointer("fine") { + width: fun.convert-px(30); + height: fun.convert-px(30); + line-height: 1; + } + + &:hover, + &:focus { + border-color: var(--color-primary-light); + color: var(--color-primary-light); + box-shadow: fun.convert-px(1) fun.convert-px(1) fun.convert-px(1) + var(--color-shadow-light), + fun.convert-px(1) fun.convert-px(2) fun.convert-px(2) fun.convert-px(-2) + var(--color-shadow-light), + fun.convert-px(3) fun.convert-px(4) fun.convert-px(5) fun.convert-px(-4) + var(--color-shadow-light), + fun.convert-px(7) fun.convert-px(10) fun.convert-px(12) fun.convert-px(-3) + var(--color-shadow-light); + transform: scale(1.1); + + .icon { + transform: scale(1.1); + } + } + + &.active { + background: var(--color-primary); + } +} diff --git a/src/components/Buttons/ButtonHelp/ButtonHelp.tsx b/src/components/Buttons/ButtonHelp/ButtonHelp.tsx new file mode 100644 index 0000000..252e58c --- /dev/null +++ b/src/components/Buttons/ButtonHelp/ButtonHelp.tsx @@ -0,0 +1,41 @@ +import { SetStateAction } from 'react'; +import { useIntl } from 'react-intl'; +import styles from './ButtonHelp.module.scss'; + +const ButtonHelp = ({ + showHelp, + setShowHelp, + title, +}: { + showHelp: boolean; + setShowHelp: (value: SetStateAction<boolean>) => void; + title?: string; +}) => { + const intl = useIntl(); + + const handleClick = () => { + setShowHelp((prev) => !prev); + }; + + const activeModifier = showHelp ? styles.active : ''; + + return ( + <button + onClick={handleClick} + title={title} + className={`${styles.wrapper} ${activeModifier}`} + > + <span className={styles.icon} aria-hidden="true"> + ? + </span> + <span className="screen-reader-text"> + {intl.formatMessage({ + defaultMessage: 'Help', + description: 'ButtonHelp: screen reader text', + })} + </span> + </button> + ); +}; + +export default ButtonHelp; |
