diff --git a/system/libs/figa-ui/src/lib/bar/bar.stories.tsx b/system/libs/figa-ui/src/lib/bar/bar.stories.tsx index 0a5b8a5b5..f2b787829 100644 --- a/system/libs/figa-ui/src/lib/bar/bar.stories.tsx +++ b/system/libs/figa-ui/src/lib/bar/bar.stories.tsx @@ -1,6 +1,6 @@ import type { Story, Meta } from '@storybook/react'; -import { Bar } from './Bar'; +import { Bar } from './bar'; import type { BarProps } from './defs'; import { Button } from '../button'; import { ArrowTopIcon, CloseIcon } from '../icon'; diff --git a/system/libs/figa-ui/src/lib/expandable-link/__snapshots__/expandable-link.test.tsx.snap b/system/libs/figa-ui/src/lib/expandable-link/__snapshots__/expandable-link.test.tsx.snap new file mode 100644 index 000000000..64ef7ac47 --- /dev/null +++ b/system/libs/figa-ui/src/lib/expandable-link/__snapshots__/expandable-link.test.tsx.snap @@ -0,0 +1,44 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Exapndable link can be used when: [FRAGILE] assigns class names for particular nodes 1`] = ` + + + +`; diff --git a/system/libs/figa-ui/src/lib/expandable-link/defs.ts b/system/libs/figa-ui/src/lib/expandable-link/defs.ts new file mode 100644 index 000000000..cbbb620e9 --- /dev/null +++ b/system/libs/figa-ui/src/lib/expandable-link/defs.ts @@ -0,0 +1,28 @@ +import type { ReactNode } from 'react'; + +type DefaultComponentProps = { + children: ReactNode; + className?: string; +}; + +interface ExpandableLinkProps extends DefaultComponentProps { + active: boolean; +} + +interface ExpandableLinkItemProps extends DefaultComponentProps { + path: string; +} + +interface ExpandableLinkNameProps extends DefaultComponentProps {} + +interface ExpandableLinkListProps + extends Omit { + children: ReactNode[]; +} + +export type { + ExpandableLinkProps, + ExpandableLinkItemProps, + ExpandableLinkNameProps, + ExpandableLinkListProps, +}; diff --git a/system/libs/figa-ui/src/lib/expandable-link/expandable-link.stories.tsx b/system/libs/figa-ui/src/lib/expandable-link/expandable-link.stories.tsx new file mode 100644 index 000000000..fe9c2b26a --- /dev/null +++ b/system/libs/figa-ui/src/lib/expandable-link/expandable-link.stories.tsx @@ -0,0 +1,35 @@ +import type { Story, Meta } from '@storybook/react'; + +import { ExpandableLink } from './expandable-link'; +import { Box } from '../box'; +import { ExpandableLinkProps } from './defs'; + +export default { + component: ExpandableLink, + title: 'ExpandableLink', +} as Meta; + +const Template: Story = (props) => { + return ( + +
+ + Inputs + + + Empty Input + + + Filled Input + + + +
+
+ ); +}; + +export const Default = Template.bind({}); +Default.args = { + active: true, +}; diff --git a/system/libs/figa-ui/src/lib/expandable-link/expandable-link.test.tsx b/system/libs/figa-ui/src/lib/expandable-link/expandable-link.test.tsx new file mode 100644 index 000000000..f56805d2a --- /dev/null +++ b/system/libs/figa-ui/src/lib/expandable-link/expandable-link.test.tsx @@ -0,0 +1,34 @@ +import { render } from '@testing-library/react'; +import { ExpandableLink } from './expandable-link'; +import { ThemeProvider } from '../theme-provider'; + +describe('Exapndable link can be used when:', () => { + const Fixture = () => { + return ( + + + + Inputs + + + + Empty Input + + + Filled Input + + + + + ); + }; + + it('[FRAGILE] assigns class names for particular nodes', () => { + const { asFragment } = render(); + + expect(asFragment()).toMatchSnapshot(); + }); +}); diff --git a/system/libs/figa-ui/src/lib/expandable-link/expandable-link.tsx b/system/libs/figa-ui/src/lib/expandable-link/expandable-link.tsx new file mode 100644 index 000000000..b28e4dab0 --- /dev/null +++ b/system/libs/figa-ui/src/lib/expandable-link/expandable-link.tsx @@ -0,0 +1,126 @@ +import styled from 'styled-components'; +import type { + ExpandableLinkProps, + ExpandableLinkItemProps, + ExpandableLinkNameProps, + ExpandableLinkListProps, +} from './defs'; +import c from 'classnames'; +import { column, size } from '../shared'; +import { tokens } from '../theme-provider'; +import { ListItem } from '../list'; +import { Link } from '../link'; + +const Container = styled.nav` + ${column()} + user-select: none; + position: relative; + + &:hover, + &:focus { + color: ${(props) => props.theme.font.primary.color}; + & .expandable-link-list { + display: block; + } + } + + &.active { + &::after { + content: ''; + position: absolute; + left: 0; + bottom: 0; + ${size(tokens.spacing[50], '100%')}; + background-color: ${(props) => props.theme.outline.color}; + } + + & .expandable-link-name { + color: ${(props) => props.theme.font.primary.color}; + } + } + + .expandable-link-list { + position: absolute; + top: 100%; + left: 0; + display: none; + white-space: nowrap; + + &:focus-within, + &:hover { + display: block; + } + } + + .expandable-link-name { + cursor: pointer; + width: fit-content; + padding: ${tokens.spacing[400]} ${tokens.spacing[300]}; + background-color: ${(props) => props.theme.box.filled.bg}; + } + + .expandable-link-list-item { + cursor: pointer; + background-color: ${(props) => props.theme.box.filled.bg}; + padding: ${tokens.spacing[100]} ${tokens.spacing[200]}; + display: block; + + & { + text-decoration: none; + } + + &:hover span { + color: ${(props) => props.theme.font.primary.color}; + } + } +`; + +const ExpandableLinkName = ({ + className, + children, +}: ExpandableLinkNameProps) => { + return ( + + {children} + + ); +}; + +const ExpandableLinkItem = ({ + children, + className, + path, +}: ExpandableLinkItemProps) => { + return ( + + + {children} + + + ); +}; + +const ExpandableLinkList = ({ + className, + children, +}: ExpandableLinkListProps) => { + return
    {children}
; +}; + +const ExpandableLink = ({ + className, + children, + active, +}: ExpandableLinkProps) => { + return ( + + {children} + + ); +}; + +ExpandableLink.Name = ExpandableLinkName; +ExpandableLink.List = ExpandableLinkList; +ExpandableLink.Item = ExpandableLinkItem; + +export { ExpandableLink }; diff --git a/system/libs/figa-ui/src/lib/expandable-link/index.ts b/system/libs/figa-ui/src/lib/expandable-link/index.ts new file mode 100644 index 000000000..24277ce34 --- /dev/null +++ b/system/libs/figa-ui/src/lib/expandable-link/index.ts @@ -0,0 +1 @@ +export * from './expandable-link'; \ No newline at end of file