@fpkit/acss 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/dist/chunk-77CZU5XZ.cjs +9 -0
- package/dist/chunk-77CZU5XZ.cjs.map +1 -0
- package/dist/chunk-D43FJIRQ.cjs +31 -0
- package/dist/chunk-D43FJIRQ.cjs.map +1 -0
- package/dist/chunk-GJWMCDFS.js +9 -0
- package/dist/chunk-GJWMCDFS.js.map +1 -0
- package/dist/chunk-PCDUGD3C.js +5 -0
- package/dist/chunk-PCDUGD3C.js.map +1 -0
- package/dist/hooks.cjs +10 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.cts +32 -0
- package/dist/hooks.d.ts +32 -0
- package/dist/hooks.js +8 -0
- package/dist/hooks.js.map +1 -0
- package/dist/icon-e6044c73.d.ts +227 -0
- package/dist/icons.cjs +73 -0
- package/dist/icons.cjs.map +1 -0
- package/dist/icons.d.cts +252 -0
- package/dist/icons.d.ts +252 -0
- package/dist/icons.js +4 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.cjs +59 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +566 -0
- package/dist/index.d.ts +566 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/libs/chunk-GCGKYLDG.js +7 -0
- package/libs/chunk-GCGKYLDG.js.map +1 -0
- package/libs/chunk-PDD4N5P5.cjs +10 -0
- package/libs/chunk-PDD4N5P5.cjs.map +1 -0
- package/libs/chunk-QHIABQNQ.js +8 -0
- package/libs/chunk-QHIABQNQ.js.map +1 -0
- package/libs/chunk-ZOHIKF6I.cjs +31 -0
- package/libs/chunk-ZOHIKF6I.cjs.map +1 -0
- package/libs/components/badge/badge.css +1 -0
- package/libs/components/badge/badge.css.map +1 -0
- package/libs/components/badge/badge.min.css +3 -0
- package/libs/components/breadcrumbs/breadcrumb.css +1 -0
- package/libs/components/breadcrumbs/breadcrumb.css.map +1 -0
- package/libs/components/breadcrumbs/breadcrumb.min.css +3 -0
- package/libs/components/buttons/button.css +1 -0
- package/libs/components/buttons/button.css.map +1 -0
- package/libs/components/buttons/button.min.css +3 -0
- package/libs/components/cards/card-style.css +1 -0
- package/libs/components/cards/card-style.css.map +1 -0
- package/libs/components/cards/card-style.min.css +3 -0
- package/libs/components/cards/card.css +1 -0
- package/libs/components/cards/card.css.map +1 -0
- package/libs/components/cards/card.min.css +3 -0
- package/libs/components/details/details.css +1 -0
- package/libs/components/details/details.css.map +1 -0
- package/libs/components/details/details.min.css +3 -0
- package/libs/components/form/form.css +1 -0
- package/libs/components/form/form.css.map +1 -0
- package/libs/components/form/form.min.css +3 -0
- package/libs/components/icons/icon.css +1 -0
- package/libs/components/icons/icon.css.map +1 -0
- package/libs/components/icons/icon.min.css +3 -0
- package/libs/components/images/img.css +1 -0
- package/libs/components/images/img.css.map +1 -0
- package/libs/components/images/img.min.css +3 -0
- package/libs/components/layout/landmarks.css +1 -0
- package/libs/components/layout/landmarks.css.map +1 -0
- package/libs/components/layout/landmarks.min.css +3 -0
- package/libs/components/link/link.css +1 -0
- package/libs/components/link/link.css.map +1 -0
- package/libs/components/link/link.min.css +3 -0
- package/libs/components/nav/nav.css +1 -0
- package/libs/components/nav/nav.css.map +1 -0
- package/libs/components/nav/nav.min.css +3 -0
- package/libs/components/progress/progress.css +1 -0
- package/libs/components/progress/progress.css.map +1 -0
- package/libs/components/progress/progress.min.css +3 -0
- package/libs/components/styles/index.css +1 -0
- package/libs/components/styles/index.css.map +1 -0
- package/libs/components/styles/index.min.css +3 -0
- package/libs/components/tag/tag.css +1 -0
- package/libs/components/tag/tag.css.map +1 -0
- package/libs/components/tag/tag.min.css +3 -0
- package/libs/components/text-to-speech/text-to-speech.css +1 -0
- package/libs/components/text-to-speech/text-to-speech.css.map +1 -0
- package/libs/components/text-to-speech/text-to-speech.min.css +3 -0
- package/libs/hooks.cjs +12 -0
- package/libs/hooks.cjs.map +1 -0
- package/libs/hooks.d.cts +32 -0
- package/libs/hooks.d.ts +32 -0
- package/libs/hooks.js +3 -0
- package/libs/hooks.js.map +1 -0
- package/libs/icons-1f5afc0c.d.ts +318 -0
- package/libs/icons.cjs +12 -0
- package/libs/icons.cjs.map +1 -0
- package/libs/icons.d.cts +2 -0
- package/libs/icons.d.ts +2 -0
- package/libs/icons.js +3 -0
- package/libs/icons.js.map +1 -0
- package/libs/index.cjs +71 -0
- package/libs/index.cjs.map +1 -0
- package/libs/index.css +1 -0
- package/libs/index.css.map +1 -0
- package/libs/index.d.cts +551 -0
- package/libs/index.d.ts +551 -0
- package/libs/index.js +11 -0
- package/libs/index.js.map +1 -0
- package/package.json +125 -0
- package/src/App.css +42 -0
- package/src/App.tsx +35 -0
- package/src/__snapshots__/App.test.tsx.snap +56 -0
- package/src/components/.gitkeep +0 -0
- package/src/components/__snapshots__/fp.test.tsx.snap +3 -0
- package/src/components/badge/badge.scss +20 -0
- package/src/components/badge/badge.stories.tsx +54 -0
- package/src/components/badge/badge.tsx +17 -0
- package/src/components/breadcrumbs/bc-item.tsx +20 -0
- package/src/components/breadcrumbs/breadcrumb.scss +35 -0
- package/src/components/breadcrumbs/breadcrumb.stories.tsx +92 -0
- package/src/components/breadcrumbs/breadcrumb.tsx +218 -0
- package/src/components/buttons/button.scss +115 -0
- package/src/components/buttons/button.stories.tsx +57 -0
- package/src/components/buttons/button.test.tsx +104 -0
- package/src/components/buttons/button.tsx +64 -0
- package/src/components/cards/card-style.scss +0 -0
- package/src/components/cards/card.scss +43 -0
- package/src/components/cards/card.stories.tsx +114 -0
- package/src/components/cards/card.test.tsx +30 -0
- package/src/components/cards/card.tsx +135 -0
- package/src/components/cards/flex-card.tsx +15 -0
- package/src/components/details/details.scss +75 -0
- package/src/components/details/details.stories.tsx +122 -0
- package/src/components/details/details.tsx +77 -0
- package/src/components/form/README.mdx +70 -0
- package/src/components/form/fields.tsx +45 -0
- package/src/components/form/form.scss +87 -0
- package/src/components/form/form.stories.tsx +49 -0
- package/src/components/form/form.tsx +71 -0
- package/src/components/form/input.stories.tsx +155 -0
- package/src/components/form/inputs.tsx +84 -0
- package/src/components/form/select.stories.tsx +38 -0
- package/src/components/form/select.tsx +112 -0
- package/src/components/form/textarea.tsx +87 -0
- package/src/components/fp.test.tsx +56 -0
- package/src/components/fp.tsx +78 -0
- package/src/components/heading/heading.stories.tsx +75 -0
- package/src/components/heading/heading.tsx +27 -0
- package/src/components/icons/components/add.tsx +42 -0
- package/src/components/icons/components/arrow-down.tsx +52 -0
- package/src/components/icons/components/arrow-left.tsx +49 -0
- package/src/components/icons/components/arrow-right.tsx +52 -0
- package/src/components/icons/components/arrow-up.tsx +49 -0
- package/src/components/icons/components/chat.tsx +44 -0
- package/src/components/icons/components/code.tsx +50 -0
- package/src/components/icons/components/copy.tsx +51 -0
- package/src/components/icons/components/down.tsx +33 -0
- package/src/components/icons/components/home.tsx +57 -0
- package/src/components/icons/components/left.tsx +43 -0
- package/src/components/icons/components/minus.tsx +42 -0
- package/src/components/icons/components/pause-solid.tsx +48 -0
- package/src/components/icons/components/pause.tsx +63 -0
- package/src/components/icons/components/play-solid.tsx +44 -0
- package/src/components/icons/components/play.tsx +51 -0
- package/src/components/icons/components/remove.tsx +42 -0
- package/src/components/icons/components/resume-solid.tsx +52 -0
- package/src/components/icons/components/resume.tsx +57 -0
- package/src/components/icons/components/right.tsx +43 -0
- package/src/components/icons/components/star.tsx +38 -0
- package/src/components/icons/components/stop-solid.tsx +44 -0
- package/src/components/icons/components/stop.tsx +54 -0
- package/src/components/icons/components/svg.tsx +44 -0
- package/src/components/icons/components/up.tsx +31 -0
- package/src/components/icons/components/user.tsx +46 -0
- package/src/components/icons/icon.scss +15 -0
- package/src/components/icons/icon.stories.tsx +208 -0
- package/src/components/icons/icon.tsx +100 -0
- package/src/components/icons/index.ts +29 -0
- package/src/components/icons/types.ts +12 -0
- package/src/components/images/README.mdx +43 -0
- package/src/components/images/figure.stories.tsx +34 -0
- package/src/components/images/figure.tsx +44 -0
- package/src/components/images/img.scss +43 -0
- package/src/components/images/img.stories.tsx +24 -0
- package/src/components/images/img.test.tsx +43 -0
- package/src/components/images/img.tsx +93 -0
- package/src/components/images/place-holder.png +0 -0
- package/src/components/kit.tsx +56 -0
- package/src/components/layout/_header.scss +72 -0
- package/src/components/layout/footer.stories.tsx +34 -0
- package/src/components/layout/landmarks.scss +51 -0
- package/src/components/layout/landmarks.stories.tsx +54 -0
- package/src/components/layout/landmarks.tsx +149 -0
- package/src/components/layout/main.stories.tsx +90 -0
- package/src/components/link/link.scss +92 -0
- package/src/components/link/link.stories.tsx +74 -0
- package/src/components/link/link.tsx +48 -0
- package/src/components/list/list.stories.tsx +52 -0
- package/src/components/list/list.tsx +74 -0
- package/src/components/modal/dialog.tsx +50 -0
- package/src/components/modal/modal.tsx +85 -0
- package/src/components/nav/nav.scss +90 -0
- package/src/components/nav/nav.stories.tsx +96 -0
- package/src/components/nav/nav.tsx +76 -0
- package/src/components/popover/node_modules/.vitest/results.json +1 -0
- package/src/components/popover/popover.stories.tsx +31 -0
- package/src/components/popover/popover.test.tsx +39 -0
- package/src/components/popover/popover.tsx +85 -0
- package/src/components/progress/progress.scss +70 -0
- package/src/components/progress/progress.stories.tsx +51 -0
- package/src/components/progress/progress.tsx +82 -0
- package/src/components/readme.stories.mdx +7 -0
- package/src/components/styles/index.css +520 -0
- package/src/components/styles/index.css.map +1 -0
- package/src/components/tables/table-elements.tsx +57 -0
- package/src/components/tables/table.tsx +57 -0
- package/src/components/tag/tag.scss +56 -0
- package/src/components/tag/tag.stories.tsx +39 -0
- package/src/components/tag/tag.tsx +25 -0
- package/src/components/text/text.stories.tsx +67 -0
- package/src/components/text/text.tsx +93 -0
- package/src/components/text-to-speech/README.mdx +192 -0
- package/src/components/text-to-speech/TextInput.tsx +19 -0
- package/src/components/text-to-speech/TextToSpeech.stories.tsx +145 -0
- package/src/components/text-to-speech/TextToSpeech.tsx +94 -0
- package/src/components/text-to-speech/text-to-speech.scss +31 -0
- package/src/components/text-to-speech/useTextToSpeech.mdx +182 -0
- package/src/components/text-to-speech/useTextToSpeech.tsx +176 -0
- package/src/components/text-to-speech/views/TextToSpeechControls.tsx +117 -0
- package/src/components/ui.tsx +67 -0
- package/src/favicon.svg +15 -0
- package/src/hooks/popover/__snapshots__/popover.test.tsx.snap +88 -0
- package/src/hooks/popover/node_modules/.vitest/results.json +1 -0
- package/src/hooks/popover/popover.tsx +71 -0
- package/src/hooks/popover/use-popover.tsx +83 -0
- package/src/hooks.ts +1 -0
- package/src/icons.ts +1 -0
- package/src/index.css +13 -0
- package/src/index.scss +19 -0
- package/src/index.ts +35 -0
- package/src/libs/content.ts +30 -0
- package/src/logo.svg +7 -0
- package/src/main.tsx +10 -0
- package/src/patterns/.gitkeep +0 -0
- package/src/patterns/page/page-header.stories.tsx +44 -0
- package/src/patterns/page/page-header.tsx +78 -0
- package/src/sass/_elements.scss +17 -0
- package/src/sass/_globals.scss +162 -0
- package/src/sass/_layout.scss +51 -0
- package/src/sass/_loading-animation.scss +35 -0
- package/src/sass/_mixins.scss +10 -0
- package/src/sass/_properties.scss +106 -0
- package/src/sass/_reset.scss +183 -0
- package/src/sass/_type.scss +43 -0
- package/src/setupTest.ts +1 -0
- package/src/styles/badge/badge.css +22 -0
- package/src/styles/badge/badge.css.map +1 -0
- package/src/styles/breadcrumbs/breadcrumb.css +42 -0
- package/src/styles/breadcrumbs/breadcrumb.css.map +1 -0
- package/src/styles/buttons/button.css +93 -0
- package/src/styles/buttons/button.css.map +1 -0
- package/src/styles/cards/card-style.css +3 -0
- package/src/styles/cards/card-style.css.map +1 -0
- package/src/styles/cards/card.css +48 -0
- package/src/styles/cards/card.css.map +1 -0
- package/src/styles/details/details.css +69 -0
- package/src/styles/details/details.css.map +1 -0
- package/src/styles/dropdowns/dropdown.css.map +1 -0
- package/src/styles/form/form.css +93 -0
- package/src/styles/form/form.css.map +1 -0
- package/src/styles/form/style.css.map +1 -0
- package/src/styles/icons/icon.css +16 -0
- package/src/styles/icons/icon.css.map +1 -0
- package/src/styles/images/img.css +42 -0
- package/src/styles/images/img.css.map +1 -0
- package/src/styles/index.css +1330 -0
- package/src/styles/index.css.map +1 -0
- package/src/styles/layout/landmarks.css +155 -0
- package/src/styles/layout/landmarks.css.map +1 -0
- package/src/styles/link/link.css +88 -0
- package/src/styles/link/link.css.map +1 -0
- package/src/styles/nav/nav.css +85 -0
- package/src/styles/nav/nav.css.map +1 -0
- package/src/styles/progress/progress.css +54 -0
- package/src/styles/progress/progress.css.map +1 -0
- package/src/styles/progress/sass/progress.css.map +1 -0
- package/src/styles/styles/index.css +562 -0
- package/src/styles/styles/index.css.map +1 -0
- package/src/styles/tag/badge.css.map +1 -0
- package/src/styles/tag/tag.css +71 -0
- package/src/styles/tag/tag.css.map +1 -0
- package/src/styles/text-to-speech/text-to-speech.css +32 -0
- package/src/styles/text-to-speech/text-to-speech.css.map +1 -0
- package/src/test/setup.ts +6 -0
- package/src/types/component-props.ts +36 -0
- package/src/types/index.ts +2 -0
- package/src/types/input-props.ts +28 -0
- package/src/types/shared.ts +57 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import UI from '../ui'
|
|
2
|
+
import List from '../list/list'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
export type NavListProps = React.ComponentProps<typeof List> & {
|
|
6
|
+
isBlock?: boolean
|
|
7
|
+
}
|
|
8
|
+
export type NavItemProps = React.ComponentProps<typeof List.ListItem>
|
|
9
|
+
|
|
10
|
+
export type NavProps = React.ComponentProps<typeof UI>
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Renders a NavList component.
|
|
14
|
+
* @param {Object} props - The props for the component.
|
|
15
|
+
* @param {ReactNode} props.children - The child elements.
|
|
16
|
+
* @param {Object} props - Additional props to spread to the List component.
|
|
17
|
+
* @returns {JSX.Element} The rendered NavList component.
|
|
18
|
+
*/
|
|
19
|
+
export const NavList = ({ isBlock, children, ...props }: NavListProps) => {
|
|
20
|
+
return (
|
|
21
|
+
<List type="ul" {...props} data-list={`unstyled ${isBlock ? 'block' : ''}`}>
|
|
22
|
+
{children}
|
|
23
|
+
</List>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Renders a NavItem component.
|
|
29
|
+
* @param {Object} props - The props for the component.
|
|
30
|
+
* @param {string} [props.id] - The id for the component.
|
|
31
|
+
* @param {Object} [props.styles] - The styles for the component.
|
|
32
|
+
* @param {string} [props.classes] - The classes for the component.
|
|
33
|
+
* @param {ReactNode} props.children - The child elements.
|
|
34
|
+
* @param {boolean} [props.inline=true] - Whether the item should display inline.
|
|
35
|
+
* @param {Object} props - Additional props to spread to the ListItem component.
|
|
36
|
+
* @returns {JSX.Element} The rendered NavItem component.
|
|
37
|
+
*/
|
|
38
|
+
export const NavItem = ({
|
|
39
|
+
id,
|
|
40
|
+
styles,
|
|
41
|
+
classes,
|
|
42
|
+
children,
|
|
43
|
+
...props
|
|
44
|
+
}: NavItemProps) => {
|
|
45
|
+
return (
|
|
46
|
+
<List.ListItem
|
|
47
|
+
type="li"
|
|
48
|
+
id={id}
|
|
49
|
+
classes={classes}
|
|
50
|
+
styles={styles}
|
|
51
|
+
{...props}
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
</List.ListItem>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Renders a Nav component.
|
|
60
|
+
* @param {Object} props - The props for the component.
|
|
61
|
+
* @param {ReactNode} props.children - The child elements.
|
|
62
|
+
* @param {Object} props - Additional props to spread to the UI component.
|
|
63
|
+
* @returns {JSX.Element} The rendered Nav component.
|
|
64
|
+
*/
|
|
65
|
+
export const Nav = ({ children, ...props }: NavProps) => {
|
|
66
|
+
return (
|
|
67
|
+
<UI as="nav" {...props}>
|
|
68
|
+
{children}
|
|
69
|
+
</UI>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default Nav
|
|
74
|
+
Nav.displayName = 'Nav'
|
|
75
|
+
Nav.List = NavList
|
|
76
|
+
Nav.Item = NavItem
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"0.33.0","results":[[":popover.test.tsx",{"duration":0,"failed":true}]]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
+
import { within, userEvent, screen } from '@storybook/testing-library'
|
|
3
|
+
import { expect } from '@storybook/jest'
|
|
4
|
+
|
|
5
|
+
import Popover from './popover'
|
|
6
|
+
import { getByText } from '@testing-library/react'
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof Popover> = {
|
|
9
|
+
title: 'FP.React Components/Basic Popover',
|
|
10
|
+
component: Popover,
|
|
11
|
+
args: {
|
|
12
|
+
children: 'Hi, I am a popover.',
|
|
13
|
+
popoverTrigger: 'Hover here',
|
|
14
|
+
styles: Popover.styles,
|
|
15
|
+
},
|
|
16
|
+
} as Meta
|
|
17
|
+
|
|
18
|
+
export default meta
|
|
19
|
+
type Story = StoryObj<typeof Popover>
|
|
20
|
+
|
|
21
|
+
export const PopoverComponent: Story = {
|
|
22
|
+
args: {},
|
|
23
|
+
play: async ({ canvasElement }) => {
|
|
24
|
+
const canvas = within(canvasElement)
|
|
25
|
+
expect(await canvas.queryByText('Hover here')).toBeInTheDocument()
|
|
26
|
+
userEvent.hover(canvas.getByText('Hover here'))
|
|
27
|
+
expect(await canvas.findByText('Hi, I am a popover.')).toBeInTheDocument()
|
|
28
|
+
await userEvent.unhover(canvas.getByText('Hover here'))
|
|
29
|
+
expect(canvas.queryByText('Hi, I am a popover.')).not.toBeInTheDocument()
|
|
30
|
+
},
|
|
31
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react'
|
|
3
|
+
import Popover from './popover'
|
|
4
|
+
import userEvent from '@testing-library/user-event'
|
|
5
|
+
|
|
6
|
+
describe('Popover', () => {
|
|
7
|
+
it('renders the popover content when the trigger element is hovered', async () => {
|
|
8
|
+
render(
|
|
9
|
+
<Popover popoverTrigger={<button>Hover here</button>}>
|
|
10
|
+
Popover content
|
|
11
|
+
</Popover>,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
const triggerElement = screen.getByRole('button', {
|
|
15
|
+
name: /hover here/i,
|
|
16
|
+
})
|
|
17
|
+
userEvent.hover(triggerElement)
|
|
18
|
+
expect(await screen.findByText('Popover content')).toBeInTheDocument()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('hides the popover content when the trigger element is no longer hovered', () => {
|
|
22
|
+
render(
|
|
23
|
+
<Popover popoverTrigger={<button>Hover here</button>}>
|
|
24
|
+
Popover content
|
|
25
|
+
</Popover>,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const triggerElement = screen.getByRole('button', {
|
|
29
|
+
name: /hover here/i,
|
|
30
|
+
})
|
|
31
|
+
fireEvent.pointerEnter(triggerElement)
|
|
32
|
+
|
|
33
|
+
const popoverContent = screen.getByText('Popover content')
|
|
34
|
+
expect(popoverContent).toBeInTheDocument()
|
|
35
|
+
|
|
36
|
+
fireEvent.pointerLeave(triggerElement)
|
|
37
|
+
expect(popoverContent).not.toBeInTheDocument()
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import usePopover from '#hooks/popover/use-popover'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Interface for props accepted by the Popover component
|
|
6
|
+
*
|
|
7
|
+
* @property {ReactNode} children - The content to show in the popover
|
|
8
|
+
* @property {ReactNode} [content] - Optional alternative content for popover
|
|
9
|
+
*/
|
|
10
|
+
export type PopoverProps = {
|
|
11
|
+
children: React.ReactNode
|
|
12
|
+
popoverTrigger: React.ReactNode
|
|
13
|
+
styles?: {}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const defaultStyles = {
|
|
17
|
+
display: 'block',
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
background: '#000',
|
|
20
|
+
border: '1px solid #010101',
|
|
21
|
+
padding: '10px',
|
|
22
|
+
color: '#fff',
|
|
23
|
+
transition: 'opacity .5s ease-in-out',
|
|
24
|
+
} as React.CSSProperties
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Popover component to display popover content.
|
|
28
|
+
*
|
|
29
|
+
* @param props - The props for the component
|
|
30
|
+
* @param props.children - The content to show in the popover
|
|
31
|
+
* @param props.popoverTrigger - The element that triggers the popover on hover
|
|
32
|
+
*
|
|
33
|
+
* @returns JSX.Element - The rendered JSX element for the Popover
|
|
34
|
+
* @example - <Popover popoverTrigger={<button>Hover here</button>}>Popover content</Popover>
|
|
35
|
+
*
|
|
36
|
+
* The component uses the usePopover hook to handle popover visibility and positioning.
|
|
37
|
+
*
|
|
38
|
+
* It renders the triggerElement, and conditionally renders the popover content
|
|
39
|
+
* positioned absolutely when visible.
|
|
40
|
+
*
|
|
41
|
+
* Inline styles handle visuals like background, border, padding, etc.
|
|
42
|
+
*
|
|
43
|
+
* Transforms and opacity animate the enter/exit transition of the popover.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
export const Popover = ({
|
|
47
|
+
children,
|
|
48
|
+
popoverTrigger,
|
|
49
|
+
styles,
|
|
50
|
+
...props
|
|
51
|
+
}: PopoverProps): JSX.Element => {
|
|
52
|
+
const hoverRef = React.useRef(null)
|
|
53
|
+
const popOverRef = React.useRef(null)
|
|
54
|
+
const { isVisible, popoverPosition, handlePointerEvent, handlePointerLeave } =
|
|
55
|
+
usePopover(hoverRef, popOverRef)
|
|
56
|
+
const popoverStyles = {
|
|
57
|
+
opacity: isVisible ? 1 : 0,
|
|
58
|
+
top: popoverPosition.top,
|
|
59
|
+
left: popoverPosition.left,
|
|
60
|
+
// transform: `translateY(${isVisible ? '0px' : '-50px'})`,
|
|
61
|
+
zIndex: 999,
|
|
62
|
+
} as React.CSSProperties
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<div
|
|
67
|
+
ref={hoverRef}
|
|
68
|
+
onPointerEnter={handlePointerEvent}
|
|
69
|
+
onPointerLeave={handlePointerLeave}
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
{popoverTrigger}
|
|
73
|
+
</div>
|
|
74
|
+
{isVisible && (
|
|
75
|
+
<div ref={popOverRef} style={{ ...popoverStyles, ...styles }}>
|
|
76
|
+
{children}
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
</>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default Popover
|
|
84
|
+
Popover.displayName = 'Popover'
|
|
85
|
+
Popover.styles = defaultStyles
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
progress {
|
|
2
|
+
/* Revert all styles */
|
|
3
|
+
all: revert;
|
|
4
|
+
--progress-w: 100%;
|
|
5
|
+
--progress-h: 1rem;
|
|
6
|
+
--progress-bg: #cccccc;
|
|
7
|
+
--progress-color: rgb(71, 71, 245);
|
|
8
|
+
--progress-accent-color: var(--progress-color);
|
|
9
|
+
|
|
10
|
+
/* This code changes the color of the progress bar. */
|
|
11
|
+
/* The variable names indicate the colors that are used. */
|
|
12
|
+
/* The colors are used in the progress bar. */
|
|
13
|
+
&[value] {
|
|
14
|
+
|
|
15
|
+
width: var(--progress-w);
|
|
16
|
+
height: var(--progress-h);
|
|
17
|
+
background-color: var(--progress-bg);
|
|
18
|
+
accent-color: var(--progress-accent-color);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
&::-webkit-progress-value {
|
|
22
|
+
/* Color for Chrome, Safari, and newer Opera */
|
|
23
|
+
background-color: var(--progress-accent-color);
|
|
24
|
+
accent-color: var(--progress-accent-color);
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&::-moz-progress-bar {
|
|
29
|
+
/* Color for Firefox */
|
|
30
|
+
background-color: var(--progress-accent-color);
|
|
31
|
+
accent-color: var(--progress-accent-color)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Styling for the remaining part of the& bar */
|
|
35
|
+
&::-webkit-progress-bar {
|
|
36
|
+
/* Background for Chrome, Safari, and newer Opera */
|
|
37
|
+
background-color: var(--progress-background-color);
|
|
38
|
+
accent-color: var(--progress-accent-color)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* If the progress element is busy, remove the revert styles */
|
|
43
|
+
&[aria-busy] {
|
|
44
|
+
// all: revert;
|
|
45
|
+
width: var(--progress-w);
|
|
46
|
+
height: var(--progress-h);
|
|
47
|
+
// height: calc(var(--progress-h) + var(--progress-h));
|
|
48
|
+
accent-color: var(--progress-accent-color);
|
|
49
|
+
|
|
50
|
+
&::-webkit-progress-value {
|
|
51
|
+
/* Color for Chrome, Safari, and newer Opera */
|
|
52
|
+
// background-color: var(--progress-accent-color);
|
|
53
|
+
accent-color: var(--progress-accent-color)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&::-moz-progress-bar {
|
|
57
|
+
// /* Color for Firefox */
|
|
58
|
+
// background-color: var(--progress-bg);
|
|
59
|
+
accent-color: var(--progress-accent-color)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Styling for the remaining part of the& bar */
|
|
63
|
+
&::-webkit-progress-bar {
|
|
64
|
+
/* Background for Chrome, Safari, and newer Opera */
|
|
65
|
+
// background-color: var(--progress-bg);
|
|
66
|
+
accent-color: var(--progress-accent-color)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
+
import { within, userEvent, screen } from '@storybook/testing-library'
|
|
3
|
+
import { expect } from '@storybook/jest'
|
|
4
|
+
|
|
5
|
+
import '../../styles/progress/progress.css'
|
|
6
|
+
|
|
7
|
+
import Progress from './progress'
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof Progress> = {
|
|
10
|
+
title: 'FP.React Components/Progress',
|
|
11
|
+
component: Progress,
|
|
12
|
+
args: {},
|
|
13
|
+
decorators: [
|
|
14
|
+
(Story) => (
|
|
15
|
+
<div style={{ minWidth: '500px', height: '100%' }}>
|
|
16
|
+
<Story />
|
|
17
|
+
</div>
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
} as Meta
|
|
21
|
+
|
|
22
|
+
export default meta
|
|
23
|
+
type Story = StoryObj<typeof Progress>
|
|
24
|
+
|
|
25
|
+
export const ProgressComponent: Story = {
|
|
26
|
+
name: 'Progress Bar',
|
|
27
|
+
args: {
|
|
28
|
+
isBusy: true,
|
|
29
|
+
},
|
|
30
|
+
play: async ({ canvasElement }) => {
|
|
31
|
+
const canvas = within(canvasElement)
|
|
32
|
+
//expect(canvas).toBeInTheDocument()
|
|
33
|
+
},
|
|
34
|
+
} as Story
|
|
35
|
+
|
|
36
|
+
export const ProgressIndicator: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
value: 3,
|
|
39
|
+
max: 10,
|
|
40
|
+
},
|
|
41
|
+
} as Story
|
|
42
|
+
|
|
43
|
+
export const RedProgress: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
...ProgressIndicator.args,
|
|
46
|
+
styles: {
|
|
47
|
+
'--progress-color': 'red',
|
|
48
|
+
},
|
|
49
|
+
value: 7,
|
|
50
|
+
},
|
|
51
|
+
} as Story
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
type ProgressRules =
|
|
4
|
+
| {
|
|
5
|
+
/** Indicates progress bar is in busy/loading state */
|
|
6
|
+
isBusy?: true
|
|
7
|
+
|
|
8
|
+
/** No current value when in busy state */
|
|
9
|
+
value?: never
|
|
10
|
+
|
|
11
|
+
/** No max value needed when in busy state */
|
|
12
|
+
max?: never
|
|
13
|
+
}
|
|
14
|
+
| {
|
|
15
|
+
/** Indicates progress bar is not in busy state */
|
|
16
|
+
isBusy?: false | undefined
|
|
17
|
+
|
|
18
|
+
/** Current value of progress bar */
|
|
19
|
+
value: number
|
|
20
|
+
|
|
21
|
+
/** Max value of progress bar */
|
|
22
|
+
max: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type ProgressProps = {
|
|
26
|
+
/**
|
|
27
|
+
* Optional styles to pass to override default styles
|
|
28
|
+
* Accepts CSSProperties
|
|
29
|
+
*/
|
|
30
|
+
styles?: React.CSSProperties
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Optional accessible label for the progress bar
|
|
34
|
+
*/
|
|
35
|
+
label?: string
|
|
36
|
+
/**
|
|
37
|
+
* Color of the scroll bar
|
|
38
|
+
*/
|
|
39
|
+
color?: string
|
|
40
|
+
} & ProgressRules
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Progress bar component
|
|
44
|
+
* Displays a progress bar with busy and value state
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} classes - CSS classes object
|
|
47
|
+
* @param {ReactNode} [children] - Child elements
|
|
48
|
+
* @param {boolean} isBusy - Whether progress is in busy state
|
|
49
|
+
* @param {number} [value] - Current progress value
|
|
50
|
+
* @param {number} [max] - Max progress value
|
|
51
|
+
* @param {string} [color] - color of the scroll bar
|
|
52
|
+
* @param {Object} props - Other props
|
|
53
|
+
* @returns {JSX.Element} - Rendered progress element
|
|
54
|
+
*/
|
|
55
|
+
const Progress = ({
|
|
56
|
+
styles,
|
|
57
|
+
isBusy,
|
|
58
|
+
value,
|
|
59
|
+
max,
|
|
60
|
+
color,
|
|
61
|
+
label = 'Progress',
|
|
62
|
+
...props
|
|
63
|
+
}: ProgressProps): React.JSX.Element => {
|
|
64
|
+
const defaultStyles = {
|
|
65
|
+
accentColor: color,
|
|
66
|
+
} as React.CSSProperties
|
|
67
|
+
|
|
68
|
+
const style = { ...defaultStyles, ...styles }
|
|
69
|
+
return (
|
|
70
|
+
<progress
|
|
71
|
+
aria-label={label}
|
|
72
|
+
style={style}
|
|
73
|
+
aria-busy={isBusy}
|
|
74
|
+
value={value}
|
|
75
|
+
max={max}
|
|
76
|
+
{...props}
|
|
77
|
+
></progress>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default Progress
|
|
82
|
+
Progress.displayName = 'Progress'
|