123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- import { FloatingContainer } from 'components/shared'
- import Tooltip from 'components/tooltip'
- import styled from 'styles'
-
- export const ToolButton = styled('button', {
- position: 'relative',
- height: '32px',
- width: '32px',
- color: '$text',
- backgroundColor: '$panel',
- borderRadius: '4px',
- padding: '0',
- margin: '0',
- display: 'grid',
- alignItems: 'center',
- justifyContent: 'center',
- outline: 'none',
- border: 'none',
- pointerEvents: 'all',
- fontSize: '$0',
- cursor: 'pointer',
-
- '& > *': {
- gridRow: 1,
- gridColumn: 1,
- },
-
- '&:disabled': {
- opacity: '0.5',
- },
-
- '& > span': {
- width: '100%',
- height: '100%',
- display: 'flex',
- alignItems: 'center',
- },
- })
-
- export const PrimaryToolButton = styled(ToolButton, {
- variants: {
- bp: {
- mobile: {
- height: 44,
- width: 44,
- '& svg:nth-of-type(1)': {
- height: '20px',
- width: '20px',
- },
- },
- small: {
- '&:hover:not(:disabled)': {
- backgroundColor: '$hover',
- },
- },
- medium: {},
- large: {},
- },
- isActive: {
- true: {
- color: '$selected',
- },
- },
- },
- })
-
- export const SecondaryToolButton = styled(ToolButton, {
- variants: {
- bp: {
- mobile: {
- height: 44,
- width: 44,
- '& svg:nth-of-type(1)': {
- height: '18px',
- width: '18px',
- },
- },
- small: {
- '&:hover:not(:disabled)': {
- backgroundColor: '$hover',
- },
- },
- medium: {},
- large: {},
- },
- isActive: {
- true: {
- color: '$selected',
- },
- },
- },
- })
-
- export const TertiaryToolButton = styled(ToolButton, {
- variants: {
- bp: {
- mobile: {
- height: 32,
- width: 44,
- '& svg:nth-of-type(1)': {
- height: '16px',
- width: '16px',
- },
- },
- small: {
- height: 40,
- width: 40,
- '& svg:nth-of-type(1)': {
- height: '18px',
- width: '18px',
- },
- '&:hover:not(:disabled)': {
- backgroundColor: '$hover',
- },
- },
- medium: {},
- large: {},
- },
- },
- })
-
- interface PrimaryToolButtonProps {
- label: string
- kbd: string
- onClick: () => void
- onDoubleClick?: () => void
- isActive: boolean
- children: React.ReactNode
- }
-
- export function PrimaryButton({
- label,
- kbd,
- onClick,
- onDoubleClick,
- isActive,
- children,
- }: PrimaryToolButtonProps): JSX.Element {
- return (
- <Tooltip label={label[0].toUpperCase() + label.slice(1)} kbd={kbd}>
- <PrimaryToolButton
- name={label}
- bp={{
- '@initial': 'mobile',
- '@sm': 'small',
- '@md': 'medium',
- '@lg': 'large',
- }}
- onClick={onClick}
- onDoubleClick={onDoubleClick}
- isActive={isActive}
- >
- {children}
- </PrimaryToolButton>
- </Tooltip>
- )
- }
-
- interface SecondaryToolButtonProps {
- label: string
- kbd: string
- onClick: () => void
- onDoubleClick?: () => void
- isActive: boolean
- children: React.ReactNode
- }
-
- export function SecondaryButton({
- label,
- kbd,
- onClick,
- onDoubleClick,
- isActive,
- children,
- }: SecondaryToolButtonProps): JSX.Element {
- return (
- <Tooltip label={label[0].toUpperCase() + label.slice(1)} kbd={kbd}>
- <SecondaryToolButton
- name={label}
- bp={{
- '@initial': 'mobile',
- '@sm': 'small',
- '@md': 'medium',
- '@lg': 'large',
- }}
- onClick={onClick}
- onDoubleClick={onDoubleClick}
- isActive={isActive}
- >
- {children}
- </SecondaryToolButton>
- </Tooltip>
- )
- }
-
- interface TertiaryToolProps {
- label: string
- kbd: string
- onClick: () => void
- onDoubleClick?: () => void
- children: React.ReactNode
- }
-
- export function TertiaryButton({
- label,
- kbd,
- onClick,
- onDoubleClick,
- children,
- }: TertiaryToolProps): JSX.Element {
- return (
- <Tooltip label={label[0].toUpperCase() + label.slice(1)} kbd={kbd}>
- <TertiaryToolButton
- name={label}
- bp={{
- '@initial': 'mobile',
- '@sm': 'small',
- '@md': 'medium',
- '@lg': 'large',
- }}
- onClick={onClick}
- onDoubleClick={onDoubleClick}
- >
- {children}
- </TertiaryToolButton>
- </Tooltip>
- )
- }
-
- export const TertiaryButtonsContainer = styled(FloatingContainer, {
- boxShadow: '$3',
- variants: {
- bp: {
- mobile: {
- alignItems: 'center',
- flexDirection: 'column',
- },
- small: {
- alignItems: 'center',
- flexDirection: 'row',
- },
- },
- },
- })
|