From 3843a9bee7493c4f9374a6de661aa70dbfa9f105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=90=E1=85=A2=E1=84=8C=E1=85=A2=E1=84=8B=E1=85=A7?= =?UTF-8?q?=E1=86=BC?= Date: Sun, 19 Jun 2022 03:17:36 +0900 Subject: [PATCH 001/106] fix: Switch Animation In Safari --- packages/react/src/switch/switch.styles.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/react/src/switch/switch.styles.ts b/packages/react/src/switch/switch.styles.ts index 24a159afe7..458a3fdc22 100644 --- a/packages/react/src/switch/switch.styles.ts +++ b/packages/react/src/switch/switch.styles.ts @@ -127,10 +127,10 @@ export const StyledSwitchCircle = styled('span', { size: 'calc($$switchHeight * 0.7)', jc: 'center', ai: 'center', - top: '50%', - transform: 'translateY(-50%)', - left: 'calc($$switchWidth / 15)', - transition: 'left 0.25s ease, width 0.2s ease', + top: 'calc(50% - $$switchHeight * 0.35)', + left: '0', + transform: 'translateX(calc($$switchWidth / 15))', + transition: 'transform 0.25s ease, width 0.2s ease', bg: '$background', br: '$pill', '& svg': { @@ -162,7 +162,8 @@ export const StyledSwitch = styled( true: { bg: '$$switchColor', [`& ${StyledSwitchCircle}`]: { - left: 'calc(100% - ($$switchWidth / 15) - $$switchHeight * 0.7)' + transform: + 'translateX(calc($$switchWidth - $$switchWidth / 15 - 100%))' }, '&:hover:not(&:active)': { bg: '$$switchColorHover' @@ -177,7 +178,8 @@ export const StyledSwitch = styled( borderColor: '$$switchColor' }, [`& ${StyledSwitchCircle}`]: { - left: 'calc(($$switchWidth / 15) - ($$switchBorderW / 2))', + transform: + 'translateX(calc(($$switchWidth / 15) - ($$switchBorderW / 2)))', bg: '$accents2' } } @@ -248,7 +250,7 @@ export const StyledSwitch = styled( css: { '&:active': { [`& ${StyledSwitchCircle}`]: { - left: 'calc($$switchWidth / 7.5)' + transform: 'translateX(calc($$switchWidth / 7.5))' } } } @@ -260,7 +262,8 @@ export const StyledSwitch = styled( css: { '&:active': { [`& ${StyledSwitchCircle}`]: { - left: 'calc(100% - ($$switchWidth / 5) - $$switchHeight * 0.7)' + transform: + 'translateX(calc($$switchWidth - $$switchWidth / 7.5 - 100%))' } } } From 709b18d7e3dd1a2e153009f54222e9d99860a706 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sat, 18 Jun 2022 23:17:06 -0300 Subject: [PATCH 002/106] refactor(react-theme): new sizes added, some fontSizes/linHeights renamed, text component now partially support fontsize tokens --- apps/docs/content/docs/components/text.mdx | 35 +++-- .../docs/content/docs/theme/default-theme.mdx | 123 ++++++++++-------- packages/react/src/avatar/avatar.styles.ts | 2 +- .../react/src/css-baseline/css-baseline.tsx | 6 +- packages/react/src/table/table-pagination.tsx | 7 +- .../__snapshots__/index.test.tsx.snap | 14 +- packages/react/src/text/child.tsx | 47 +++---- packages/react/src/text/text.tsx | 61 +++------ .../__snapshots__/index.test.tsx.snap | 4 +- packages/react/src/theme/common.ts | 47 ++++--- packages/react/src/theme/stitches.config.ts | 19 +++ 11 files changed, 187 insertions(+), 178 deletions(-) diff --git a/apps/docs/content/docs/components/text.mdx b/apps/docs/content/docs/components/text.mdx index 9757bdd65e..509f65b8c0 100644 --- a/apps/docs/content/docs/components/text.mdx +++ b/apps/docs/content/docs/components/text.mdx @@ -67,24 +67,23 @@ import { Text } from '@nextui-org/react'; #### Text Props -| Attribute | Type | Accepted values | Description | Default | -| -------------- | ----------------------- | ---------------------------------- | ------------------------------------- | --------- | -| **h1 - h6** | `boolean` | - | Component name | `false` | -| **small** | `boolean` | - | Component name | `false` | -| **span** | `boolean` | - | Component name | `false` | -| **del** | `boolean` | - | Component name | `false` | -| **i** | `boolean` | - | Component name | `false` | -| **em** | `boolean` | - | Component name | `false` | -| **b** | `boolean` | - | Component name | `false` | -| **blockquote** | `boolean` | - | Component name | `false` | -| **transform** | `TextTransform` | [TextTransforms](#text-transforms) | text-transform prop | `none` | -| **size** | `string` `number` | - | Text size | `inherit` | -| **margin** | `string` `number` | - | Text margin | `inherit` | -| **color** | `SimpleColors` `string` | [SimpleColors](#simple-colors) | Text color | `default` | -| **weight** | `TextWeights` | [TextWeights](#text-weights) | Text weight | `noset` | -| **css** | `Stitches.CSS` | - | Override Default CSS style | - | -| **as** | `keyof JSX.IntrinsicElements` | - | Changes which tag component outputs | `p` | -| ... | `HTMLAttributes` | `'id', 'className', ...` | native props | - | +| Attribute | Type | Accepted values | Description | Default | +| -------------- | ----------------------------- | ---------------------------------- | ----------------------------------- | --------- | +| **h1 - h6** | `boolean` | - | Component name | `false` | +| **small** | `boolean` | - | Component name | `false` | +| **span** | `boolean` | - | Component name | `false` | +| **del** | `boolean` | - | Component name | `false` | +| **i** | `boolean` | - | Component name | `false` | +| **em** | `boolean` | - | Component name | `false` | +| **b** | `boolean` | - | Component name | `false` | +| **blockquote** | `boolean` | - | Component name | `false` | +| **transform** | `TextTransform` | [TextTransforms](#text-transforms) | text-transform prop | `none` | +| **size** | `string` `number` | - | Text size | `inherit` | +| **color** | `SimpleColors` `string` | [SimpleColors](#simple-colors) | Text color | `default` | +| **weight** | `TextWeights` | [TextWeights](#text-weights) | Text weight | `noset` | +| **css** | `Stitches.CSS` | - | Override Default CSS style | - | +| **as** | `keyof JSX.IntrinsicElements` | - | Changes which tag component outputs | `p` | +| ... | `HTMLAttributes` | `'id', 'className', ...` | native props | - | diff --git a/apps/docs/content/docs/theme/default-theme.mdx b/apps/docs/content/docs/theme/default-theme.mdx index 6ada998339..afb67b6aa2 100644 --- a/apps/docs/content/docs/theme/default-theme.mdx +++ b/apps/docs/content/docs/theme/default-theme.mdx @@ -321,14 +321,14 @@ export default { md: '1rem', /* 16px */ lg: '1.125rem', /* 18px */ xl: '1.25rem', /* 20px */ - xl2: '1.5rem', /* 24px */ - xl3: '1.875rem', /* 30px */ - xl4: '2.25rem', /* 36px */ - xl5: '3rem', /* 48px */ - xl6: '3.75rem', /* 60px */ - xl7: '4.5rem', /* 72px */ - xl8: '6rem', /* 96px */ - xl9: '8rem', /* 128px */ + '2xl': '1.5rem', /* 24px */ + '3xl': '1.875rem', /* 30px */ + '4xl': '2.25rem', /* 36px */ + '5xl': '3rem', /* 48px */ + '6xl': '3.75rem', /* 60px */ + '7xl': '4.5rem', /* 72px */ + '8xl': '6rem', /* 96px */ + '9xl': '8rem', /* 128px */ } ... }; @@ -373,14 +373,14 @@ export default { md: 1.5, /* 24px */ lg: 1.75, /* 28px */ xl: 1.75, /* 28px */ - xl2: 2, /* 32px */ - xl3: 2.25, /* 36px */ - xl4: 2.5, /* 40px */ - xl5: 1, - xl6: 1, - xl7: 1, - xl8: 1, - xl9: 1 + '2xl': 2, /* 32px */ + '3xl': 2.25, /* 36px */ + '4xl': 2.5, /* 40px */ + '5xl': 1, /* 16px */ + '6xl': 1, /* 16px */ + '7xl': 1, /* 16px */ + '8xl': 1, /* 16px */ + '9xl': 1 /* 16px */ } ... }; @@ -429,9 +429,11 @@ export default { base: '14px', lg: '14px', // preferred value by NextUI components xl: '18px', + '2xl': '24px', + '3xl': '32px', squared: '33%', rounded: '50%', - pill: '9999px' + pill: '9999px', } ... }; @@ -483,6 +485,19 @@ export default { md: '1rem', lg: '1.375rem', xl: '2.25rem', + '2xl': '3rem', + '3xl': '5rem', + '4xl': '10rem', + '5xl': '14rem', + '6xl': '18rem', + '7xl': '24rem', + '8xl': '32rem', + '9xl': '40rem', + min: 'min-content', + max: 'max-content', + fit: 'fit-content', + screen: '100vw', + full: '100%', px: '1px', 1: '0.125rem', 2: '0.25rem', @@ -524,43 +539,43 @@ export default { -| Name | Space | Pixels | | -| ------- | -------- | ------ | ---------------------------------------------------------- | -| 0 | 0rem | 0px | | -| px | 1px | 1px | | -| 1 | 0.125rem | 2px | | -| 2 | 0.25rem | 4px | | -| 3 | 0.375rem | 6px | | -| 4 (xs) | 0.5rem | 8px | | -| 5 | 0.625rem | 10px | | -| 6 (sm) | 0.75rem | 12px | | -| 7 | 0.875rem | 14px | | -| 8 (md) | 1rem | 16px | | -| 9 (lg) | 1.25rem | 20px | | -| 10 | 1.5rem | 24px | | -| 11 | 1.75rem | 28px | | -| 12 | 2rem | 32px | | -| 13 (xl) | 2.25rem | 36px | | -| 14 | 2.5rem | 40px | | -| 15 | 2.75rem | 44px | | -| 16 | 3rem | 48px | | -| 17 | 3.75rem | 60px | | -| 18 | 4rem | 64px | | -| 20 | 5rem | 80px | | -| 24 | 6rem | 96px | | -| 28 | 7rem | 112px | | -| 32 | 8rem | 128px | | -| 36 | 9rem | 144px | | -| 40 | 10rem | 160px | | -| 44 | 11rem | 176px | | -| 48 | 12rem | 192px | | -| 52 | 13rem | 208px | | -| 56 | 14rem | 224px | | -| 60 | 15rem | 240px | | -| 64 | 16rem | 256px | | -| 72 | 18rem | 288px | | -| 80 | 20rem | 320px | | -| 96 | 24rem | 384px | | +| Name | Space | Pixels | | +| -------- | -------- | ------ | ---------------------------------------------------------- | +| 0 | 0rem | 0px | | +| px | 1px | 1px | | +| 1 | 0.125rem | 2px | | +| 2 | 0.25rem | 4px | | +| 3 | 0.375rem | 6px | | +| 4 (xs) | 0.5rem | 8px | | +| 5 | 0.625rem | 10px | | +| 6 (sm) | 0.75rem | 12px | | +| 7 | 0.875rem | 14px | | +| 8 (md) | 1rem | 16px | | +| 9 (lg) | 1.25rem | 20px | | +| 10 | 1.5rem | 24px | | +| 11 | 1.75rem | 28px | | +| 12 | 2rem | 32px | | +| 13 (xl) | 2.25rem | 36px | | +| 14 | 2.5rem | 40px | | +| 15 | 2.75rem | 44px | | +| 16 (2xl) | 3rem | 48px | | +| 17 | 3.75rem | 60px | | +| 18 | 4rem | 64px | | +| 20 (3xl) | 5rem | 80px | | +| 24 | 6rem | 96px | | +| 28 | 7rem | 112px | | +| 32 | 8rem | 128px | | +| 36 | 9rem | 144px | | +| 40 (4xl) | 10rem | 160px | | +| 44 | 11rem | 176px | | +| 48 | 12rem | 192px | | +| 52 | 13rem | 208px | | +| 56 (5xl) | 14rem | 224px | | +| 60 | 15rem | 240px | | +| 64 | 16rem | 256px | | +| 72 (6xl) | 18rem | 288px | | +| 80 | 20rem | 320px | | +| 96 (7xl) | 24rem | 384px | | diff --git a/packages/react/src/avatar/avatar.styles.ts b/packages/react/src/avatar/avatar.styles.ts index dc4df79c6a..ccbcd00b25 100644 --- a/packages/react/src/avatar/avatar.styles.ts +++ b/packages/react/src/avatar/avatar.styles.ts @@ -175,7 +175,7 @@ export const StyledAvatar = styled( $$avatarXl: '$space$18', sizeMin: '$$avatarXl', '.nextui-avatar-text': { - fontSize: '$xl2' + fontSize: '$2xl' } } }, diff --git a/packages/react/src/css-baseline/css-baseline.tsx b/packages/react/src/css-baseline/css-baseline.tsx index b0bffc298f..e0bffb04d4 100644 --- a/packages/react/src/css-baseline/css-baseline.tsx +++ b/packages/react/src/css-baseline/css-baseline.tsx @@ -86,18 +86,18 @@ const globalStyles = globalCss({ }, h1: { letterSpacing: '$tighter', - fontSize: '$xl5', + fontSize: '$5xl', lineHeight: '$md', fontWeight: '$bold' }, h2: { letterSpacing: '$tighter', - fontSize: '$xl4', + fontSize: '$4xl', fontWeight: '$semibold' }, h3: { letterSpacing: '$tighter', - fontSize: '$xl2', + fontSize: '$2xl', fontWeight: '$semibold' }, h4: { diff --git a/packages/react/src/table/table-pagination.tsx b/packages/react/src/table/table-pagination.tsx index 95a5441cad..00851e0dab 100644 --- a/packages/react/src/table/table-pagination.tsx +++ b/packages/react/src/table/table-pagination.tsx @@ -12,11 +12,14 @@ interface Props { onPageChange?: PaginationProps['onChange']; } -type NativeAttrs = Omit, keyof Props>; +type NativeAttrs = Omit< + React.HTMLAttributes, + keyof Props | 'onChange' +>; export type TablePaginationProps = Props & NativeAttrs & - Omit, 'onChage'> & { css?: CSS }; + Omit, 'onChange'> & { css?: CSS }; const TablePagination: React.FC = ({ align, diff --git a/packages/react/src/text/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/text/__tests__/__snapshots__/index.test.tsx.snap index 454f2acdda..3fc7651ebe 100644 --- a/packages/react/src/text/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/text/__tests__/__snapshots__/index.test.tsx.snap @@ -1,15 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Text should be able to specify the size of text 1`] = `"

test-value

"`; +exports[`Text should be able to specify the size of text 1`] = `"

test-value

"`; -exports[`Text should be able to specify the size of text 2`] = `"

test-value

"`; +exports[`Text should be able to specify the size of text 2`] = `"

test-value

"`; -exports[`Text should render P element in the default 1`] = `"

test-value

"`; +exports[`Text should render P element in the default 1`] = `"

test-value

"`; -exports[`Text should render default color when type missing 1`] = `"

test-value

"`; +exports[`Text should render default color when type missing 1`] = `"

test-value

"`; -exports[`Text should work with different styles 1`] = `"

test-value

test-value

test-value

test-value

"`; +exports[`Text should work with different styles 1`] = `"

test-value

test-value

test-value

test-value

"`; -exports[`Text the combined style should be rendered 1`] = `"test-value"`; +exports[`Text the combined style should be rendered 1`] = `"test-value"`; -exports[`Text the specified element should be rendered 1`] = `"

test-value

test-value

test-value

test-value

test-value
test-value

test-value

test-valuetest-valuetest-valuetest-valuetest-valuetest-value
"`; +exports[`Text the specified element should be rendered 1`] = `"

test-value

test-value

test-value

test-value

test-value
test-value

test-value

test-valuetest-valuetest-valuetest-valuetest-valuetest-value
"`; diff --git a/packages/react/src/text/child.tsx b/packages/react/src/text/child.tsx index 7c779188aa..5ba05c2d3b 100644 --- a/packages/react/src/text/child.tsx +++ b/packages/react/src/text/child.tsx @@ -1,45 +1,36 @@ import React, { useMemo, ReactNode } from 'react'; -import withDefaults from '../utils/with-defaults'; -import { CSS } from '../theme/stitches.config'; +import { CSS, FontSizes, baseTheme } from '../theme/stitches.config'; import { SimpleColors, TextTransforms } from '../utils/prop-types'; import { isNormalColor } from '../utils/color'; import { ReactRef } from '../utils/refs'; import { useDOMRef } from '../utils/dom'; -import { __DEV__ } from '../utils/assertion'; import { StyledText, TextVariantsProps } from './text.styles'; +import { __DEV__ } from '../utils/assertion'; type As = keyof JSX.IntrinsicElements | React.ComponentType; +type FontSize = number | string | keyof FontSizes; export interface Props { tag: keyof JSX.IntrinsicElements; children?: ReactNode; color?: SimpleColors | string; - size?: string | number; - margin?: string | number; + size?: FontSize; transform?: TextTransforms; css?: CSS; as?: As; } -const defaultProps = { - color: 'default' as SimpleColors | string -}; - type NativeAttrs = Omit, keyof Props>; -export type TextChildProps = Props & - typeof defaultProps & - NativeAttrs & - TextVariantsProps; +export type TextChildProps = Props & NativeAttrs & TextVariantsProps; export const TextChild = React.forwardRef( (props: TextChildProps, ref: ReactRef) => { const { children, tag, - color: userColor, + color: userColor = 'default', transform, - margin: marginProp, size, css, ...otherProps @@ -47,6 +38,15 @@ export const TextChild = React.forwardRef( const domRef = useDOMRef(ref); + const fontSize = useMemo(() => { + if (!size) return 'inherit'; + if (typeof size === 'number') return `${size}px`; + if (baseTheme.theme.fontSizes?.[size as keyof FontSizes]) { + return `$${size}`; + } + return size; + }, [size]); + const color = useMemo(() => { if (isNormalColor(userColor)) { switch (userColor) { @@ -59,18 +59,6 @@ export const TextChild = React.forwardRef( return userColor; }, [userColor]); - const fontSize = useMemo(() => { - if (!size) return 'inherit'; - if (typeof size === 'number') return `${size}px`; - return size; - }, [size]); - - const margin = useMemo(() => { - if (!marginProp) return 'inherit'; - if (typeof marginProp === 'number') return `${size}px`; - return marginProp; - }, [marginProp]); - return ( '.nextui-text-child'; -const MemoTextChild = React.memo(TextChild); - -export default withDefaults(MemoTextChild, defaultProps); +export default React.memo(TextChild); diff --git a/packages/react/src/text/text.tsx b/packages/react/src/text/text.tsx index 96fd0217f7..9e1514dde7 100644 --- a/packages/react/src/text/text.tsx +++ b/packages/react/src/text/text.tsx @@ -1,6 +1,5 @@ import React, { ReactNode, useMemo } from 'react'; -import withDefaults from '../utils/with-defaults'; -import { SimpleColors, TextTransforms } from '../utils/prop-types'; +import { TextTransforms } from '../utils/prop-types'; import { ReactRef } from '../utils/refs'; import { useDOMRef } from '../utils/dom'; import { __DEV__ } from '../utils/assertion'; @@ -22,35 +21,13 @@ interface Props { del?: boolean; em?: boolean; blockquote?: boolean; - size?: string | number; - margin?: string | number; - color?: SimpleColors | string; } -const defaultProps = { - h1: false, - h2: false, - h3: false, - h4: false, - h5: false, - h6: false, - b: false, - small: false, - transform: 'none' as TextTransforms, - i: false, - span: false, - del: false, - em: false, - blockquote: false, - color: 'default' as SimpleColors | string -}; - type ElementMap = { [key in keyof JSX.IntrinsicElements]?: boolean }; type NativeAttrs = Omit, keyof Props>; export type TextProps = Props & - typeof defaultProps & NativeAttrs & Omit; @@ -59,7 +36,7 @@ type TextRenderableElements = Array; const getModifierChild = ( tags: TextRenderableElements, children: ReactNode, - size?: string | number, + size?: TextChildProps['size'], transform?: TextTransforms ) => { if (!tags.length) return children; @@ -74,22 +51,21 @@ const getModifierChild = ( export const Text = React.forwardRef( (props: TextProps, ref: ReactRef) => { const { - h1, - h2, - h3, - h4, - h5, - h6, - b, - small, - i, - span, - del, - em, - blockquote, - transform, + h1 = false, + h2 = false, + h3 = false, + h4 = false, + h5 = false, + h6 = false, + b = false, + small = false, + i = false, + span = false, + del = false, + em = false, + blockquote = false, + transform = 'none', size, - margin, children, ...otherProps } = props; @@ -138,7 +114,6 @@ export const Text = React.forwardRef( ref={domRef} transform={transform} tag={tag} - margin={margin} size={size} {...otherProps} > @@ -154,6 +129,4 @@ if (__DEV__) { Text.toString = () => '.nextui-text'; -const MemoText = React.memo(Text); - -export default withDefaults(MemoText, defaultProps); +export default React.memo(Text); diff --git a/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap index b10d6fb8ab..1f9f40f469 100644 --- a/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Textarea should render correctly 1`] = `"
"`; +exports[`Textarea should render correctly 1`] = `"
"`; -exports[`Textarea should work with different styles 1`] = `"
"`; +exports[`Textarea should work with different styles 1`] = `"
"`; diff --git a/packages/react/src/theme/common.ts b/packages/react/src/theme/common.ts index 39f3115557..2aedae0225 100644 --- a/packages/react/src/theme/common.ts +++ b/packages/react/src/theme/common.ts @@ -13,14 +13,14 @@ export const defaultTokens = { md: '1rem', lg: '1.125rem', xl: '1.25rem', - xl2: '1.5rem', - xl3: '1.875rem', - xl4: '2.25rem', - xl5: '3rem', - xl6: '3.75rem', - xl7: '4.5rem', - xl8: '6rem', - xl9: '8rem' + '2xl': '1.5rem', + '3xl': '1.875rem', + '4xl': '2.25rem', + '5xl': '3rem', + '6xl': '3.75rem', + '7xl': '4.5rem', + '8xl': '6rem', + '9xl': '8rem' }, fontWeights: { hairline: 100, @@ -40,14 +40,14 @@ export const defaultTokens = { md: 1.5, lg: 1.75, xl: 1.75, - xl2: 2, - xl3: 2.25, - xl4: 2.5, - xl5: 1, - xl6: 1, - xl7: 1, - xl8: 1, - xl9: 1 + '2xl': 2, + '3xl': 2.25, + '4xl': 2.5, + '5xl': 1, + '6xl': 1, + '7xl': 1, + '8xl': 1, + '9xl': 1 }, letterSpacings: { tighter: '-0.05em', @@ -64,6 +64,19 @@ export const defaultTokens = { md: '1rem', lg: '1.25rem', xl: '2.25rem', + '2xl': '3rem', + '3xl': '5rem', + '4xl': '10rem', + '5xl': '14rem', + '6xl': '18rem', + '7xl': '24rem', + '8xl': '32rem', + '9xl': '40rem', + min: 'min-content', + max: 'max-content', + fit: 'fit-content', + screen: '100vw', + full: '100%', px: '1px', 1: '0.125rem', 2: '0.25rem', @@ -106,6 +119,8 @@ export const defaultTokens = { base: '14px', lg: '14px', xl: '18px', + '2xl': '24px', + '3xl': '32px', squared: '33%', rounded: '50%', pill: '9999px' diff --git a/packages/react/src/theme/stitches.config.ts b/packages/react/src/theme/stitches.config.ts index d77de0c7d6..05172233d6 100644 --- a/packages/react/src/theme/stitches.config.ts +++ b/packages/react/src/theme/stitches.config.ts @@ -35,6 +35,7 @@ export const keyframes = stitches.keyframes; export const getCssText = stitches.getCssText; export const theme = stitches.theme; export const config = stitches.config; +export const baseTheme = commonTheme; export const createTheme = ({ type, theme, className }: Theme) => { if (!type) { @@ -46,6 +47,24 @@ export const createTheme = ({ type, theme, className }: Theme) => { ); }; +// stitches types export type VariantProps = Stitches.VariantProps; +export type PropertyValue = + Stitches.PropertyValue; +export type CSSProperties = Stitches.CSSProperties; export type CSS = Stitches.CSS; export type StitchesTheme = typeof theme; + +// common theme types +export type Spaces = typeof commonTheme.theme['space']; +export type FontSizes = typeof commonTheme.theme['fontSizes']; +export type Fonts = typeof commonTheme.theme['fonts']; +export type FontWeights = typeof commonTheme.theme['fontWeights']; +export type LineHeights = typeof commonTheme.theme['lineHeights']; +export type LetterSpacings = typeof commonTheme.theme['letterSpacings']; +export type Colors = typeof commonTheme.theme['colors']; +export type Radii = typeof commonTheme.theme['radii']; +export type zIndices = typeof commonTheme.theme['zIndices']; +export type BorderWeights = typeof commonTheme.theme['borderWeights']; +export type Tranistions = typeof commonTheme.theme['transitions']; +export type Breakpoints = typeof commonTheme.theme['breakpoints']; From fd7fd0c4c998a0aed62a0072ec7a506cc99e65fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=90=E1=85=A2=E1=84=8C=E1=85=A2=E1=84=8B=E1=85=A7?= =?UTF-8?q?=E1=86=BC?= Date: Sun, 19 Jun 2022 14:19:57 +0900 Subject: [PATCH 003/106] fix: variants -> css selector --- packages/react/src/switch/switch.styles.ts | 78 ++++++++++++---------- packages/react/src/switch/switch.tsx | 1 + 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/packages/react/src/switch/switch.styles.ts b/packages/react/src/switch/switch.styles.ts index 458a3fdc22..ff59031807 100644 --- a/packages/react/src/switch/switch.styles.ts +++ b/packages/react/src/switch/switch.styles.ts @@ -119,8 +119,6 @@ export const StyledSwitchContainer = styled('label', { } }); -export const StyledSwitchInput = styled('input', {}, sharedVisuallyHidden); - export const StyledSwitchCircle = styled('span', { position: 'absolute', display: 'flex', @@ -129,7 +127,6 @@ export const StyledSwitchCircle = styled('span', { ai: 'center', top: 'calc(50% - $$switchHeight * 0.35)', left: '0', - transform: 'translateX(calc($$switchWidth / 15))', transition: 'transform 0.25s ease, width 0.2s ease', bg: '$background', br: '$pill', @@ -161,10 +158,6 @@ export const StyledSwitch = styled( checked: { true: { bg: '$$switchColor', - [`& ${StyledSwitchCircle}`]: { - transform: - 'translateX(calc($$switchWidth - $$switchWidth / 15 - 100%))' - }, '&:hover:not(&:active)': { bg: '$$switchColorHover' } @@ -178,8 +171,6 @@ export const StyledSwitch = styled( borderColor: '$$switchColor' }, [`& ${StyledSwitchCircle}`]: { - transform: - 'translateX(calc(($$switchWidth / 15) - ($$switchBorderW / 2)))', bg: '$accents2' } } @@ -243,31 +234,6 @@ export const StyledSwitch = styled( normalShadowVar: '$$switchColorShadow' } }, - // animated && !checked - { - animated: true, - checked: false, - css: { - '&:active': { - [`& ${StyledSwitchCircle}`]: { - transform: 'translateX(calc($$switchWidth / 7.5))' - } - } - } - }, - // animated && checked - { - animated: true, - checked: true, - css: { - '&:active': { - [`& ${StyledSwitchCircle}`]: { - transform: - 'translateX(calc($$switchWidth - $$switchWidth / 7.5 - 100%))' - } - } - } - }, // checked && bordered { checked: true, @@ -279,7 +245,6 @@ export const StyledSwitch = styled( borderColor: 'transparent' }, [`& ${StyledSwitchCircle}`]: { - left: 'calc(100% - ($$switchWidth / 15) - $$switchHeight * 0.7 + ($$switchBorderW / 2))', bg: '$background' } } @@ -289,6 +254,49 @@ export const StyledSwitch = styled( sharedFocus ); +export const StyledSwitchInput = styled( + 'input', + { + [`& + ${StyledSwitch} > ${StyledSwitchCircle}`]: { + transform: 'translateX(calc($$switchWidth / 15))' + }, + [`&:checked + ${StyledSwitch} > ${StyledSwitchCircle}`]: { + transform: + 'translateX(calc($$switchWidth - $$switchWidth / 15 - $$switchHeight * 0.7))' + }, + [`& + ${StyledSwitch}:active > ${StyledSwitchCircle}`]: { + transform: 'translateX(calc($$switchWidth / 7.5))' + }, + [`&:checked + ${StyledSwitch}:active > ${StyledSwitchCircle}`]: { + transform: + 'translateX(calc($$switchWidth - $$switchWidth / 7.5 - $$switchWidth / 10 - $$switchHeight * 0.7))' + }, + variants: { + bordered: { + true: { + [`& + ${StyledSwitch} > ${StyledSwitchCircle}`]: { + transform: + 'translateX(calc($$switchWidth / 15 - $$switchBorderW / 2))' + }, + [`&:checked + ${StyledSwitch} > ${StyledSwitchCircle}`]: { + transform: + 'translateX(calc($$switchWidth - $$switchWidth / 15 - $$switchBorderW * 1.5 - $$switchHeight * 0.7))' + }, + [`& + ${StyledSwitch}:active > ${StyledSwitchCircle}`]: { + transform: + 'translateX(calc($$switchWidth / 7.5 - $$switchBorderW / 2))' + }, + [`&:checked + ${StyledSwitch}:active > ${StyledSwitchCircle}`]: { + transform: + 'translateX(calc($$switchWidth - $$switchWidth / 7.5 - $$switchWidth / 10 - $$switchBorderW * 1.5 - $$switchHeight * 0.7))' + } + } + } + } + }, + sharedVisuallyHidden +); + // types export type SwitchVariantsProps = VariantProps; export type SwitchContainerVariantsProps = VariantProps< diff --git a/packages/react/src/switch/switch.tsx b/packages/react/src/switch/switch.tsx index 1209a77776..e69188f460 100644 --- a/packages/react/src/switch/switch.tsx +++ b/packages/react/src/switch/switch.tsx @@ -140,6 +140,7 @@ const Switch: React.FC = ({ className={clsx(`${preClass}-input`)} data-state={getState} disabled={disabled} + bordered={bordered} checked={selfChecked} onChange={changeHandle} /> From aaf7cbd2294e566a8b180d9eda561b7f0533be72 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sun, 19 Jun 2022 12:38:08 -0300 Subject: [PATCH 004/106] refactor(root): eslint config and files changed --- .eslintignore | 1 + .eslintrc.json | 108 +-- .prettierrc | 12 +- package.json | 6 +- packages/react/package.json | 1 - .../react/src/avatar/__tests__/group.test.tsx | 51 +- .../react/src/avatar/__tests__/index.test.tsx | 58 +- .../react/src/avatar/avatar-group.styles.ts | 55 +- packages/react/src/avatar/avatar-group.tsx | 28 +- packages/react/src/avatar/avatar.stories.tsx | 172 ++-- packages/react/src/avatar/avatar.styles.ts | 384 ++++---- packages/react/src/avatar/avatar.tsx | 168 ++-- packages/react/src/avatar/index.ts | 14 +- .../react/src/backdrop/backdrop.styles.ts | 185 ++-- packages/react/src/backdrop/backdrop.tsx | 88 +- packages/react/src/backdrop/index.ts | 12 +- .../react/src/button/__tests__/group.test.tsx | 46 +- .../react/src/button/__tests__/icon.test.tsx | 20 +- .../react/src/button/__tests__/index.test.tsx | 80 +- .../react/src/button/button-group-context.ts | 8 +- .../react/src/button/button-group.stories.tsx | 32 +- .../react/src/button/button-group.styles.ts | 124 ++- packages/react/src/button/button-group.tsx | 50 +- packages/react/src/button/button-icon.tsx | 101 +- packages/react/src/button/button.stories.tsx | 105 +- packages/react/src/button/button.styles.ts | 875 +++++++++-------- packages/react/src/button/button.tsx | 156 ++- packages/react/src/button/index.ts | 20 +- packages/react/src/button/utils.tsx | 55 +- .../react/src/card/__tests__/footer.test.tsx | 22 +- .../react/src/card/__tests__/index.test.tsx | 39 +- packages/react/src/card/card.stories.tsx | 475 ++++----- packages/react/src/card/card.styles.ts | 188 ++-- packages/react/src/card/card.tsx | 55 +- packages/react/src/card/index.ts | 22 +- packages/react/src/card/use-card.ts | 63 +- .../src/checkbox/__tests__/group.test.tsx | 67 +- .../src/checkbox/__tests__/index.test.tsx | 76 +- .../react/src/checkbox/checkbox-context.ts | 9 +- .../react/src/checkbox/checkbox-group.tsx | 51 +- .../react/src/checkbox/checkbox.stories.tsx | 159 ++- .../react/src/checkbox/checkbox.styles.ts | 749 +++++++-------- packages/react/src/checkbox/checkbox.tsx | 104 +- packages/react/src/checkbox/index.ts | 16 +- .../react/src/checkbox/use-checkbox-group.ts | 41 +- packages/react/src/checkbox/use-checkbox.ts | 63 +- .../react/src/code/__tests__/index.test.tsx | 31 +- packages/react/src/code/code.styles.ts | 10 +- packages/react/src/code/code.tsx | 23 +- packages/react/src/code/index.ts | 8 +- .../react/src/col/__tests__/index.test.tsx | 35 +- packages/react/src/col/col.styles.ts | 12 +- packages/react/src/col/col.tsx | 21 +- packages/react/src/col/index.ts | 8 +- .../src/collapse/__tests__/group.test.tsx | 92 +- .../src/collapse/__tests__/index.test.tsx | 136 ++- .../react/src/collapse/collapse-context.ts | 7 +- .../react/src/collapse/collapse-group.tsx | 43 +- packages/react/src/collapse/collapse-icon.tsx | 27 +- .../react/src/collapse/collapse.stories.tsx | 404 ++++---- .../react/src/collapse/collapse.styles.ts | 277 +++--- packages/react/src/collapse/collapse.tsx | 131 ++- packages/react/src/collapse/index.ts | 16 +- .../react/src/container/container.styles.ts | 44 +- packages/react/src/container/container.tsx | 44 +- packages/react/src/container/index.ts | 8 +- .../react/src/css-baseline/css-baseline.tsx | 351 +++---- packages/react/src/css-baseline/index.ts | 2 +- .../src/divider/__tests__/index.test.tsx | 32 +- packages/react/src/divider/divider.styles.ts | 78 +- packages/react/src/divider/divider.tsx | 45 +- packages/react/src/divider/index.ts | 11 +- .../src/dropdown/__tests__/index.test.tsx | 146 +-- .../src/dropdown/base/dropdown-item-base.tsx | 15 +- .../react/src/dropdown/dropdown-button.tsx | 46 +- .../react/src/dropdown/dropdown-context.tsx | 16 +- packages/react/src/dropdown/dropdown-icon.tsx | 21 +- packages/react/src/dropdown/dropdown-item.tsx | 197 ++-- packages/react/src/dropdown/dropdown-menu.tsx | 73 +- .../react/src/dropdown/dropdown-section.tsx | 71 +- .../react/src/dropdown/dropdown-trigger.tsx | 31 +- packages/react/src/dropdown/dropdown-types.ts | 21 +- .../react/src/dropdown/dropdown.stories.tsx | 200 ++-- .../react/src/dropdown/dropdown.styles.ts | 458 +++++---- packages/react/src/dropdown/dropdown.tsx | 36 +- packages/react/src/dropdown/index.ts | 31 +- packages/react/src/dropdown/use-dropdown.ts | 36 +- .../react/src/grid/__tests__/index.test.tsx | 67 +- packages/react/src/grid/grid-container.tsx | 91 +- packages/react/src/grid/grid-item.tsx | 109 +-- packages/react/src/grid/grid.stories.tsx | 40 +- packages/react/src/grid/grid.styles.ts | 14 +- packages/react/src/grid/grid.tsx | 30 +- packages/react/src/grid/index.ts | 17 +- .../react/src/image/__tests__/index.test.tsx | 85 +- packages/react/src/image/image.skeleton.tsx | 35 +- packages/react/src/image/image.stories.tsx | 61 +- packages/react/src/image/image.styles.ts | 64 +- packages/react/src/image/image.tsx | 267 +++-- packages/react/src/image/index.ts | 14 +- packages/react/src/index.ts | 192 ++-- .../react/src/input/__tests__/index.test.tsx | 143 +-- .../src/input/__tests__/password.test.tsx | 33 +- .../src/input/__tests__/use-input.test.tsx | 38 +- packages/react/src/input/index.ts | 21 +- packages/react/src/input/input-password.tsx | 41 +- packages/react/src/input/input-props.ts | 36 +- packages/react/src/input/input.stories.tsx | 216 ++--- packages/react/src/input/input.styles.ts | 909 +++++++++--------- packages/react/src/input/input.tsx | 255 +++-- packages/react/src/input/password-icon.tsx | 18 +- .../react/src/link/__tests__/index.test.tsx | 36 +- packages/react/src/link/icon.tsx | 19 +- packages/react/src/link/index.ts | 8 +- packages/react/src/link/link.stories.tsx | 42 +- packages/react/src/link/link.styles.ts | 146 +-- packages/react/src/link/link.tsx | 29 +- .../src/loading/__tests__/index.test.tsx | 58 +- packages/react/src/loading/index.ts | 16 +- .../react/src/loading/loading.stories.tsx | 38 +- packages/react/src/loading/loading.styles.ts | 548 ++++++----- packages/react/src/loading/loading.tsx | 42 +- packages/react/src/loading/spinner.tsx | 31 +- .../react/src/modal/__tests__/index.test.tsx | 94 +- .../src/modal/__tests__/use-modal.test.tsx | 30 +- packages/react/src/modal/index.ts | 24 +- packages/react/src/modal/modal-body.tsx | 32 +- .../react/src/modal/modal-close-button.tsx | 30 +- packages/react/src/modal/modal-context.ts | 5 +- packages/react/src/modal/modal-footer.tsx | 43 +- packages/react/src/modal/modal-header.tsx | 43 +- packages/react/src/modal/modal-wrapper.tsx | 78 +- packages/react/src/modal/modal.stories.tsx | 814 +++++++--------- packages/react/src/modal/modal.styles.ts | 268 +++--- packages/react/src/modal/modal.tsx | 80 +- packages/react/src/modal/use-modal.ts | 15 +- .../pagination/__tests__/pagination.test.tsx | 12 +- packages/react/src/pagination/index.ts | 16 +- .../src/pagination/pagination-ellipsis.tsx | 47 +- .../src/pagination/pagination-highlight.tsx | 52 +- .../react/src/pagination/pagination-icon.tsx | 30 +- .../react/src/pagination/pagination-item.tsx | 65 +- .../src/pagination/pagination.stories.tsx | 58 +- .../react/src/pagination/pagination.styles.ts | 409 ++++---- packages/react/src/pagination/pagination.tsx | 98 +- .../src/popover/__tests__/index.test.tsx | 68 +- packages/react/src/popover/index.ts | 12 +- .../react/src/popover/popover-content.tsx | 96 +- packages/react/src/popover/popover-context.ts | 16 +- .../react/src/popover/popover-trigger.tsx | 49 +- .../react/src/popover/popover.stories.tsx | 50 +- packages/react/src/popover/popover.styles.ts | 138 ++- packages/react/src/popover/popover.tsx | 51 +- packages/react/src/popover/use-popover.ts | 70 +- packages/react/src/popover/utils.ts | 93 +- .../src/progress/__tests__/index.test.tsx | 98 +- packages/react/src/progress/index.ts | 8 +- .../react/src/progress/progress.stories.tsx | 56 +- .../react/src/progress/progress.styles.ts | 164 ++-- packages/react/src/progress/progress.tsx | 78 +- .../react/src/radio/__tests__/index.test.tsx | 173 ++-- packages/react/src/radio/index.ts | 12 +- packages/react/src/radio/radio-context.ts | 18 +- packages/react/src/radio/radio-group.tsx | 48 +- packages/react/src/radio/radio.stories.tsx | 123 +-- packages/react/src/radio/radio.styles.ts | 343 ++++--- packages/react/src/radio/radio.tsx | 216 ++--- packages/react/src/radio/use-radio-group.ts | 33 +- packages/react/src/radio/use-radio.ts | 51 +- .../react/src/row/__tests__/index.test.tsx | 50 +- packages/react/src/row/index.ts | 8 +- packages/react/src/row/row.stories.tsx | 22 +- packages/react/src/row/row.styles.ts | 20 +- packages/react/src/row/row.tsx | 22 +- .../src/snippet/__tests__/index.test.tsx | 76 +- packages/react/src/snippet/index.ts | 10 +- packages/react/src/snippet/snippet-icon.tsx | 26 +- packages/react/src/snippet/snippet.styles.ts | 162 ++-- packages/react/src/snippet/snippet.tsx | 87 +- .../react/src/spacer/__tests__/index.test.tsx | 25 +- packages/react/src/spacer/index.ts | 8 +- packages/react/src/spacer/spacer.stories.tsx | 37 +- packages/react/src/spacer/spacer.styles.ts | 18 +- packages/react/src/spacer/spacer.tsx | 30 +- .../react/src/switch/__tests__/index.test.tsx | 115 +-- packages/react/src/switch/index.ts | 13 +- packages/react/src/switch/switch.stories.tsx | 54 +- packages/react/src/switch/switch.styles.ts | 334 ++++--- packages/react/src/switch/switch.tsx | 81 +- .../react/src/table/__tests__/index.test.tsx | 186 ++-- packages/react/src/table/base/index.ts | 10 +- packages/react/src/table/base/table-body.tsx | 9 +- packages/react/src/table/base/table-cell.tsx | 9 +- .../react/src/table/base/table-column.tsx | 14 +- .../react/src/table/base/table-header.tsx | 8 +- packages/react/src/table/base/table-row.tsx | 9 +- packages/react/src/table/index.ts | 40 +- packages/react/src/table/table-body.tsx | 114 +-- packages/react/src/table/table-cell.tsx | 50 +- .../react/src/table/table-checkbox-cell.tsx | 67 +- .../react/src/table/table-column-header.tsx | 111 +-- packages/react/src/table/table-context.tsx | 54 +- packages/react/src/table/table-footer.tsx | 27 +- packages/react/src/table/table-header-row.tsx | 79 +- packages/react/src/table/table-pagination.tsx | 40 +- packages/react/src/table/table-row-group.tsx | 29 +- packages/react/src/table/table-row.tsx | 56 +- .../src/table/table-select-all-checkbox.tsx | 71 +- packages/react/src/table/table-sort-icon.tsx | 38 +- packages/react/src/table/table.stories.tsx | 499 +++++----- packages/react/src/table/table.styles.ts | 605 ++++++------ packages/react/src/table/table.tsx | 142 ++- packages/react/src/table/utils.ts | 22 +- .../react/src/text/__tests__/index.test.tsx | 64 +- packages/react/src/text/child.tsx | 116 ++- packages/react/src/text/index.ts | 6 +- packages/react/src/text/text.stories.tsx | 33 +- packages/react/src/text/text.styles.ts | 28 +- packages/react/src/text/text.tsx | 168 ++-- .../src/textarea/__tests__/index.test.tsx | 72 +- packages/react/src/textarea/index.ts | 4 +- .../react/src/textarea/textarea.stories.tsx | 90 +- packages/react/src/textarea/textarea.tsx | 83 +- packages/react/src/textarea/utils.ts | 111 +-- packages/react/src/theme/colors/blue.ts | 40 +- packages/react/src/theme/colors/cyan.ts | 40 +- packages/react/src/theme/colors/gray.ts | 40 +- packages/react/src/theme/colors/green.ts | 40 +- packages/react/src/theme/colors/index.ts | 16 +- packages/react/src/theme/colors/pink.ts | 40 +- packages/react/src/theme/colors/purple.ts | 40 +- packages/react/src/theme/colors/red.ts | 40 +- packages/react/src/theme/colors/yellow.ts | 40 +- packages/react/src/theme/common.ts | 734 +++++++------- packages/react/src/theme/dark-theme.ts | 96 +- packages/react/src/theme/index.ts | 8 +- packages/react/src/theme/light-theme.ts | 40 +- packages/react/src/theme/shared-css.ts | 62 +- packages/react/src/theme/stitches.config.ts | 61 +- packages/react/src/theme/theme-context.ts | 9 +- packages/react/src/theme/theme-provider.tsx | 54 +- packages/react/src/theme/types.ts | 41 +- packages/react/src/theme/utils.ts | 121 ++- .../react/src/tooltip/__test__/index.test.tsx | 115 +-- packages/react/src/tooltip/index.ts | 15 +- packages/react/src/tooltip/placement.ts | 162 ++-- .../react/src/tooltip/tooltip-content.tsx | 114 +-- .../react/src/tooltip/tooltip.stories.tsx | 108 +-- packages/react/src/tooltip/tooltip.styles.ts | 188 ++-- packages/react/src/tooltip/tooltip.tsx | 62 +- .../__tests__/body-scroll.test.tsx | 137 +-- packages/react/src/use-body-scroll/index.ts | 4 +- .../src/use-body-scroll/use-body-scroll.ts | 31 +- .../react/src/use-click-anywhere/index.ts | 2 +- .../use-click-anywhere/use-click-anywhere.ts | 7 +- .../__tests__/click-away.test.tsx | 26 +- packages/react/src/use-click-away/index.ts | 2 +- .../src/use-click-away/use-click-away.ts | 10 +- .../__tests__/clipboard.test.tsx | 50 +- packages/react/src/use-clipboard/index.ts | 4 +- .../react/src/use-clipboard/use-clipboard.ts | 30 +- .../__tests__/current-state.test.tsx | 53 +- packages/react/src/use-current-state/index.ts | 2 +- .../use-current-state/use-current-state.ts | 29 +- packages/react/src/use-drip/index.ts | 2 +- packages/react/src/use-drip/use-drip.ts | 9 +- .../use-input/__tests__/use-input.test.tsx | 68 +- packages/react/src/use-input/index.ts | 2 +- packages/react/src/use-input/use-input.ts | 9 +- packages/react/src/use-keyboard/codes.ts | 4 +- packages/react/src/use-keyboard/helper.ts | 29 +- packages/react/src/use-keyboard/index.ts | 10 +- .../react/src/use-keyboard/use-keyboard.ts | 50 +- .../__tests__/use-pagination.test.tsx | 60 +- packages/react/src/use-pagination/index.ts | 35 +- packages/react/src/use-portal/index.ts | 2 +- packages/react/src/use-portal/use-portal.ts | 19 +- packages/react/src/use-real-shape/index.ts | 2 +- .../src/use-real-shape/use-real-shape.ts | 31 +- packages/react/src/use-resize/index.ts | 2 +- packages/react/src/use-resize/use-resize.ts | 13 +- packages/react/src/use-ssr/index.ts | 2 +- packages/react/src/use-ssr/use-ssr.ts | 9 +- packages/react/src/use-theme/index.ts | 2 +- packages/react/src/use-theme/use-theme.ts | 10 +- packages/react/src/use-warning/index.ts | 2 +- packages/react/src/use-warning/use-warning.ts | 9 +- .../react/src/user/__tests__/index.test.tsx | 43 +- packages/react/src/user/index.ts | 15 +- packages/react/src/user/user-link.tsx | 30 +- packages/react/src/user/user.stories.tsx | 19 +- packages/react/src/user/user.styles.ts | 78 +- packages/react/src/user/user.tsx | 184 ++-- packages/react/src/utils/animations.ts | 44 +- packages/react/src/utils/assertion.ts | 20 +- packages/react/src/utils/checkmark.tsx | 53 +- packages/react/src/utils/clear-icon.tsx | 32 +- packages/react/src/utils/clsx.ts | 16 +- packages/react/src/utils/collections.ts | 48 +- packages/react/src/utils/color.ts | 83 +- packages/react/src/utils/console.ts | 17 + packages/react/src/utils/context.ts | 15 +- packages/react/src/utils/css-transition.ts | 38 +- packages/react/src/utils/deep-merge.js | 8 +- packages/react/src/utils/dom.ts | 102 +- packages/react/src/utils/drip.tsx | 74 +- packages/react/src/utils/expand.tsx | 37 +- packages/react/src/utils/icons.tsx | 449 +++------ packages/react/src/utils/numbers.ts | 3 +- packages/react/src/utils/object.ts | 29 +- packages/react/src/utils/prop-types.ts | 303 +++--- packages/react/src/utils/react.ts | 7 +- packages/react/src/utils/refs.ts | 11 +- packages/react/src/utils/strings.ts | 4 +- packages/react/src/utils/with-defaults.ts | 8 +- tsconfig.json | 3 + yarn.lock | 75 +- 317 files changed, 12465 insertions(+), 13463 deletions(-) create mode 100644 packages/react/src/utils/console.ts create mode 100644 tsconfig.json diff --git a/.eslintignore b/.eslintignore index 547c236843..a81ee2c9b4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,3 +7,4 @@ public/* scripts/* tests/* *.config.js +.DS_Store diff --git a/.eslintrc.json b/.eslintrc.json index bf1a8b6dc9..3290ff3edc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,89 +1,79 @@ { - "plugins": ["prettier", "@typescript-eslint", "jsx-a11y"], - "extends": ["eslint:recommended", "plugin:react/recommended", "prettier", "plugin:jsx-a11y/recommended"], - "parser": "@typescript-eslint/parser", - "globals": { - "JSX": true - }, "env": { - "browser": true, - "amd": true, - "node": true, - "jest": true + "browser": false, + "es2021": true, + "node": true }, + "extends": [ + "plugin:react/recommended", + "plugin:prettier/recommended", + "plugin:react-hooks/recommended", + "plugin:jsx-a11y/recommended" + ], + "plugins": ["react", "prettier", "import", "@typescript-eslint", "jsx-a11y"], + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaFeatures": { "jsx": true - } + }, + "ecmaVersion": 12, + "sourceType": "module" }, "settings": { "react": { - "pragma": "React", "version": "detect" - }, - "import/resolver": { - "typescript": { - "alwaysTryTypes": true - } } }, "rules": { - "object-curly-spacing": ["warn", "always"], - "no-unused-vars": [ + "no-console": "warn", + "react/prop-types": "off", + "react/jsx-uses-react": "off", + "react/react-in-jsx-scope": "off", + "prettier/prettier": [ "warn", { - "vars": "all", - "args": "none" + "printWidth": 100, + "trailingComma": "all", + "tabWidth": 2, + "semi": true, + "singleQuote": false, + "bracketSpacing": false, + "arrowParens": "always", + "endOfLine":"auto" } ], - "jsx-a11y/no-static-element-interactions": ["warn"], - "jsx-a11y/click-events-have-key-events": ["warn"], "@typescript-eslint/no-unused-vars": [ "warn", { - "vars": "all", - "args": "none" + "args": "after-used", + "ignoreRestSiblings": false, + "argsIgnorePattern": "^_.*?$" } ], - "@typescript-eslint/no-explicit-any": [ + "import/order": ["warn", { + "groups": ["type", "builtin", "object", "external", "internal", "parent", "sibling", "index"], + "pathGroups": [{ + "pattern": "~/**", + "group": "external", + "position": "after" + }], + "newlines-between": "always" + }], + "react/self-closing-comp": "warn", + "react/jsx-sort-props": [ "warn", { - "ignoreRestArgs": true + "callbacksLast": true, + "shorthandFirst": true, + "noSortAlphabetically": false, + "reservedFirst": true } ], - "max-len": [ + "padding-line-between-statements": [ "warn", - { - "code": 80, - "ignoreStrings": true, - "ignoreTemplateLiterals": true, - "ignoreComments": true - } - ], - "no-plusplus": [ - "error", - { - "allowForLoopAfterthoughts": true - } - ], - "react/jsx-key": "error", - "react/jsx-props-no-spreading": "off", - "import/prefer-default-export": "off", - "react/jsx-boolean-value": "off", - "react/prop-types": "off", - "react/no-unescaped-entities": "off", - "react/jsx-one-expression-per-line": "off", - "react/jsx-wrap-multilines": "off", - "react/destructuring-assignment": "off", - "@typescript-eslint/comma-dangle": [ - "error", - { - "arrays": "only-multiline", - "objects": "only-multiline", - "imports": "only-multiline", - "exports": "only-multiline", - "functions": "never" - } + {"blankLine": "always", "prev": "*", "next": "return"}, + {"blankLine": "always", "prev": ["const", "let", "var"], "next": "*"}, + {"blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]} ] } } diff --git a/.prettierrc b/.prettierrc index c45da9d8e8..b33506fafc 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,10 @@ { - "printWidth": 80, - "singleQuote": true, - "trailingComma": "none", - "tabWidth": 2 + "printWidth": 100, + "trailingComma": "all", + "tabWidth": 2, + "semi": true, + "singleQuote": false, + "bracketSpacing": false, + "arrowParens": "always", + "endOfLine": "auto" } diff --git a/package.json b/package.json index e898a890a2..76c55787e8 100644 --- a/package.json +++ b/package.json @@ -65,12 +65,14 @@ "eslint-import-resolver-typescript": "^2.4.0", "eslint-loader": "^4.0.2", "eslint-plugin-flowtype": "^5.7.1", - "eslint-plugin-import": "^2.22.1", + "eslint-plugin-import": "^2.26.0", "eslint-plugin-jest": "^24.3.6", "eslint-plugin-jsx-a11y": "^6.4.1", + "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-promise": "^6.0.0", "eslint-plugin-react": "^7.23.2", - "eslint-plugin-react-hooks": "^4.2.0", + "eslint-plugin-react-hooks": "^4.6.0", "graceful-fs": "^4.2.6", "http-server": "^0.12.3", "lerna": "^4.0.0", diff --git a/packages/react/package.json b/packages/react/package.json index 331f649103..19e617ae4e 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -122,7 +122,6 @@ "cherry-pick": "^0.5.0", "css-mediaquery": "^0.1.2", "enzyme": "^3.11.0", - "eslint-plugin-import": "^2.23.4", "eslint-plugin-react": "^7.24.0", "execa": "^5.1.1", "fs-extra": "^10.0.0", diff --git a/packages/react/src/avatar/__tests__/group.test.tsx b/packages/react/src/avatar/__tests__/group.test.tsx index d1d1efb009..b659de02b6 100644 --- a/packages/react/src/avatar/__tests__/group.test.tsx +++ b/packages/react/src/avatar/__tests__/group.test.tsx @@ -1,63 +1,68 @@ -import React from 'react'; -import { mount, shallow } from 'enzyme'; -import { render } from '@testing-library/react'; -import Avatar from '../index'; +import React from "react"; +import {mount, shallow} from "enzyme"; +import {render} from "@testing-library/react"; -describe('AvatarGroup', () => { - it('should render correctly', () => { +import Avatar from "../index"; + +describe("AvatarGroup", () => { + it("should render correctly", () => { const pictureUsers = [ - 'https://i.pravatar.cc/300?u=a042581f4e29026705d', - 'https://i.pravatar.cc/300?u=a042581f4e29026706d', - 'https://i.pravatar.cc/300?u=a042581f4e29026707d', - 'https://i.pravatar.cc/300?u=a042581f4e29026709d', - 'https://i.pravatar.cc/300?u=a042581f4f29026709d' + "https://i.pravatar.cc/300?u=a042581f4e29026705d", + "https://i.pravatar.cc/300?u=a042581f4e29026706d", + "https://i.pravatar.cc/300?u=a042581f4e29026707d", + "https://i.pravatar.cc/300?u=a042581f4e29026709d", + "https://i.pravatar.cc/300?u=a042581f4f29026709d", ]; - const nameUsers = ['Junior', 'Jane', 'W', 'John']; + const nameUsers = ["Junior", "Jane", "W", "John"]; const wrapper = mount( {pictureUsers.map((url, index) => ( - + ))} - + , ); + expect(() => wrapper.unmount()).not.toThrow(); const rendered = render( {nameUsers.map((name, index) => ( - + ))} - + , ); + expect(rendered).toMatchSnapshot(); }); - it('group component should render all children', () => { + it("group component should render all children", () => { const group = render( - + , ); - const avatars = group.getAllByTestId('avatar-test'); + const avatars = group.getAllByTestId("avatar-test"); expect(avatars).toHaveLength(2); }); - it('should stacked when avatars are in a group', () => { + it("should stacked when avatars are in a group", () => { const group = render( - + , ); + expect(group).toMatchSnapshot(); }); - it('should show count in group', () => { + it("should show count in group", () => { const count = 20; const group = shallow(); - const text = group.find('.nextui-avatar-group-count').text(); + const text = group.find(".nextui-avatar-group-count").text(); + expect(text).toContain(count); }); }); diff --git a/packages/react/src/avatar/__tests__/index.test.tsx b/packages/react/src/avatar/__tests__/index.test.tsx index f6597b0c5c..001ebd8196 100644 --- a/packages/react/src/avatar/__tests__/index.test.tsx +++ b/packages/react/src/avatar/__tests__/index.test.tsx @@ -1,31 +1,34 @@ -import React from 'react'; -import { mount, render, shallow } from 'enzyme'; -import Avatar from '../index'; +import React from "react"; +import {mount, render, shallow} from "enzyme"; + +import Avatar from "../index"; interface IconProps { className?: string; } -const Icon: React.FC = ({ className = '' }) => ( - -); +const Icon: React.FC = ({className = ""}) => ; -describe('Avatar', () => { - it('should support square and circle', () => { +describe("Avatar", () => { + it("should support square and circle", () => { const circle = shallow(); + expect(() => circle.unmount()).not.toThrow(); const square = shallow(); + expect(() => square.unmount()).not.toThrow(); }); - it('should render text element', () => { + it("should render text element", () => { const imageAvatar = render(); + expect(imageAvatar).toMatchSnapshot(); const textAvatar = render(); + expect(textAvatar).toMatchSnapshot(); }); - it('should work with different colors', () => { + it("should work with different colors", () => { const wrapper = mount(
@@ -33,50 +36,57 @@ describe('Avatar', () => { -
+ , ); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should work with a gradient color', () => { + it("should work with a gradient color", () => { const wrapper = mount(); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should work with pointer', () => { + it("should work with pointer", () => { const wrapper = mount(); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should work with zoomed', () => { + it("should work with zoomed", () => { const wrapper = mount(); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should render correctly with an icon', () => { + it("should render correctly with an icon", () => { const wrapper = mount(} />); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should omit long chars automatically', () => { + it("should omit long chars automatically", () => { const avatar = mount(); - const text = avatar.find('.nextui-avatar-text').text(); + const text = avatar.find(".nextui-avatar-text").text(); + expect(text.length).toBeLessThan(4); }); - it('stacked should be work', () => { + it("stacked should be work", () => { const avatar = shallow( - + , ); + expect(() => avatar.unmount()).not.toThrow(); }); - it('should work correctly with different sizes', () => { + it("should work correctly with different sizes", () => { const wrapper = mount(
@@ -84,14 +94,16 @@ describe('Avatar', () => { -
+ , ); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should render component of a specified size', () => { - const avatar = render(); + it("should render component of a specified size", () => { + const avatar = render(); + expect(avatar).toMatchSnapshot(); }); }); diff --git a/packages/react/src/avatar/avatar-group.styles.ts b/packages/react/src/avatar/avatar-group.styles.ts index 3d1cd0c96e..aa295bd2b1 100644 --- a/packages/react/src/avatar/avatar-group.styles.ts +++ b/packages/react/src/avatar/avatar-group.styles.ts @@ -1,43 +1,44 @@ -import { styled, VariantProps } from '../theme/stitches.config'; -import Avatar from './avatar.styles'; +import {styled, VariantProps} from "../theme/stitches.config"; -export const StyledAvatarGroupCount = styled('span', { - fontSize: '$xs', - display: 'inline-flex', - alignItems: 'center', - marginLeft: '$3', - color: '$text' +import Avatar from "./avatar.styles"; + +export const StyledAvatarGroupCount = styled("span", { + fontSize: "$xs", + display: "inline-flex", + alignItems: "center", + marginLeft: "$3", + color: "$text", }); -export const StyledAvatarGroup = styled('div', { - dflex: 'center', - height: 'auto', - width: 'max-content', - '@motion': { - transition: 'none' +export const StyledAvatarGroup = styled("div", { + dflex: "center", + height: "auto", + width: "max-content", + "@motion": { + transition: "none", }, [`& ${Avatar}`]: { - marginLeft: '-$space$5', - transition: '$default', - '.only-text-avatar': { - boxShadow: '$xs' - } + marginLeft: "-$space$5", + transition: "$default", + ".only-text-avatar": { + boxShadow: "$xs", + }, }, - '.only-text-avatar': { - boxShadow: '$xs' + ".only-text-avatar": { + boxShadow: "$xs", }, variants: { animated: { true: { [`& ${Avatar}:hover`]: { - transform: 'translate(-$space$5)' - } - } - } + transform: "translate(-$space$5)", + }, + }, + }, }, defaultVariants: { - animated: true - } + animated: true, + }, }); export type AvatarGroupVariants = VariantProps; diff --git a/packages/react/src/avatar/avatar-group.tsx b/packages/react/src/avatar/avatar-group.tsx index 67fd019f01..c563b2fedc 100644 --- a/packages/react/src/avatar/avatar-group.tsx +++ b/packages/react/src/avatar/avatar-group.tsx @@ -1,12 +1,14 @@ -import React, { ReactNode } from 'react'; -import { CSS } from '../theme/stitches.config'; -import { ReactRef } from '../utils/refs'; -import { useDOMRef } from '../utils/dom'; -import { __DEV__ } from '../utils/assertion'; +import React, {ReactNode} from "react"; + +import {CSS} from "../theme/stitches.config"; +import {ReactRef} from "../utils/refs"; +import {useDOMRef} from "../utils/dom"; +import {__DEV__} from "../utils/assertion"; + import StyledAvatarGroup, { StyledAvatarGroupCount, - AvatarGroupVariants -} from './avatar-group.styles'; + AvatarGroupVariants, +} from "./avatar-group.styles"; interface Props { count?: number; @@ -16,13 +18,11 @@ interface Props { type NativeAttrs = Omit, keyof Props>; -export type AvatarGroupProps = Props & - NativeAttrs & - AvatarGroupVariants & { css?: CSS }; +export type AvatarGroupProps = Props & NativeAttrs & AvatarGroupVariants & {css?: CSS}; export const AvatarGroup = React.forwardRef( (props: AvatarGroupProps, ref: ReactRef) => { - const { count, children, ...otherProps } = props; + const {count, children, ...otherProps} = props; const domRef = useDOMRef(ref); @@ -36,13 +36,13 @@ export const AvatarGroup = React.forwardRef( )} ); - } + }, ); if (__DEV__) { - AvatarGroup.displayName = 'NextUI.AvatarGroup'; + AvatarGroup.displayName = "NextUI.AvatarGroup"; } -AvatarGroup.toString = () => '.nextui-avatar-group'; +AvatarGroup.toString = () => ".nextui-avatar-group"; export default AvatarGroup; diff --git a/packages/react/src/avatar/avatar.stories.tsx b/packages/react/src/avatar/avatar.stories.tsx index aad1c67773..433efe2324 100644 --- a/packages/react/src/avatar/avatar.stories.tsx +++ b/packages/react/src/avatar/avatar.stories.tsx @@ -1,32 +1,34 @@ -import React from 'react'; -import { Meta } from '@storybook/react'; -import Avatar from './index'; -import Spacer from '../spacer'; -import { Lock, User, VolumeUp, Camera, Activity } from '../utils/icons'; +import React from "react"; +import {Meta} from "@storybook/react"; + +import Spacer from "../spacer"; +import {Lock, User, VolumeUp, Camera, Activity} from "../utils/icons"; + +import Avatar from "./index"; export default { - title: 'Display/Avatar', - component: Avatar + title: "Display/Avatar", + component: Avatar, } as Meta; -const nameUsers = ['Junior', 'Jane', 'W', 'John', 'JR']; +const nameUsers = ["Junior", "Jane", "W", "John", "JR"]; const pictureUsers = [ - 'https://i.pravatar.cc/300?u=a042581f4e29026705d', - 'https://i.pravatar.cc/300?u=a042581f4e29026706d', - 'https://i.pravatar.cc/300?u=a042581f4e29026707d', - 'https://i.pravatar.cc/300?u=a042581f4e29026709d', - 'https://i.pravatar.cc/300?u=a042581f4f29026709d' + "https://i.pravatar.cc/300?u=a042581f4e29026705d", + "https://i.pravatar.cc/300?u=a042581f4e29026706d", + "https://i.pravatar.cc/300?u=a042581f4e29026707d", + "https://i.pravatar.cc/300?u=a042581f4e29026709d", + "https://i.pravatar.cc/300?u=a042581f4f29026709d", ]; // eslint-disable-next-line @typescript-eslint/no-explicit-any -const Container = ({ children }: any) => ( +const Container = ({children}: any) => (
{children} @@ -41,9 +43,9 @@ export const Default = () => { - - - + + + ); }; @@ -52,27 +54,27 @@ export const Colors = () => { return ( <> - - - - - - + + + + + + - - - - - - + + + + + + ); @@ -82,13 +84,7 @@ export const Bordered = () => { return ( {pictureUsers.map((url, index) => ( - 0} - bordered - pointer - src={url} - /> + 0} src={url} /> ))} ); @@ -97,48 +93,12 @@ export const Bordered = () => { export const BorderWeights = () => { return ( - - - - - - + + + + + + ); }; @@ -147,25 +107,25 @@ export const Sizes = () => { return (
- - - - - + + + + + - - - - - + + + + +
); @@ -175,7 +135,7 @@ export const Zoomed = () => { return ( {pictureUsers.map((url, index) => ( - + ))} ); @@ -184,11 +144,11 @@ export const Zoomed = () => { export const Icons = () => { return ( - } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> ); }; @@ -198,13 +158,13 @@ export const Group = () => { {pictureUsers.map((url, index) => ( - + ))} {nameUsers.map((name, index) => ( - + ))} diff --git a/packages/react/src/avatar/avatar.styles.ts b/packages/react/src/avatar/avatar.styles.ts index ccbcd00b25..97b43a3dc0 100644 --- a/packages/react/src/avatar/avatar.styles.ts +++ b/packages/react/src/avatar/avatar.styles.ts @@ -1,314 +1,314 @@ -import { styled, VariantProps } from '../theme/stitches.config'; -import { cssFocusVisible, sharedDialogPopup } from '../theme/shared-css'; +import {styled, VariantProps} from "../theme/stitches.config"; +import {cssFocusVisible, sharedDialogPopup} from "../theme/shared-css"; export const StyledAvatar = styled( - 'span', + "span", { - dflex: 'center', - position: 'relative', - zIndex: '$1', - boxSizing: 'border-box', - overflow: 'hidden', - verticalAlign: 'top', - cursor: 'auto', - transition: 'transform 250ms ease 0ms, box-shadow 0.25s ease 0s', - '.nextui-avatar-bg': { - position: 'absolute', + dflex: "center", + position: "relative", + zIndex: "$1", + boxSizing: "border-box", + overflow: "hidden", + verticalAlign: "top", + cursor: "auto", + transition: "transform 250ms ease 0ms, box-shadow 0.25s ease 0s", + ".nextui-avatar-bg": { + position: "absolute", top: 0, left: 0, right: 0, bottom: 0, - zIndex: '$2', - transition: '$avatar', - size: '100%' + zIndex: "$2", + transition: "$avatar", + size: "100%", }, - '&:hover .nextui-avatar-bg': { - boxShadow: ' inset 0 0 40px 0 rgb(0 0 0 / 14%)' + "&:hover .nextui-avatar-bg": { + boxShadow: " inset 0 0 40px 0 rgb(0 0 0 / 14%)", }, - '.nextui-avatar-img': { + ".nextui-avatar-img": { opacity: 0, - zIndex: '$3', - display: 'flex', - bg: '$background', - transition: 'transform 250ms ease 0ms, opacity 200ms ease-in 0ms', - width: '100%', - height: '100%', - objectFit: 'cover' + zIndex: "$3", + display: "flex", + bg: "$background", + transition: "transform 250ms ease 0ms, opacity 200ms ease-in 0ms", + width: "100%", + height: "100%", + objectFit: "cover", }, '&[data-state="ready"] .nextui-avatar-img': { - opacity: 1 + opacity: 1, }, - '.nextui-avatar-icon': { - display: 'flex', - position: 'absolute', - left: '50%', - top: '50%', - ta: 'center', - zIndex: '$2', - transform: 'translate(-50%, -50%)', - whiteSpace: 'nowrap', - us: 'none' + ".nextui-avatar-icon": { + display: "flex", + position: "absolute", + left: "50%", + top: "50%", + ta: "center", + zIndex: "$2", + transform: "translate(-50%, -50%)", + whiteSpace: "nowrap", + us: "none", }, - '.nextui-avatar-text': { - position: 'absolute', - zIndex: '$2', - left: '50%', - top: '50%', - ta: 'center', - color: '$text', - fontWeight: '$medium', - transform: 'translate(-50%, -50%) scale(0.65)', - whiteSpace: 'nowrap', - us: 'none' + ".nextui-avatar-text": { + position: "absolute", + zIndex: "$2", + left: "50%", + top: "50%", + ta: "center", + color: "$text", + fontWeight: "$medium", + transform: "translate(-50%, -50%) scale(0.65)", + whiteSpace: "nowrap", + us: "none", }, - '@motion': { - transition: 'none', - '.nextui-avatar-bg, .nextui-avatar-img': { - transition: 'none' - } + "@motion": { + transition: "none", + ".nextui-avatar-bg, .nextui-avatar-img": { + transition: "none", + }, }, variants: { color: { default: { - '.nextui-avatar-bg': { - bg: '$accents2' - } + ".nextui-avatar-bg": { + bg: "$accents2", + }, }, primary: { - '.nextui-avatar-bg': { - bg: '$primary' - } + ".nextui-avatar-bg": { + bg: "$primary", + }, }, secondary: { - '.nextui-avatar-bg': { - bg: '$secondary' - } + ".nextui-avatar-bg": { + bg: "$secondary", + }, }, success: { - '.nextui-avatar-bg': { - bg: '$success' - } + ".nextui-avatar-bg": { + bg: "$success", + }, }, warning: { - '.nextui-avatar-bg': { - bg: '$warning' - } + ".nextui-avatar-bg": { + bg: "$warning", + }, }, error: { - '.nextui-avatar-bg': { - bg: '$error' - } + ".nextui-avatar-bg": { + bg: "$error", + }, }, gradient: { - '.nextui-avatar-bg': { - bg: '$gradient' - } - } + ".nextui-avatar-bg": { + bg: "$gradient", + }, + }, }, textColor: { default: { - '.nextui-avatar-text': { - color: '$text' - } + ".nextui-avatar-text": { + color: "$text", + }, }, white: { - '.nextui-avatar-text': { - color: '$white' - } + ".nextui-avatar-text": { + color: "$white", + }, }, primary: { - '.nextui-avatar-text': { - color: '$primary' - } + ".nextui-avatar-text": { + color: "$primary", + }, }, secondary: { - '.nextui-avatar-text': { - color: '$secondary' - } + ".nextui-avatar-text": { + color: "$secondary", + }, }, success: { - '.nextui-avatar-text': { - color: '$success' - } + ".nextui-avatar-text": { + color: "$success", + }, }, warning: { - '.nextui-avatar-text': { - color: '$warning' - } + ".nextui-avatar-text": { + color: "$warning", + }, }, error: { - '.nextui-avatar-text': { - color: '$error' - } - } + ".nextui-avatar-text": { + color: "$error", + }, + }, }, size: { xs: { - $$avatarXs: '$space$9', - sizeMin: '$$avatarXs', - '.nextui-avatar-text': { - fontSize: '$sm' - } + $$avatarXs: "$space$9", + sizeMin: "$$avatarXs", + ".nextui-avatar-text": { + fontSize: "$sm", + }, }, sm: { - $$avatarSm: '$space$11', - sizeMin: '$$avatarSm', - '.nextui-avatar-text': { - fontSize: '$md' - } + $$avatarSm: "$space$11", + sizeMin: "$$avatarSm", + ".nextui-avatar-text": { + fontSize: "$md", + }, }, md: { - $$avatarMd: '$space$14', - sizeMin: '$$avatarMd', - '.nextui-avatar-text': { - fontSize: '$lg' - } + $$avatarMd: "$space$14", + sizeMin: "$$avatarMd", + ".nextui-avatar-text": { + fontSize: "$lg", + }, }, lg: { - $$avatarLg: '$space$16', - sizeMin: '$$avatarLg', - '.nextui-avatar-text': { - fontSize: '$xl' - } + $$avatarLg: "$space$16", + sizeMin: "$$avatarLg", + ".nextui-avatar-text": { + fontSize: "$xl", + }, }, xl: { - $$avatarXl: '$space$18', - sizeMin: '$$avatarXl', - '.nextui-avatar-text': { - fontSize: '$2xl' - } - } + $$avatarXl: "$space$18", + sizeMin: "$$avatarXl", + ".nextui-avatar-text": { + fontSize: "$2xl", + }, + }, }, borderWeight: { light: { - '.nextui-avatar-img': { - borderWidth: '$light' - } + ".nextui-avatar-img": { + borderWidth: "$light", + }, }, normal: { - '.nextui-avatar-img': { - borderWidth: '$normal' - } + ".nextui-avatar-img": { + borderWidth: "$normal", + }, }, bold: { - '.nextui-avatar-img': { - borderWidth: '$normal' - } + ".nextui-avatar-img": { + borderWidth: "$normal", + }, }, extrabold: { - '.nextui-avatar-img': { - borderWidth: '$normal' - } + ".nextui-avatar-img": { + borderWidth: "$normal", + }, }, black: { - '.nextui-avatar-img': { - borderWidth: '$normal' - } - } + ".nextui-avatar-img": { + borderWidth: "$normal", + }, + }, }, bordered: { true: { - '&:hover:not(.only-text-avatar) .nextui-avatar-bg': { - opacity: '0.6' + "&:hover:not(.only-text-avatar) .nextui-avatar-bg": { + opacity: "0.6", + }, + ".nextui-avatar-img": { + borderStyle: "solid", + borderColor: "$background", }, - '.nextui-avatar-img': { - borderStyle: 'solid', - borderColor: '$background' - } - } + }, }, stacked: { true: { - ml: '-$5' - } + ml: "-$5", + }, }, pointer: { true: { - cursor: 'pointer' - } + cursor: "pointer", + }, }, rounded: { true: { - borderRadius: '$rounded', - '.nextui-avatar-img': { - borderRadius: '$rounded' - } - } + borderRadius: "$rounded", + ".nextui-avatar-img": { + borderRadius: "$rounded", + }, + }, }, squared: { true: { - borderRadius: '$squared', - '.nextui-avatar-img': { - borderRadius: '$squared' - } - } + borderRadius: "$squared", + ".nextui-avatar-img": { + borderRadius: "$squared", + }, + }, }, zoomed: { true: { - '&:hover .nextui-avatar-img': { - transform: 'scale(1.125)' - } - } - } + "&:hover .nextui-avatar-img": { + transform: "scale(1.125)", + }, + }, + }, }, compoundVariants: [ // bordered / borderWeight { bordered: true, - borderWeight: 'light', + borderWeight: "light", css: { - padding: 'calc($1/2)' - } + padding: "calc($1/2)", + }, }, { bordered: true, - borderWeight: 'normal', + borderWeight: "normal", css: { - padding: '$1' - } + padding: "$1", + }, }, { bordered: true, - borderWeight: 'bold', + borderWeight: "bold", css: { - padding: 'calc($2/1.5)' - } + padding: "calc($2/1.5)", + }, }, { bordered: true, - borderWeight: 'extrabold', + borderWeight: "extrabold", css: { - padding: '$2' - } + padding: "$2", + }, }, { bordered: true, - borderWeight: 'black', + borderWeight: "black", css: { - padding: 'calc($3/1.5)' - } + padding: "calc($3/1.5)", + }, }, { rounded: true, squared: true, css: { - borderRadius: '$squared', - '.nextui-avatar-img': { - borderRadius: '$squared' - } - } - } + borderRadius: "$squared", + ".nextui-avatar-img": { + borderRadius: "$squared", + }, + }, + }, ], defaultVariants: { - size: 'md', + size: "md", rounded: true, - color: 'default', - textColor: 'default', - borderWeight: 'normal' - } + color: "default", + textColor: "default", + borderWeight: "normal", + }, }, cssFocusVisible, - sharedDialogPopup + sharedDialogPopup, ); export type AvatarVariantsProps = VariantProps; diff --git a/packages/react/src/avatar/avatar.tsx b/packages/react/src/avatar/avatar.tsx index 8d569bc1e1..cce3aec688 100644 --- a/packages/react/src/avatar/avatar.tsx +++ b/packages/react/src/avatar/avatar.tsx @@ -1,14 +1,17 @@ -import React, { useMemo, useState, useRef, useEffect } from 'react'; -import { useFocusRing } from '@react-aria/focus'; -import type { FocusRingAria } from '@react-aria/focus'; -import { mergeProps } from '@react-aria/utils'; -import AvatarGroup from './avatar-group'; -import { CSS } from '../theme/stitches.config'; -import { ReactRef } from '../utils/refs'; -import { useDOMRef } from '../utils/dom'; -import { __DEV__ } from '../utils/assertion'; -import StyledAvatar, { AvatarVariantsProps } from './avatar.styles'; -import clsx from '../utils/clsx'; +import type {FocusRingAria} from "@react-aria/focus"; + +import {useFocusRing} from "@react-aria/focus"; +import React, {useMemo, useState, useRef, useEffect} from "react"; +import {mergeProps} from "@react-aria/utils"; + +import {CSS} from "../theme/stitches.config"; +import {ReactRef} from "../utils/refs"; +import {useDOMRef} from "../utils/dom"; +import {__DEV__} from "../utils/assertion"; +import clsx from "../utils/clsx"; + +import StyledAvatar, {AvatarVariantsProps} from "./avatar.styles"; +import AvatarGroup from "./avatar-group"; interface Props { text?: string; @@ -21,12 +24,10 @@ interface Props { type NativeAttrs = Omit< Partial & React.HTMLAttributes>, - keyof Props | 'sizes' + keyof Props | "sizes" >; -export type AvatarProps = Props & - AvatarVariantsProps & - NativeAttrs & { css?: CSS }; +export type AvatarProps = Props & AvatarVariantsProps & NativeAttrs & {css?: CSS}; interface IFocusRingAria extends FocusRingAria { focusProps: Omit, keyof AvatarProps>; @@ -34,86 +35,83 @@ interface IFocusRingAria extends FocusRingAria { const safeText = (text: string): string => { if (text?.length <= 4) return text; + return text?.slice(0, 3); }; -export const Avatar = React.forwardRef( - (props: AvatarProps, ref: ReactRef) => { - const { as, src, css, text, icon, alt, className, ...otherProps } = props; - - const domRef = useDOMRef(ref); - - const showText = !src; - const [ready, setReady] = useState(false); - - const imgRef = useRef(null); - - const { isFocusVisible, focusProps }: IFocusRingAria = useFocusRing(); - - useEffect(() => { - imgRef?.current?.complete && setReady(true); - }, []); - - const getState = useMemo(() => { - return !ready && src ? 'loading' : 'ready'; - }, [src, ready]); - - return ( - - - {!showText && ( - {alt} setReady(true)} - /> - )} - {showText && !icon && text && ( - {safeText(text)} - )} - {icon && {icon}} - - ); - } -); +export const Avatar = React.forwardRef((props: AvatarProps, ref: ReactRef) => { + const {as, src, css, text, icon, alt, className, ...otherProps} = props; + + const domRef = useDOMRef(ref); + + const showText = !src; + const [ready, setReady] = useState(false); + + const imgRef = useRef(null); + + const {isFocusVisible, focusProps}: IFocusRingAria = useFocusRing(); + + useEffect(() => { + imgRef?.current?.complete && setReady(true); + }, []); + + const getState = useMemo(() => { + return !ready && src ? "loading" : "ready"; + }, [src, ready]); + + return ( + + + {!showText && ( + {alt} setReady(true)} + /> + )} + {showText && !icon && text && {safeText(text)}} + {icon && {icon}} + + ); +}); type AvatarComponent

= React.NamedExoticComponent

& { Group: typeof AvatarGroup; }; if (__DEV__) { - Avatar.displayName = 'NextUI.Avatar'; + Avatar.displayName = "NextUI.Avatar"; } -Avatar.toString = () => '.nextui-avatar'; +Avatar.toString = () => ".nextui-avatar"; export default Avatar as AvatarComponent; diff --git a/packages/react/src/avatar/index.ts b/packages/react/src/avatar/index.ts index ccd662a528..a80c21b534 100644 --- a/packages/react/src/avatar/index.ts +++ b/packages/react/src/avatar/index.ts @@ -1,12 +1,12 @@ -import Avatar from './avatar'; -import AvatarGroup from './avatar-group'; +import Avatar from "./avatar"; +import AvatarGroup from "./avatar-group"; -export type { AvatarProps } from './avatar'; -export type { AvatarGroupProps } from './avatar-group'; +export type {AvatarProps} from "./avatar"; +export type {AvatarGroupProps} from "./avatar-group"; -export { StyledAvatar } from './avatar.styles'; -export { StyledAvatarGroup } from './avatar-group.styles'; -export { StyledAvatarGroupCount } from './avatar-group.styles'; +export {StyledAvatar} from "./avatar.styles"; +export {StyledAvatarGroup} from "./avatar-group.styles"; +export {StyledAvatarGroupCount} from "./avatar-group.styles"; Avatar.Group = AvatarGroup; diff --git a/packages/react/src/backdrop/backdrop.styles.ts b/packages/react/src/backdrop/backdrop.styles.ts index 078144db63..9b1526cc94 100644 --- a/packages/react/src/backdrop/backdrop.styles.ts +++ b/packages/react/src/backdrop/backdrop.styles.ts @@ -1,151 +1,150 @@ -import { styled, keyframes, VariantProps } from '../theme/stitches.config'; +import {styled, keyframes, VariantProps} from "../theme/stitches.config"; const appearanceIn = keyframes({ - '0%': { - opacity: 0 + "0%": { + opacity: 0, }, - '60%': { - opacity: 0.75 + "60%": { + opacity: 0.75, + }, + "100%": { + opacity: 1, }, - '100%': { - opacity: 1 - } }); -export const StyledBackdropContent = styled('div', { - position: 'relative', - display: 'inline-block', - zIndex: '$max', - outline: 'none', - width: '100%', - margin: '$9 auto', - verticalAlign: 'middle', - '@sm': { - width: '90%', - maxWidth: '90%' +export const StyledBackdropContent = styled("div", { + position: "relative", + display: "inline-block", + zIndex: "$max", + outline: "none", + width: "100%", + margin: "$9 auto", + verticalAlign: "middle", + "@sm": { + width: "90%", + maxWidth: "90%", }, variants: { animated: { true: { - '&': { + "&": { animationName: appearanceIn, - animationDuration: '200ms', - animationTimingFunction: 'ease-in', - animationDirection: 'normal' - } + animationDuration: "200ms", + animationTimingFunction: "ease-in", + animationDirection: "normal", + }, }, false: { - transition: 'none' - } - } - } + transition: "none", + }, + }, + }, }); -export const StyledBackdropLayer = styled('div', { - position: 'fixed', +export const StyledBackdropLayer = styled("div", { + position: "fixed", top: 0, left: 0, right: 0, bottom: 0, - size: '100%', - pe: 'none', - zIndex: '$max', - '@motion': { - transition: 'none' + size: "100%", + pe: "none", + zIndex: "$max", + "@motion": { + transition: "none", }, variants: { blur: { true: { - bg: '$black', - opacity: '$$backdropOpacity', - transition: 'opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1)', - '@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none))': - { - opacity: 1, - transition: 'background 0.35s cubic-bezier(0.4, 0, 0.2, 1)', - backdropFilter: 'saturate(180%) blur(20px)', - bg: 'rgba(0, 0, 0, 0.1)' - } + bg: "$black", + opacity: "$$backdropOpacity", + transition: "opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1)", + "@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none))": { + opacity: 1, + transition: "background 0.35s cubic-bezier(0.4, 0, 0.2, 1)", + backdropFilter: "saturate(180%) blur(20px)", + bg: "rgba(0, 0, 0, 0.1)", + }, }, false: { - bg: '$black', - opacity: '$$backdropOpacity', - transition: 'opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1)' - } + bg: "$black", + opacity: "$$backdropOpacity", + transition: "opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1)", + }, }, animated: { false: { - transition: 'none' - } - } - } + transition: "none", + }, + }, + }, }); -export const StyledBackdrop = styled('div', { - position: 'fixed', +export const StyledBackdrop = styled("div", { + position: "fixed", top: 0, left: 0, right: 0, bottom: 0, - overflow: 'auto', - zIndex: '$max', - WebkitOverflowScrolling: 'touch', - boxSizing: 'border-box', - textAlign: 'center', - '&:before': { - content: '', - display: 'inline-block', + overflow: "auto", + zIndex: "$max", + WebkitOverflowScrolling: "touch", + boxSizing: "border-box", + textAlign: "center", + "&:before": { + content: "", + display: "inline-block", width: 0, - height: '100%', - verticalAlign: 'middle' + height: "100%", + verticalAlign: "middle", }, - '.nextui-backdrop-wrapper-enter .nextui-backdrop-layer-default': { - opacity: 0 + ".nextui-backdrop-wrapper-enter .nextui-backdrop-layer-default": { + opacity: 0, }, - '.nextui-backdrop-wrapper-enter-active .nextui-backdrop-layer-default': { - opacity: '$$backdropOpacity' + ".nextui-backdrop-wrapper-enter-active .nextui-backdrop-layer-default": { + opacity: "$$backdropOpacity", }, - '.nextui-backdrop-wrapper-leave .nextui-backdrop-layer-default': { - opacity: '$$backdropOpacity' + ".nextui-backdrop-wrapper-leave .nextui-backdrop-layer-default": { + opacity: "$$backdropOpacity", }, - '.nextui-backdrop-wrapper-leave-active .nextui-backdrop-layer-default': { - opacity: 0 + ".nextui-backdrop-wrapper-leave-active .nextui-backdrop-layer-default": { + opacity: 0, }, - '.nextui-backdrop-wrapper-enter .nextui-backdrop-layer-blur': { - bg: 'rgba(0, 0, 0, 0.1)' + ".nextui-backdrop-wrapper-enter .nextui-backdrop-layer-blur": { + bg: "rgba(0, 0, 0, 0.1)", }, - '.nextui-backdrop-wrapper-enter-active .nextui-backdrop-layer-blur': { - bg: 'rgba(0, 0, 0, 0.4)' + ".nextui-backdrop-wrapper-enter-active .nextui-backdrop-layer-blur": { + bg: "rgba(0, 0, 0, 0.4)", }, - '.nextui-backdrop-wrapper-leave .nextui-backdrop-layer-blur': { - bg: 'rgba(0, 0, 0, 0.4)' + ".nextui-backdrop-wrapper-leave .nextui-backdrop-layer-blur": { + bg: "rgba(0, 0, 0, 0.4)", }, - '.nextui-backdrop-wrapper-leave-active .nextui-backdrop-layer-blur': { - bg: 'rgba(0, 0, 0, 0.1)' + ".nextui-backdrop-wrapper-leave-active .nextui-backdrop-layer-blur": { + bg: "rgba(0, 0, 0, 0.1)", }, variants: { fullScreen: { true: { - display: 'inline-flex', - overflow: 'hidden', + display: "inline-flex", + overflow: "hidden", [`& ${StyledBackdropContent}`]: { - width: '100vw', - maxWidth: '100vw', - height: '100vh', - margin: 0 + width: "100vw", + maxWidth: "100vw", + height: "100vh", + margin: 0, }, [`& ${StyledBackdropLayer}`]: { - display: 'none' - } - } - } + display: "none", + }, + }, + }, }, defaultVariants: { - fullScreen: false - } + fullScreen: false, + }, }); export type BackdropVariantsProps = VariantProps; diff --git a/packages/react/src/backdrop/backdrop.tsx b/packages/react/src/backdrop/backdrop.tsx index b46fa19105..6b47796c39 100644 --- a/packages/react/src/backdrop/backdrop.tsx +++ b/packages/react/src/backdrop/backdrop.tsx @@ -1,18 +1,20 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import React, { MouseEvent, useCallback, useMemo } from 'react'; -import withDefaults from '../utils/with-defaults'; -import CSSTransition from '../utils/css-transition'; -import { CSS } from '../theme/stitches.config'; -import useCurrentState from '../use-current-state'; -import cslx from '../utils/clsx'; -import useKeyboard, { KeyCode } from '../use-keyboard'; +import React, {MouseEvent, useCallback, useMemo} from "react"; + +import withDefaults from "../utils/with-defaults"; +import CSSTransition from "../utils/css-transition"; +import {CSS} from "../theme/stitches.config"; +import useCurrentState from "../use-current-state"; +import cslx from "../utils/clsx"; +import useKeyboard, {KeyCode} from "../use-keyboard"; +import {__DEV__} from "../utils/assertion"; + import { StyledBackdrop, StyledBackdropLayer, StyledBackdropContent, - BackdropVariantsProps -} from './backdrop.styles'; -import { __DEV__ } from '../utils/assertion'; + BackdropVariantsProps, +} from "./backdrop.styles"; interface Props { onClick?: (event: MouseEvent) => void; @@ -35,17 +37,14 @@ const defaultProps = { animated: true, preventDefault: true, opacity: 0.5, - className: '' + className: "", }; type NativeAttrs = Omit, keyof Props>; -export type BackdropProps = Props & - typeof defaultProps & - NativeAttrs & - BackdropVariantsProps; +export type BackdropProps = Props & typeof defaultProps & NativeAttrs & BackdropVariantsProps; -const preClass = 'nextui-backdrop'; +const preClass = "nextui-backdrop"; const Backdrop: React.FC> = React.memo( ({ @@ -62,18 +61,14 @@ const Backdrop: React.FC> = React.memo( css, ...props }) => { - const [, setIsContentMouseDown, IsContentMouseDownRef] = - useCurrentState(false); + const [, setIsContentMouseDown, IsContentMouseDownRef] = useCurrentState(false); const clickHandler = (event: MouseEvent) => { if (IsContentMouseDownRef.current) return; onClick && onClick(event); }; - const childrenClickHandler = useCallback( - (event: MouseEvent) => { - event.stopPropagation(); - }, - [] - ); + const childrenClickHandler = useCallback((event: MouseEvent) => { + event.stopPropagation(); + }, []); const mouseUpHandler = () => { if (!IsContentMouseDownRef.current) return; const timer = setTimeout(() => { @@ -82,70 +77,71 @@ const Backdrop: React.FC> = React.memo( }, 0); }; - const { bindings } = useKeyboard( + const {bindings} = useKeyboard( (ev: React.KeyboardEvent | KeyboardEvent) => { onKeyPress && onKeyPress(ev); }, [KeyCode.Escape, KeyCode.Space], { disableGlobalEvent: true, - preventDefault - } + preventDefault, + }, ); const getState = useMemo(() => { - return visible ? 'open' : 'closed'; + return visible ? "open" : "closed"; }, [visible]); const renderChildren = useMemo(() => { return ( setIsContentMouseDown(true)} > {children} ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [children]); return ( <> {animated ? ( {renderChildren} @@ -154,13 +150,13 @@ const Backdrop: React.FC> = React.memo( ) : null} ); - } + }, ); if (__DEV__) { - Backdrop.displayName = 'NextUI.Backdrop'; + Backdrop.displayName = "NextUI.Backdrop"; } -Backdrop.toString = () => '.nextui-backdrop'; +Backdrop.toString = () => ".nextui-backdrop"; export default withDefaults(Backdrop, defaultProps); diff --git a/packages/react/src/backdrop/index.ts b/packages/react/src/backdrop/index.ts index 4ca8ee0f9c..d20e6b4ef2 100644 --- a/packages/react/src/backdrop/index.ts +++ b/packages/react/src/backdrop/index.ts @@ -1,11 +1,7 @@ -import Backdrop from './backdrop'; +import Backdrop from "./backdrop"; -export type { BackdropProps } from './backdrop'; -export { - StyledBackdropContent, - StyledBackdropLayer, - StyledBackdrop -} from './backdrop.styles'; -export type { BackdropVariantsProps } from './backdrop.styles'; +export type {BackdropProps} from "./backdrop"; +export {StyledBackdropContent, StyledBackdropLayer, StyledBackdrop} from "./backdrop.styles"; +export type {BackdropVariantsProps} from "./backdrop.styles"; export default Backdrop; diff --git a/packages/react/src/button/__tests__/group.test.tsx b/packages/react/src/button/__tests__/group.test.tsx index 845d3ee447..633f936055 100644 --- a/packages/react/src/button/__tests__/group.test.tsx +++ b/packages/react/src/button/__tests__/group.test.tsx @@ -1,57 +1,62 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import Button from '../index'; -import { nativeEvent } from '../../../tests/utils'; +import React from "react"; +import {mount} from "enzyme"; -describe('ButtonGroup', () => { - it('should render correctly', () => { +import Button from "../index"; +import {nativeEvent} from "../../../tests/utils"; + +describe("ButtonGroup", () => { + it("should render correctly", () => { const wrapper = mount( - + , ); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('props should be passed to each button', () => { + it("props should be passed to each button", () => { const wrapper = mount( - + - + , ); + expect(wrapper.html()).toMatchSnapshot(); - wrapper.setProps({ flat: true }); + wrapper.setProps({flat: true}); expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should ignore events when group disabled', () => { + it("should ignore events when group disabled", () => { const handler = jest.fn(); const wrapper = mount( - + , ); - wrapper.find('button').simulate('click', nativeEvent); + + wrapper.find("button").simulate("click", nativeEvent); expect(handler).toHaveBeenCalledTimes(1); - wrapper.setProps({ disabled: true }); - wrapper.find('button').simulate('click', nativeEvent); + wrapper.setProps({disabled: true}); + wrapper.find("button").simulate("click", nativeEvent); expect(handler).toHaveBeenCalledTimes(1); }); - it('buttons should be displayed vertically', () => { + it("buttons should be displayed vertically", () => { const wrapper = mount( - + , ); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should render different variants', () => { + it("should render different variants", () => { const wrapper = mount( @@ -69,8 +74,9 @@ describe('ButtonGroup', () => { - + , ); + expect(wrapper).toMatchSnapshot(); expect().toMatchSnapshot(); }); diff --git a/packages/react/src/button/__tests__/icon.test.tsx b/packages/react/src/button/__tests__/icon.test.tsx index f947550eef..4f77f53738 100644 --- a/packages/react/src/button/__tests__/icon.test.tsx +++ b/packages/react/src/button/__tests__/icon.test.tsx @@ -1,25 +1,29 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import Button from '../index'; +import React from "react"; +import {mount} from "enzyme"; + +import Button from "../index"; const Icon: React.FC = () => ; -describe('ButtonIcon', () => { - it('should render correctly', () => { +describe("ButtonIcon", () => { + it("should render correctly", () => { const wrapper = mount(); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should work with right', () => { + it("should work with right", () => { const wrapper = mount(); + expect(wrapper.html()).toMatchSnapshot(); expect(() => wrapper.unmount()).not.toThrow(); }); - it('should work without text', () => { + it("should work without text", () => { const wrapper = mount(); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should support all colors', () => { + it("should support all colors", () => { const wrapper = mount(

+
, ); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should support all sizes', () => { + it("should support all sizes", () => { const wrapper = mount(
+ , ); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should render different text', () => { + it("should render different text", () => { const wrapper = mount(); - expect(wrapper.text()).toContain('button'); + + expect(wrapper.text()).toContain("button"); wrapper.setProps({ - children: Hello + children: Hello, }); - expect(wrapper.text()).toContain('Hello'); + expect(wrapper.text()).toContain("Hello"); }); - it('should render empty button correctly', () => { + it("should render empty button correctly", () => { expect( @@ -70,51 +75,58 @@ describe('Button', () => { - + , ); + expect(wrapper).toMatchSnapshot(); expect().toMatchSnapshot(); }); - it('ref should be forwarded', () => { + it("ref should be forwarded", () => { const ref = React.createRef(); const wrapper = mount(); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should trigger callback function', () => { + it("should trigger callback function", () => { const WrapperButton = () => { - const [state, setState] = React.useState('state1'); - return ; + const [state, setState] = React.useState("state1"); + + return ; }; const wrapper = mount(); - expect(wrapper.text()).toContain('state1'); - wrapper.simulate('click'); - userEvent.click(wrapper.find('button').getDOMNode()); - expect(wrapper.text()).toContain('state2'); + expect(wrapper.text()).toContain("state1"); + + wrapper.simulate("click"); + userEvent.click(wrapper.find("button").getDOMNode()); + expect(wrapper.text()).toContain("state2"); }); - it('should ignore events when disabled', () => { + it("should ignore events when disabled", () => { const WrapperButton = () => { - const [state, setState] = React.useState('state1'); + const [state, setState] = React.useState("state1"); + return ( - ); }; const wrapper = mount(); - expect(wrapper.text()).toContain('state1'); - userEvent.click(wrapper.find('button').getDOMNode()); - expect(wrapper.text()).toContain('state1'); - expect(wrapper.text()).not.toContain('state2'); + expect(wrapper.text()).toContain("state1"); + + userEvent.click(wrapper.find("button").getDOMNode()); + expect(wrapper.text()).toContain("state1"); + expect(wrapper.text()).not.toContain("state2"); }); - it('should remove expired events', () => { + it("should remove expired events", () => { const wrapper = mount(); - userEvent.click(wrapper.find('button').getDOMNode()); + + userEvent.click(wrapper.find("button").getDOMNode()); expect(() => wrapper.unmount()).not.toThrow(); }); }); diff --git a/packages/react/src/button/button-group-context.ts b/packages/react/src/button/button-group-context.ts index 97d8b2a9e0..dce0071096 100644 --- a/packages/react/src/button/button-group-context.ts +++ b/packages/react/src/button/button-group-context.ts @@ -1,5 +1,6 @@ -import React from 'react'; -import { NormalSizes, NormalColors, NormalWeights } from '../utils/prop-types'; +import React from "react"; + +import {NormalSizes, NormalColors, NormalWeights} from "../utils/prop-types"; export interface ButtonGroupConfig { size?: NormalSizes; @@ -23,8 +24,7 @@ const defaultContext = { disabled: false, }; -export const ButtonGroupContext = - React.createContext(defaultContext); +export const ButtonGroupContext = React.createContext(defaultContext); export const useButtonGroupContext = (): ButtonGroupConfig => React.useContext(ButtonGroupContext); diff --git a/packages/react/src/button/button-group.stories.tsx b/packages/react/src/button/button-group.stories.tsx index f776bab6f1..7206134b47 100644 --- a/packages/react/src/button/button-group.stories.tsx +++ b/packages/react/src/button/button-group.stories.tsx @@ -1,18 +1,20 @@ -import React from 'react'; -import { Meta } from '@storybook/react'; -import Button from './index'; -import { Grid } from '../index'; +import React from "react"; +import {Meta} from "@storybook/react"; + +import {Grid} from "../index"; + +import Button from "./index"; export default { - title: 'General/ButtonGroup', + title: "General/ButtonGroup", component: Button, decorators: [ (Story) => ( - + - ) - ] + ), + ], } as Meta; export const Default = () => ( @@ -48,17 +50,17 @@ export const Variants = () => ( - + - + - + @@ -68,12 +70,12 @@ export const Variants = () => ( - + - + @@ -112,7 +114,7 @@ export const Sizes = () => ( export const Vertical = () => ( <> - + @@ -123,7 +125,7 @@ export const Vertical = () => ( export const Disabled = () => ( <> - + diff --git a/packages/react/src/button/button-group.styles.ts b/packages/react/src/button/button-group.styles.ts index 61bdbe6b6f..1bcd8a45f8 100644 --- a/packages/react/src/button/button-group.styles.ts +++ b/packages/react/src/button/button-group.styles.ts @@ -1,80 +1,81 @@ -import { styled, VariantProps } from '../theme/stitches.config'; -import StyledButton from './button.styles'; +import {styled, VariantProps} from "../theme/stitches.config"; -export const StyledButtonGroup = styled('div', { - display: 'inline-flex', - margin: '$3', - backgroundColor: 'transparent', - height: 'min-content', +import StyledButton from "./button.styles"; + +export const StyledButtonGroup = styled("div", { + display: "inline-flex", + margin: "$3", + backgroundColor: "transparent", + height: "min-content", [`& ${StyledButton}`]: { - '.nextui-button-text': { - top: 0 - } + ".nextui-button-text": { + top: 0, + }, }, variants: { vertical: { true: { - fd: 'column', + fd: "column", [`& ${StyledButton}`]: { - '&:not(:first-child)': { + "&:not(:first-child)": { btlr: 0, // top-left - btrr: 0 // top-right + btrr: 0, // top-right }, - '&:not(:last-child)': { + "&:not(:last-child)": { bblr: 0, - bbrr: 0 - } - } + bbrr: 0, + }, + }, }, false: { - fd: 'row', + fd: "row", [`& ${StyledButton}`]: { - '&:not(:first-child)': { + "&:not(:first-child)": { btlr: 0, // top-left - bblr: 0 // bottom-left + bblr: 0, // bottom-left }, - '&:not(:last-child)': { + "&:not(:last-child)": { btrr: 0, // top-right - bbrr: 0 // bottom-right - } - } - } + bbrr: 0, // bottom-right + }, + }, + }, }, size: { xs: { - br: '$xs' + br: "$xs", }, sm: { - br: '$sm' + br: "$sm", }, md: { - br: '$md' + br: "$md", }, lg: { - br: '$base' + br: "$base", }, xl: { - br: '$xl' - } + br: "$xl", + }, }, rounded: { true: { - br: '$pill' - } + br: "$pill", + }, }, bordered: { true: { - bg: 'transparent' - } + bg: "transparent", + }, }, gradient: { true: { - pl: 0 - } - } + pl: 0, + }, + }, }, defaultVariants: { - vertical: false + vertical: false, }, compoundVariants: [ // bordered / vertical:true @@ -83,12 +84,12 @@ export const StyledButtonGroup = styled('div', { vertical: true, css: { [`& ${StyledButton}`]: { - '&:not(:last-child)': { - borderBottom: 'none', - paddingBottom: '0' - } - } - } + "&:not(:last-child)": { + borderBottom: "none", + paddingBottom: "0", + }, + }, + }, }, // bordered / vertical:false { @@ -96,11 +97,11 @@ export const StyledButtonGroup = styled('div', { vertical: false, css: { [`& ${StyledButton}`]: { - '&:not(:first-child)': { - borderLeft: 'none' - } - } - } + "&:not(:first-child)": { + borderLeft: "none", + }, + }, + }, }, // bordered & vertical:false & gradient { @@ -109,21 +110,18 @@ export const StyledButtonGroup = styled('div', { gradient: true, css: { [`& ${StyledButton}`]: { - '&:not(:last-child)&:not(:first-child)': { - pl: 0 + "&:not(:last-child)&:not(:first-child)": { + pl: 0, + }, + "&:last-child": { + pl: 0, }, - '&:last-child': { - pl: 0 - } - } - } - } - ] + }, + }, + }, + ], }); -export type ButtonGroupVariantsProps = Omit< - VariantProps, - 'gradient' ->; +export type ButtonGroupVariantsProps = Omit, "gradient">; export default StyledButtonGroup; diff --git a/packages/react/src/button/button-group.tsx b/packages/react/src/button/button-group.tsx index eadca65e9d..f646e3b20e 100644 --- a/packages/react/src/button/button-group.tsx +++ b/packages/react/src/button/button-group.tsx @@ -1,11 +1,11 @@ -import React, { useMemo } from 'react'; -import withDefaults from '../utils/with-defaults'; -import { CSS } from '../theme/stitches.config'; -import { NormalSizes, NormalColors, NormalWeights } from '../utils/prop-types'; -import { ButtonGroupContext, ButtonGroupConfig } from './button-group-context'; -import StyledButtonGroup, { - ButtonGroupVariantsProps -} from './button-group.styles'; +import React, {useMemo} from "react"; + +import withDefaults from "../utils/with-defaults"; +import {CSS} from "../theme/stitches.config"; +import {NormalSizes, NormalColors, NormalWeights} from "../utils/prop-types"; + +import {ButtonGroupContext, ButtonGroupConfig} from "./button-group-context"; +import StyledButtonGroup, {ButtonGroupVariantsProps} from "./button-group.styles"; interface Props { disabled?: boolean; @@ -24,9 +24,9 @@ interface Props { } const defaultProps = { - borderWeight: 'normal' as NormalWeights | undefined, - size: 'md' as NormalSizes, - color: 'default' as NormalColors + borderWeight: "normal" as NormalWeights | undefined, + size: "md" as NormalSizes, + color: "default" as NormalColors, }; type NativeAttrs = Omit, keyof Props>; @@ -34,11 +34,9 @@ type NativeAttrs = Omit, keyof Props>; export type ButtonGroupProps = Props & ButtonGroupVariantsProps & NativeAttrs & - typeof defaultProps & { css?: CSS }; + typeof defaultProps & {css?: CSS}; -const ButtonGroup: React.FC> = ( - groupProps -) => { +const ButtonGroup: React.FC> = (groupProps) => { const { disabled, size, @@ -72,28 +70,18 @@ const ButtonGroup: React.FC> = ( animated, rounded, ripple, - isButtonGroup: true + isButtonGroup: true, }), - [ - disabled, - animated, - size, - ripple, - color, - bordered, - light, - ghost, - flat, - borderWeight - ] + // eslint-disable-next-line react-hooks/exhaustive-deps + [disabled, animated, size, ripple, color, bordered, light, ghost, flat, borderWeight], ); return ( {children} @@ -102,7 +90,7 @@ const ButtonGroup: React.FC> = ( ); }; -ButtonGroup.toString = () => '.nextui-button-group'; +ButtonGroup.toString = () => ".nextui-button-group"; const MemoButtonGroup = React.memo(ButtonGroup); diff --git a/packages/react/src/button/button-icon.tsx b/packages/react/src/button/button-icon.tsx index b0dc7aaf3b..2fffcf3166 100644 --- a/packages/react/src/button/button-icon.tsx +++ b/packages/react/src/button/button-icon.tsx @@ -1,7 +1,8 @@ -import React from 'react'; -import { styled, VariantProps, CSS } from '../theme/stitches.config'; -import withDefaults from '../utils/with-defaults'; -import clsx from '../utils/clsx'; +import React from "react"; + +import {styled, VariantProps, CSS} from "../theme/stitches.config"; +import withDefaults from "../utils/with-defaults"; +import clsx from "../utils/clsx"; interface Props { isRight?: boolean; @@ -10,44 +11,44 @@ interface Props { } const defaultProps = { - className: '' + className: "", }; -export const StyledButtonIcon = styled('span', { - dflex: 'center', - position: 'absolute', - left: '$$buttonPadding', - right: 'auto', - top: '50%', - transform: 'translateY(-50%)', - color: 'inherit', - zIndex: '$1', - '& svg': { - background: 'transparent' +export const StyledButtonIcon = styled("span", { + dflex: "center", + position: "absolute", + left: "$$buttonPadding", + right: "auto", + top: "50%", + transform: "translateY(-50%)", + color: "inherit", + zIndex: "$1", + "& svg": { + background: "transparent", }, variants: { isAuto: { true: { - position: 'relative', - transform: 'none', - top: '0%' - } + position: "relative", + transform: "none", + top: "0%", + }, }, isRight: { true: { - right: '$$buttonPadding', - left: 'auto' - } + right: "$$buttonPadding", + left: "auto", + }, }, isSingle: { true: { - position: 'static', - transform: 'none' - } + position: "static", + transform: "none", + }, }, isGradientButtonBorder: { - true: {} - } + true: {}, + }, }, compoundVariants: [ // isAuto && isRight @@ -57,10 +58,10 @@ export const StyledButtonIcon = styled('span', { isSingle: false, css: { order: 2, - ml: 'calc($$buttonPadding / 2)', - right: '0%', - left: '0%' - } + ml: "calc($$buttonPadding / 2)", + right: "0%", + left: "0%", + }, }, // isAuto && !isRight { @@ -69,26 +70,26 @@ export const StyledButtonIcon = styled('span', { isSingle: false, css: { order: 0, - mr: 'calc($$buttonPadding / 2)', - right: '0%', - left: '0%' - } + mr: "calc($$buttonPadding / 2)", + right: "0%", + left: "0%", + }, }, // isSingle && isRight { isSingle: true, isRight: false, css: { - ml: 0 - } + ml: 0, + }, }, // isSingle && !isRight { isSingle: true, isRight: true, css: { - mr: 0 - } + mr: 0, + }, }, // isSingle && !isRight && hasButttonBorder { @@ -96,10 +97,10 @@ export const StyledButtonIcon = styled('span', { isRight: false, isGradientButtonBorder: true, css: { - mr: 'calc($$buttonPadding / 2)' - } - } - ] + mr: "calc($$buttonPadding / 2)", + }, + }, + ], }); type ButtonIconVariants = VariantProps; @@ -119,15 +120,15 @@ const ButtonIcon: React.FC> = ({ return ( @@ -136,7 +137,7 @@ const ButtonIcon: React.FC> = ({ ); }; -ButtonIcon.toString = () => '.nextui-button-icon'; +ButtonIcon.toString = () => ".nextui-button-icon"; const MemoButtonIcon = React.memo(ButtonIcon); diff --git a/packages/react/src/button/button.stories.tsx b/packages/react/src/button/button.stories.tsx index d26a268a30..eeefed9d05 100644 --- a/packages/react/src/button/button.stories.tsx +++ b/packages/react/src/button/button.stories.tsx @@ -1,19 +1,21 @@ -import React from 'react'; -import { Meta } from '@storybook/react'; -import Button from './index'; -import { Spacer, Grid, Loading } from '../index'; -import { Lock, Notification, User, Camera, Activity } from '../utils/icons'; +import React from "react"; +import {Meta} from "@storybook/react"; + +import {Spacer, Grid, Loading} from "../index"; +import {Lock, Notification, User, Camera, Activity} from "../utils/icons"; + +import Button from "./index"; export default { - title: 'General/Button', + title: "General/Button", component: Button, decorators: [ (Story) => (
- ) - ] + ), + ], } as Meta; export const Default = () => ; @@ -47,28 +49,28 @@ export const Sizes = () => ( export const Loadings = () => ( - - - - - @@ -93,23 +95,23 @@ export const Colors = () => ( export const Ghost = () => ( <> - - - - - @@ -152,27 +154,27 @@ export const Shadow = () => ( export const Bordered = () => ( <> - - - - - - @@ -180,23 +182,23 @@ export const Bordered = () => ( export const Flat = () => ( <> - - - - - @@ -204,27 +206,27 @@ export const Flat = () => ( export const Rounded = () => ( <> - - - - - - @@ -234,23 +236,23 @@ export const Light = () => ( <> - - - - - @@ -265,28 +267,23 @@ export const Icons = () => { Right Icon - - - - - diff --git a/packages/react/src/button/button.styles.ts b/packages/react/src/button/button.styles.ts index 9dfe5acd11..e7966ea052 100644 --- a/packages/react/src/button/button.styles.ts +++ b/packages/react/src/button/button.styles.ts @@ -1,215 +1,215 @@ -import { styled, VariantProps } from '../theme/stitches.config'; -import { cssFocusVisible, sharedDialogPopup } from '../theme/shared-css'; -import { StyledDrip } from '../utils/drip'; +import {styled, VariantProps} from "../theme/stitches.config"; +import {cssFocusVisible, sharedDialogPopup} from "../theme/shared-css"; +import {StyledDrip} from "../utils/drip"; export const StyledButton = styled( - 'button', + "button", { - $$buttonBorderRadius: '$radii$md', + $$buttonBorderRadius: "$radii$md", $$buttonPressedScale: 0.97, - dflex: 'center', - appearance: 'none', - boxSizing: 'border-box', - fontWeight: '$medium', - us: 'none', - lineHeight: '$sm', - ta: 'center', - whiteSpace: 'nowrap', - transition: '$button', - position: 'relative', - overflow: 'hidden', - border: 'none', - cursor: 'pointer', - pe: 'auto', + dflex: "center", + appearance: "none", + boxSizing: "border-box", + fontWeight: "$medium", + us: "none", + lineHeight: "$sm", + ta: "center", + whiteSpace: "nowrap", + transition: "$button", + position: "relative", + overflow: "hidden", + border: "none", + cursor: "pointer", + pe: "auto", p: 0, - br: '$$buttonBorderRadius', - '@motion': { - transition: 'none' + br: "$$buttonBorderRadius", + "@motion": { + transition: "none", }, - '.nextui-button-text': { - dflex: 'center', - zIndex: '$2', - 'p, pre, div': { - margin: 0 - } + ".nextui-button-text": { + dflex: "center", + zIndex: "$2", + "p, pre, div": { + margin: 0, + }, }, [`& ${StyledDrip}`]: { - zIndex: '$1', - '.nextui-drip-filler': { + zIndex: "$1", + ".nextui-drip-filler": { opacity: 0.25, - fill: '$accents2' - } + fill: "$accents2", + }, }, variants: { bordered: { true: { - bg: 'transparent', - borderStyle: 'solid', - color: '$text' - } + bg: "transparent", + borderStyle: "solid", + color: "$text", + }, }, ghost: { - true: {} + true: {}, }, color: { default: { - bg: '$primary', - color: '$primarySolidContrast' + bg: "$primary", + color: "$primarySolidContrast", }, primary: { - bg: '$primary', - color: '$primarySolidContrast' + bg: "$primary", + color: "$primarySolidContrast", }, secondary: { - bg: '$secondary', - color: '$secondarySolidContrast' + bg: "$secondary", + color: "$secondarySolidContrast", }, success: { - bg: '$success', - color: '$successSolidContrast' + bg: "$success", + color: "$successSolidContrast", }, warning: { - bg: '$warning', - color: '$warningSolidContrast' + bg: "$warning", + color: "$warningSolidContrast", }, error: { - bg: '$error', - color: '$errorSolidContrast' + bg: "$error", + color: "$errorSolidContrast", }, gradient: { - bg: '$gradient', - color: '$primarySolidContrast' - } + bg: "$gradient", + color: "$primarySolidContrast", + }, }, size: { xs: { - $$buttonPadding: '$space$3', - $$buttonBorderRadius: '$radii$xs', - $$buttonHeight: '$space$10', - px: '$3', - height: '$$buttonHeight', - lh: '$space$10', - width: 'auto', - minWidth: '$20', - fontSize: '$xs' + $$buttonPadding: "$space$3", + $$buttonBorderRadius: "$radii$xs", + $$buttonHeight: "$space$10", + px: "$3", + height: "$$buttonHeight", + lh: "$space$10", + width: "auto", + minWidth: "$20", + fontSize: "$xs", }, sm: { - $$buttonPadding: '$space$5', - $$buttonBorderRadius: '$radii$sm', - $$buttonHeight: '$space$12', - px: '$5', - height: '$$buttonHeight', - lh: '$space$14', - width: 'auto', - minWidth: '$36', - fontSize: '$sm' + $$buttonPadding: "$space$5", + $$buttonBorderRadius: "$radii$sm", + $$buttonHeight: "$space$12", + px: "$5", + height: "$$buttonHeight", + lh: "$space$14", + width: "auto", + minWidth: "$36", + fontSize: "$sm", }, md: { - $$buttonPadding: '$space$7', - $$buttonBorderRadius: '$radii$md', - $$buttonHeight: '$space$14', - px: '$7', - height: '$$buttonHeight', - lh: '$space$14', - width: 'auto', - minWidth: '$48', - fontSize: '$sm' + $$buttonPadding: "$space$7", + $$buttonBorderRadius: "$radii$md", + $$buttonHeight: "$space$14", + px: "$7", + height: "$$buttonHeight", + lh: "$space$14", + width: "auto", + minWidth: "$48", + fontSize: "$sm", }, lg: { - $$buttonPadding: '$space$9', - $$buttonBorderRadius: '$radii$base', - $$buttonHeight: '$space$16', - px: '$9', - height: '$$buttonHeight', - lh: '$space$15', - width: 'auto', - minWidth: '$60', - fontSize: '$md' + $$buttonPadding: "$space$9", + $$buttonBorderRadius: "$radii$base", + $$buttonHeight: "$space$16", + px: "$9", + height: "$$buttonHeight", + lh: "$space$15", + width: "auto", + minWidth: "$60", + fontSize: "$md", }, xl: { - $$buttonPadding: '$space$10', - $$buttonBorderRadius: '$radii$xl', - $$buttonHeight: '$space$18', - px: '$10', - height: '$$buttonHeight', - lh: '$space$17', - width: 'auto', - minWidth: '$72', - fontSize: '$lg' - } + $$buttonPadding: "$space$10", + $$buttonBorderRadius: "$radii$xl", + $$buttonHeight: "$space$18", + px: "$10", + height: "$$buttonHeight", + lh: "$space$17", + width: "auto", + minWidth: "$72", + fontSize: "$lg", + }, }, borderWeight: { light: { - bw: '$light', - $$buttonBorderWeight: '$borderWeights$light' + bw: "$light", + $$buttonBorderWeight: "$borderWeights$light", }, normal: { - bw: '$normal', - $$buttonBorderWeight: '$borderWeights$normal' + bw: "$normal", + $$buttonBorderWeight: "$borderWeights$normal", }, bold: { - bw: '$bold', - $$buttonBorderWeight: '$borderWeights$bold' + bw: "$bold", + $$buttonBorderWeight: "$borderWeights$bold", }, extrabold: { - bw: '$extrabold', - $$buttonBorderWeight: '$borderWeights$extrabold' + bw: "$extrabold", + $$buttonBorderWeight: "$borderWeights$extrabold", }, black: { - bw: '$black', - $$buttonBorderWeight: '$borderWeights$black' - } + bw: "$black", + $$buttonBorderWeight: "$borderWeights$black", + }, }, flat: { true: { - color: '$text' - } + color: "$text", + }, }, light: { true: { - bg: 'transparent', + bg: "transparent", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.8, - fill: '$accents2' - } - } - } + fill: "$accents2", + }, + }, + }, }, shadow: { true: { - bs: '$sm' - } + bs: "$sm", + }, }, animated: { false: { - transition: 'none' - } + transition: "none", + }, }, auto: { true: { - width: 'auto', - minWidth: 'min-content' - } + width: "auto", + minWidth: "min-content", + }, }, rounded: { true: { - $$buttonBorderRadius: '$radii$pill' - } + $$buttonBorderRadius: "$radii$pill", + }, }, isPressed: { - true: {} + true: {}, }, isHovered: { - true: {} + true: {}, }, isChildLess: { true: { p: 0, - width: '$$buttonHeight', - height: '$$buttonHeight' - } - } + width: "$$buttonHeight", + height: "$$buttonHeight", + }, + }, }, compoundVariants: [ // isPressed && animated @@ -217,610 +217,609 @@ export const StyledButton = styled( isPressed: true, animated: true, css: { - transform: 'scale($$buttonPressedScale)' - } + transform: "scale($$buttonPressedScale)", + }, }, // size / auto / isChildLess { auto: true, isChildLess: false, - size: 'xs', + size: "xs", css: { - px: '$5', - minWidth: 'min-content' - } + px: "$5", + minWidth: "min-content", + }, }, { auto: true, isChildLess: false, - size: 'sm', + size: "sm", css: { - px: '$8', - minWidth: 'min-content' - } + px: "$8", + minWidth: "min-content", + }, }, { auto: true, isChildLess: false, - size: 'md', + size: "md", css: { - px: '$9', - minWidth: 'min-content' - } + px: "$9", + minWidth: "min-content", + }, }, { auto: true, isChildLess: false, - size: 'lg', + size: "lg", css: { - px: '$10', - minWidth: 'min-content' - } + px: "$10", + minWidth: "min-content", + }, }, { auto: true, isChildLess: false, - size: 'xl', + size: "xl", css: { - px: '$11', - minWidth: 'min-content' - } + px: "$11", + minWidth: "min-content", + }, }, // shadow / color { shadow: true, - color: 'default', + color: "default", css: { - normalShadow: '$primaryShadow' - } + normalShadow: "$primaryShadow", + }, }, { shadow: true, - color: 'primary', + color: "primary", css: { - normalShadow: '$primaryShadow' - } + normalShadow: "$primaryShadow", + }, }, { shadow: true, - color: 'secondary', + color: "secondary", css: { - normalShadow: '$secondaryShadow' - } + normalShadow: "$secondaryShadow", + }, }, { shadow: true, - color: 'warning', + color: "warning", css: { - normalShadow: '$warningShadow' - } + normalShadow: "$warningShadow", + }, }, { shadow: true, - color: 'success', + color: "success", css: { - normalShadow: '$successShadow' - } + normalShadow: "$successShadow", + }, }, { shadow: true, - color: 'error', + color: "error", css: { - normalShadow: '$errorShadow' - } + normalShadow: "$errorShadow", + }, }, { shadow: true, - color: 'gradient', + color: "gradient", css: { - normalShadow: '$primaryShadow' - } + normalShadow: "$primaryShadow", + }, }, // light / color { light: true, - color: 'default', + color: "default", css: { - bg: 'transparent', - color: '$text', + bg: "transparent", + color: "$text", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.8, - fill: '$primaryLightActive' - } - } - } + fill: "$primaryLightActive", + }, + }, + }, }, { light: true, - color: 'primary', + color: "primary", css: { - bg: 'transparent', - color: '$primary', + bg: "transparent", + color: "$primary", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.8, - fill: '$primaryLightActive' - } - } - } + fill: "$primaryLightActive", + }, + }, + }, }, { light: true, - color: 'secondary', + color: "secondary", css: { - bg: 'transparent', - color: '$secondary', + bg: "transparent", + color: "$secondary", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.8, - fill: '$secondaryLightActive' - } - } - } + fill: "$secondaryLightActive", + }, + }, + }, }, { light: true, - color: 'warning', + color: "warning", css: { - bg: 'transparent', - color: '$warning', + bg: "transparent", + color: "$warning", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.8, - fill: '$warningLightActive' - } - } - } + fill: "$warningLightActive", + }, + }, + }, }, { light: true, - color: 'success', + color: "success", css: { - bg: 'transparent', - color: '$success', + bg: "transparent", + color: "$success", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.8, - fill: '$successLightActive' - } - } - } + fill: "$successLightActive", + }, + }, + }, }, { light: true, - color: 'error', + color: "error", css: { - bg: 'transparent', - color: '$error', + bg: "transparent", + color: "$error", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.8, - fill: '$errorLightActive' - } - } - } + fill: "$errorLightActive", + }, + }, + }, }, // bordered / color { bordered: true, - color: 'default', + color: "default", css: { - bg: 'transparent', - borderColor: '$primary', - color: '$primary', + bg: "transparent", + borderColor: "$primary", + color: "$primary", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { - fill: '$primary' - } - } - } + ".nextui-drip-filler": { + fill: "$primary", + }, + }, + }, }, { bordered: true, - color: 'primary', + color: "primary", css: { - bg: 'transparent', - borderColor: '$primary', - color: '$primary', + bg: "transparent", + borderColor: "$primary", + color: "$primary", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { - fill: '$primary' - } - } - } + ".nextui-drip-filler": { + fill: "$primary", + }, + }, + }, }, { bordered: true, - color: 'secondary', + color: "secondary", css: { - bg: 'transparent', - borderColor: '$secondary', - color: '$secondary', + bg: "transparent", + borderColor: "$secondary", + color: "$secondary", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { - fill: '$secondary' - } - } - } + ".nextui-drip-filler": { + fill: "$secondary", + }, + }, + }, }, { bordered: true, - color: 'success', + color: "success", css: { - bg: 'transparent', - borderColor: '$success', - color: '$success', + bg: "transparent", + borderColor: "$success", + color: "$success", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { - fill: '$success' - } - } - } + ".nextui-drip-filler": { + fill: "$success", + }, + }, + }, }, { bordered: true, - color: 'warning', + color: "warning", css: { - bg: 'transparent', - borderColor: '$warning', - color: '$warning', + bg: "transparent", + borderColor: "$warning", + color: "$warning", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { - fill: '$warning' - } - } - } + ".nextui-drip-filler": { + fill: "$warning", + }, + }, + }, }, { bordered: true, - color: 'error', + color: "error", css: { - bg: 'transparent', - borderColor: '$error', - color: '$error', + bg: "transparent", + borderColor: "$error", + color: "$error", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { - fill: '$error' - } - } - } + ".nextui-drip-filler": { + fill: "$error", + }, + }, + }, }, { bordered: true, - color: 'gradient', - css: { - bg: 'transparent', - color: '$text', - padding: '$$buttonBorderWeight', - bgClip: 'content-box, border-box', - borderColor: '$primary', - backgroundImage: - 'linear-gradient($background, $background), $gradient', - border: 'none', + color: "gradient", + css: { + bg: "transparent", + color: "$text", + padding: "$$buttonBorderWeight", + bgClip: "content-box, border-box", + borderColor: "$primary", + backgroundImage: "linear-gradient($background, $background), $gradient", + border: "none", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { - fill: '$secondary' - } - } - } + ".nextui-drip-filler": { + fill: "$secondary", + }, + }, + }, }, // ghost / color && isHovered { ghost: true, isHovered: true, - color: 'default', + color: "default", css: { - bg: '$primary', - color: '$primarySolidContrast' - } + bg: "$primary", + color: "$primarySolidContrast", + }, }, { ghost: true, isHovered: true, - color: 'primary', + color: "primary", css: { - bg: '$primary', - color: '$primarySolidContrast' - } + bg: "$primary", + color: "$primarySolidContrast", + }, }, { ghost: true, isHovered: true, - color: 'secondary', + color: "secondary", css: { - bg: '$secondary', - color: '$secondarySolidContrast' - } + bg: "$secondary", + color: "$secondarySolidContrast", + }, }, { ghost: true, isHovered: true, - color: 'success', + color: "success", css: { - bg: '$success', - color: '$successSolidContrast' - } + bg: "$success", + color: "$successSolidContrast", + }, }, { ghost: true, isHovered: true, - color: 'warning', + color: "warning", css: { - bg: '$warning', - color: '$warningSolidContrast' - } + bg: "$warning", + color: "$warningSolidContrast", + }, }, { ghost: true, isHovered: true, - color: 'error', + color: "error", css: { - bg: '$error', - color: '$errorSolidContrast' - } + bg: "$error", + color: "$errorSolidContrast", + }, }, { ghost: true, - color: 'gradient', + color: "gradient", isHovered: true, css: { - bg: '$gradient', - color: '$white' - } + bg: "$gradient", + color: "$white", + }, }, // flat / color { flat: true, - color: 'default', + color: "default", css: { - bg: '$primaryLight', - color: '$primaryLightContrast', + bg: "$primaryLight", + color: "$primaryLightContrast", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.4, - fill: '$primary' - } - } - } + fill: "$primary", + }, + }, + }, }, { flat: true, - color: 'primary', + color: "primary", css: { - bg: '$primaryLight', - color: '$primaryLightContrast', + bg: "$primaryLight", + color: "$primaryLightContrast", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.4, - fill: '$primary' - } - } - } + fill: "$primary", + }, + }, + }, }, { flat: true, - color: 'secondary', + color: "secondary", css: { - bg: '$secondaryLight', - color: '$secondaryLightContrast', + bg: "$secondaryLight", + color: "$secondaryLightContrast", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.4, - fill: '$secondary' - } - } - } + fill: "$secondary", + }, + }, + }, }, { flat: true, - color: 'success', + color: "success", css: { - bg: '$successLight', - color: '$successLightContrast', + bg: "$successLight", + color: "$successLightContrast", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.4, - fill: '$success' - } - } - } + fill: "$success", + }, + }, + }, }, { flat: true, - color: 'warning', + color: "warning", css: { - bg: '$warningLight', - color: '$warningLightContrast', + bg: "$warningLight", + color: "$warningLightContrast", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.4, - fill: '$warning' - } - } - } + fill: "$warning", + }, + }, + }, }, { flat: true, - color: 'error', + color: "error", css: { - bg: '$errorLight', - color: '$errorLightContrast', + bg: "$errorLight", + color: "$errorLightContrast", [`& ${StyledDrip}`]: { - '.nextui-drip-filler': { + ".nextui-drip-filler": { opacity: 0.4, - fill: '$error' - } - } - } + fill: "$error", + }, + }, + }, }, // flat / isHovered / color { flat: true, isHovered: true, - color: 'default', + color: "default", css: { - bg: '$primaryLightHover' - } + bg: "$primaryLightHover", + }, }, { flat: true, isHovered: true, - color: 'primary', + color: "primary", css: { - bg: '$primaryLightHover' - } + bg: "$primaryLightHover", + }, }, { flat: true, isHovered: true, - color: 'secondary', + color: "secondary", css: { - bg: '$secondaryLightHover' - } + bg: "$secondaryLightHover", + }, }, { flat: true, isHovered: true, - color: 'success', + color: "success", css: { - bg: '$successLightHover' - } + bg: "$successLightHover", + }, }, { flat: true, isHovered: true, - color: 'warning', + color: "warning", css: { - bg: '$warningLightHover' - } + bg: "$warningLightHover", + }, }, { flat: true, isHovered: true, - color: 'error', + color: "error", css: { - bg: '$errorLightHover' - } + bg: "$errorLightHover", + }, }, // flat / isPressed / color { flat: true, isPressed: true, - color: 'default', + color: "default", css: { - bg: '$primaryLightActive' - } + bg: "$primaryLightActive", + }, }, { flat: true, isPressed: true, - color: 'primary', + color: "primary", css: { - bg: '$primaryLightActive' - } + bg: "$primaryLightActive", + }, }, { flat: true, isPressed: true, - color: 'secondary', + color: "secondary", css: { - bg: '$secondaryLightActive' - } + bg: "$secondaryLightActive", + }, }, { flat: true, isPressed: true, - color: 'success', + color: "success", css: { - bg: '$successLightActive' - } + bg: "$successLightActive", + }, }, { flat: true, isPressed: true, - color: 'warning', + color: "warning", css: { - bg: '$warningLightActive' - } + bg: "$warningLightActive", + }, }, { flat: true, isPressed: true, - color: 'error', + color: "error", css: { - bg: '$errorLightActive' - } + bg: "$errorLightActive", + }, }, // auto / gradient-color / bordered { auto: true, - color: 'gradient', + color: "gradient", bordered: true, css: { - '.nextui-button-text': { - px: '$$buttonPadding' + ".nextui-button-text": { + px: "$$buttonPadding", + }, + ".nextui-button-icon": { + ml: "$$buttonPadding", }, - '.nextui-button-icon': { - ml: '$$buttonPadding' + ".nextui-button-icon-right": { + mr: "$$buttonPadding", }, - '.nextui-button-icon-right': { - mr: '$$buttonPadding' + ".nextui-button-text-left": { + pl: 0, }, - '.nextui-button-text-left': { - pl: 0 + ".nextui-button-text-right": { + pr: 0, }, - '.nextui-button-text-right': { - pr: 0 - } - } + }, }, // rounded && size { rounded: true, - size: 'xs', + size: "xs", css: { - br: '$pill' - } + br: "$pill", + }, }, { rounded: true, - size: 'sm', + size: "sm", css: { - br: '$pill' - } + br: "$pill", + }, }, { rounded: true, - size: 'md', + size: "md", css: { - br: '$pill' - } + br: "$pill", + }, }, { rounded: true, - size: 'lg', + size: "lg", css: { - br: '$pill' - } + br: "$pill", + }, }, { rounded: true, - size: 'xl', + size: "xl", css: { - br: '$pill' - } - } + br: "$pill", + }, + }, ], defaultVariants: { - color: 'default', - borderWeight: 'normal', + color: "default", + borderWeight: "normal", animated: true, - size: 'md' - } + size: "md", + }, }, cssFocusVisible, - sharedDialogPopup + sharedDialogPopup, ); export type ButtonVariantsProps = VariantProps; diff --git a/packages/react/src/button/button.tsx b/packages/react/src/button/button.tsx index 6477a75324..61cf41c372 100644 --- a/packages/react/src/button/button.tsx +++ b/packages/react/src/button/button.tsx @@ -1,29 +1,28 @@ -import React, { useMemo, PropsWithoutRef, RefAttributes } from 'react'; -import { useFocusRing } from '@react-aria/focus'; -import { useButton } from '@react-aria/button'; -import { useHover } from '@react-aria/interactions'; -import { mergeProps } from '@react-aria/utils'; -import type { - PressEvents, - PressEvent, - FocusableProps -} from '@react-types/shared'; -import type { AriaButtonProps } from '@react-types/button'; -import type { FocusRingAria } from '@react-aria/focus'; -import useWarning from '../use-warning'; -import ButtonDrip from '../utils/drip'; -import { CSS } from '../theme/stitches.config'; -import { NormalColors } from '../utils/prop-types'; -import { filterPropsWithGroup, getCssColors } from './utils'; -import { useButtonGroupContext } from './button-group-context'; -import ButtonGroup from './button-group'; -import ButtonIcon from './button-icon'; -import clsx from '../utils/clsx'; -import useDrip from '../use-drip'; -import StyledButton, { ButtonVariantsProps } from './button.styles'; -import withDefaults from '../utils/with-defaults'; -import { useDOMRef } from '../utils/dom'; -import { __DEV__ } from '../utils/assertion'; +import type {PressEvents, PressEvent, FocusableProps} from "@react-types/shared"; +import type {AriaButtonProps} from "@react-types/button"; +import type {FocusRingAria} from "@react-aria/focus"; + +import React, {useMemo, PropsWithoutRef, RefAttributes} from "react"; +import {useFocusRing} from "@react-aria/focus"; +import {useButton} from "@react-aria/button"; +import {useHover} from "@react-aria/interactions"; +import {mergeProps} from "@react-aria/utils"; + +import {warn} from "../utils/console"; +import ButtonDrip from "../utils/drip"; +import {CSS} from "../theme/stitches.config"; +import {NormalColors} from "../utils/prop-types"; +import clsx from "../utils/clsx"; +import useDrip from "../use-drip"; +import withDefaults from "../utils/with-defaults"; +import {useDOMRef} from "../utils/dom"; +import {__DEV__} from "../utils/assertion"; + +import {filterPropsWithGroup, getCssColors} from "./utils"; +import {useButtonGroupContext} from "./button-group-context"; +import ButtonGroup from "./button-group"; +import ButtonIcon from "./button-icon"; +import StyledButton, {ButtonVariantsProps} from "./button.styles"; export interface Props extends PressEvents, FocusableProps, AriaButtonProps { light?: boolean; @@ -54,8 +53,8 @@ const defaultProps = { disabled: false, autoFocus: false, auto: false, - className: '', - type: 'button' + className: "", + type: "button", }; type NativeAttrs = Omit, keyof Props>; @@ -66,7 +65,7 @@ interface IFocusRingAria extends FocusRingAria { export type ButtonProps = Props & NativeAttrs & - Omit & { + Omit & { css?: CSS; }; @@ -85,7 +84,7 @@ const Button = React.forwardRef( onPressUp, ...btnProps }: ButtonProps, - ref: React.Ref + ref: React.Ref, ) => { const groupConfig = useButtonGroupContext(); const filteredProps = filterPropsWithGroup(btnProps, groupConfig); @@ -110,9 +109,7 @@ const Button = React.forwardRef( ...props } = filteredProps; - const handleDrip = ( - e: React.MouseEvent | PressEvent - ) => { + const handleDrip = (e: React.MouseEvent | PressEvent) => { if (animated && ripple && buttonRef.current) { onDripClickHandler(e); } @@ -124,7 +121,7 @@ const Button = React.forwardRef( }; const handlePress = (e: PressEvent) => { - if (e.pointerType === 'keyboard' || e.pointerType === 'virtual') { + if (e.pointerType === "keyboard" || e.pointerType === "virtual") { handleDrip(e); // TODO: take this out and deprecate onClick function for next release (only use the @react-aria/button impl) onClick?.(e as any); @@ -133,7 +130,7 @@ const Button = React.forwardRef( }; const buttonRef = useDOMRef(ref); - const { buttonProps, isPressed } = useButton( + const {buttonProps, isPressed} = useButton( { ...btnProps, onClick: handleClick, @@ -143,97 +140,85 @@ const Button = React.forwardRef( onPressStart, onPressEnd, onPressChange, - onPressUp + onPressUp, } as AriaButtonProps, - buttonRef + buttonRef, ); - const { hoverProps, isHovered } = useHover({ isDisabled: disabled }); - const { isFocused, isFocusVisible, focusProps }: IFocusRingAria = - useFocusRing({ autoFocus }); + const {hoverProps, isHovered} = useHover({isDisabled: disabled}); + const {isFocused, isFocusVisible, focusProps}: IFocusRingAria = useFocusRing({autoFocus}); - const { onClick: onDripClickHandler, ...dripBindings } = useDrip( - false, - buttonRef - ); + const {onClick: onDripClickHandler, ...dripBindings} = useDrip(false, buttonRef); /* eslint-enable @typescript-eslint/no-unused-vars */ - if (__DEV__ && filteredProps.color === 'gradient' && (flat || light)) { - useWarning( - 'Using the gradient color on flat and light buttons will have no effect.' - ); + if (__DEV__ && filteredProps.color === "gradient" && (flat || light)) { + warn("Using the gradient color on flat and light buttons will have no effect."); } const hasIcon = icon || iconRight; const isChildLess = React.Children.count(children) === 0; const isRight = Boolean(iconRight); const getState = useMemo(() => { - if (isPressed) return 'pressed'; - if (isHovered) return 'hovered'; - return disabled ? 'disabled' : 'ready'; + if (isPressed) return "pressed"; + if (isHovered) return "hovered"; + + return disabled ? "disabled" : "ready"; }, [disabled, isHovered, isPressed]); const getIconCss = useMemo(() => { if (isRight) return iconRightCss; + return iconLeftCss; }, [isRight, iconRightCss, iconLeftCss]); return ( {React.Children.count(children) === 0 ? ( {hasIcon} ) : hasIcon ? ( <> {hasIcon}
{children} @@ -245,7 +230,7 @@ const Button = React.forwardRef( ); - } + }, ); type ButtonComponent = React.ForwardRefExoticComponent< @@ -255,12 +240,9 @@ type ButtonComponent = React.ForwardRefExoticComponent< }; if (__DEV__) { - Button.displayName = 'NextUI.Button'; + Button.displayName = "NextUI.Button"; } -Button.toString = () => '.nextui-button'; +Button.toString = () => ".nextui-button"; -export default withDefaults(Button, defaultProps) as ButtonComponent< - HTMLElement, - ButtonProps ->; +export default withDefaults(Button, defaultProps) as ButtonComponent; diff --git a/packages/react/src/button/index.ts b/packages/react/src/button/index.ts index fcac57e8bd..46a9d65fd7 100644 --- a/packages/react/src/button/index.ts +++ b/packages/react/src/button/index.ts @@ -1,15 +1,15 @@ -import Button from './button'; -import ButtonGroup from './button-group'; +import Button from "./button"; +import ButtonGroup from "./button-group"; -export type { ButtonProps } from './button'; -export type { ButtonGroupProps } from './button-group'; -export type { ButtonIconProps } from './button-icon'; +export type {ButtonProps} from "./button"; +export type {ButtonGroupProps} from "./button-group"; +export type {ButtonIconProps} from "./button-icon"; -export { StyledButton } from './button.styles'; -export type { ButtonVariantsProps } from './button.styles'; -export { StyledButtonGroup } from './button-group.styles'; -export type { ButtonGroupVariantsProps } from './button-group.styles'; -export { StyledButtonIcon } from './button-icon'; +export {StyledButton} from "./button.styles"; +export type {ButtonVariantsProps} from "./button.styles"; +export {StyledButtonGroup} from "./button-group.styles"; +export type {ButtonGroupVariantsProps} from "./button-group.styles"; +export {StyledButtonIcon} from "./button-icon"; Button.Group = ButtonGroup; diff --git a/packages/react/src/button/utils.tsx b/packages/react/src/button/utils.tsx index 5406ba2620..0e442ec6f6 100644 --- a/packages/react/src/button/utils.tsx +++ b/packages/react/src/button/utils.tsx @@ -1,12 +1,14 @@ -import React from 'react'; -import { ButtonProps } from './button'; -import { ButtonGroupConfig } from './button-group-context'; +import React from "react"; + +import {ButtonProps} from "./button"; +import {ButtonGroupConfig} from "./button-group-context"; export const filterPropsWithGroup = ( props: React.PropsWithChildren, - config: ButtonGroupConfig + config: ButtonGroupConfig, ): ButtonProps => { if (!config.isButtonGroup) return props; + return { ...props, auto: true, @@ -21,58 +23,55 @@ export const filterPropsWithGroup = ( light: config.light ?? props.light, size: config.size ?? props.size, color: config.color ?? props.color, - disabled: config.disabled ?? props.disabled + disabled: config.disabled ?? props.disabled, }; }; export const getCssColors = (props: React.PropsWithChildren) => { if (!props.disabled) { - if ( - props.auto && - props.color === 'gradient' && - (props.bordered || props.ghost) - ) { + if (props.auto && props.color === "gradient" && (props.bordered || props.ghost)) { return { - px: '$$buttonBorderWeight', - py: '$$buttonBorderWeight' + px: "$$buttonBorderWeight", + py: "$$buttonBorderWeight", }; } + return {}; } const defaultDisabledCss = { - bg: '$accents1', - color: '$accents7', - transform: 'none', - boxShadow: 'none', - pe: 'none' + bg: "$accents1", + color: "$accents7", + transform: "none", + boxShadow: "none", + pe: "none", }; if (!props.bordered && !props.flat && !props.ghost && !props.light) { return defaultDisabledCss; } - if (props.color === 'gradient' && (props.bordered || props.ghost)) { + if (props.color === "gradient" && (props.bordered || props.ghost)) { return { - color: '$accents4', + color: "$accents4", backgroundImage: - 'linear-gradient($background, $background), linear-gradient($accents2, $accents2)', - transform: 'none', - boxShadow: 'none', - pe: 'none', - pl: '$$buttonBorderWeight', - pr: '$$buttonBorderWeight' + "linear-gradient($background, $background), linear-gradient($accents2, $accents2)", + transform: "none", + boxShadow: "none", + pe: "none", + pl: "$$buttonBorderWeight", + pr: "$$buttonBorderWeight", }; } if (props.bordered || props.ghost || props.light) { return { ...defaultDisabledCss, - bg: 'transparent', - borderColor: '$accents4' + bg: "transparent", + borderColor: "$accents4", }; } if (props.flat) { return { ...defaultDisabledCss, - bg: '$accents1' + bg: "$accents1", }; } diff --git a/packages/react/src/card/__tests__/footer.test.tsx b/packages/react/src/card/__tests__/footer.test.tsx index 6ee289a99b..357045693f 100644 --- a/packages/react/src/card/__tests__/footer.test.tsx +++ b/packages/react/src/card/__tests__/footer.test.tsx @@ -1,25 +1,29 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import Card from '../index'; +import React from "react"; +import {mount} from "enzyme"; -describe('Card Footer', () => { - it('should render correctly', () => { +import Card from "../index"; + +describe("Card Footer", () => { + it("should render correctly", () => { const wrapper = mount(

card

footer -
+ , ); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should work properly when use alone', () => { + it("should work properly when use alone", () => { const wrapper = mount(footer); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should work with disable-auto-margin', () => { - const wrapper = mount(footer); + it("should work with disable-auto-margin", () => { + const wrapper = mount(footer); + expect(() => wrapper.unmount()).not.toThrow(); }); }); diff --git a/packages/react/src/card/__tests__/index.test.tsx b/packages/react/src/card/__tests__/index.test.tsx index 7b5e804951..abca228144 100644 --- a/packages/react/src/card/__tests__/index.test.tsx +++ b/packages/react/src/card/__tests__/index.test.tsx @@ -1,41 +1,46 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import Card from '../index'; +import React from "react"; +import {mount} from "enzyme"; -describe('Card', () => { - it('should render correctly', () => { +import Card from "../index"; + +describe("Card", () => { + it("should render correctly", () => { const wrapper = mount(card); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should support hoverable', () => { + it("should support hoverable", () => { const wrapper = mount(
card -
+
, ); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should support clikable', () => { + it("should support clikable", () => { const wrapper = mount(
card -
+ , ); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should support custom css', () => { + it("should support custom css", () => { const wrapper = mount(
- card -
+ card + , ); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should support card types', () => { + it("should support card types", () => { const wrapper = mount(
card @@ -44,19 +49,21 @@ describe('Card', () => { card card card -
+ , ); + expect(() => wrapper.unmount()).not.toThrow(); }); - it('should render correctly when nested', () => { + it("should render correctly when nested", () => { const wrapper = mount( card - + , ); + expect(() => wrapper.unmount()).not.toThrow(); }); }); diff --git a/packages/react/src/card/card.stories.tsx b/packages/react/src/card/card.stories.tsx index 195c77b48b..72ab260297 100644 --- a/packages/react/src/card/card.stories.tsx +++ b/packages/react/src/card/card.stories.tsx @@ -1,33 +1,24 @@ -import React from 'react'; -import { Meta } from '@storybook/react'; -import Card from './index'; -import { styled } from '../theme/stitches.config'; -import { - Row, - Col, - Link, - Text, - Code, - Button, - Grid, - Checkbox, - Spacer, - Input -} from '../index'; -import AppleEvent from '../../assets/apple-event.jpeg'; -import Homepods from '../../assets/homepod.jpeg'; -import Relaxing from '../../assets/relaxing.jpeg'; -import BreathingApp from '../../assets/breathing-app-icon.jpeg'; -import { Mail, Password } from '../utils/icons'; +import React from "react"; +import {Meta} from "@storybook/react"; + +import {styled} from "../theme/stitches.config"; +import {Row, Col, Link, Text, Code, Button, Grid, Checkbox, Spacer, Input} from "../index"; +import AppleEvent from "../../assets/apple-event.jpeg"; +import Homepods from "../../assets/homepod.jpeg"; +import Relaxing from "../../assets/relaxing.jpeg"; +import BreathingApp from "../../assets/breathing-app-icon.jpeg"; +import {Mail, Password} from "../utils/icons"; + +import Card from "./index"; export default { - title: 'Surfaces/Card', - component: Card + title: "Surfaces/Card", + component: Card, } as Meta; export const Default = () => ( - - + + A basic card @@ -62,37 +53,30 @@ export const Variants = () => ( export const WithFooter = () => ( - + nextui logo - + - + Next UI - nextui.org + nextui.org - - - Make beautiful websites regardless of your design experience. - + + Make beautiful websites regardless of your design experience. - + Visit source code on GitHub. @@ -105,15 +89,10 @@ export const AbsImageWithHeader = () => { return ( - - + + - + What to watch @@ -122,12 +101,12 @@ export const AbsImageWithHeader = () => { @@ -139,35 +118,30 @@ export const AbsImgWithHeaderFooter = () => { return ( - - + + - + New HomePod mini - - Room-filling sound, Intelligent assistant. Smart home control. - Works seamlessly with iPhone. Check it out + + Room-filling sound, Intelligent assistant. Smart home control. Works seamlessly with + iPhone. Check it out - + Available soon. @@ -175,8 +149,8 @@ export const AbsImgWithHeaderFooter = () => { - @@ -187,15 +161,10 @@ export const AbsImgWithHeaderFooter = () => { - - + + - + Your day your way @@ -204,21 +173,21 @@ export const AbsImgWithHeaderFooter = () => { @@ -226,12 +195,12 @@ export const AbsImgWithHeaderFooter = () => { @@ -239,20 +208,15 @@ export const AbsImgWithHeaderFooter = () => { Breathing App - Get a good night's sleep. + Get a good night's sleep. - @@ -268,16 +232,11 @@ export const AbsImgWithHeaderFooter = () => { export const CoverImage = () => ( - + - + - + What to watch @@ -286,24 +245,19 @@ export const CoverImage = () => ( - - - + + + - + Plant a tree @@ -312,24 +266,19 @@ export const CoverImage = () => ( - - - + + + - + Supercharged @@ -338,24 +287,19 @@ export const CoverImage = () => ( - - - + + + - + New @@ -363,23 +307,23 @@ export const CoverImage = () => ( - + @@ -393,13 +337,8 @@ export const CoverImage = () => ( - @@ -409,11 +348,11 @@ export const CoverImage = () => ( - - - + + + - + Your day your way @@ -421,23 +360,23 @@ export const CoverImage = () => ( - + @@ -445,11 +384,11 @@ export const CoverImage = () => ( @@ -457,25 +396,15 @@ export const CoverImage = () => ( Breathing App - Get a good night's sleep. + Get a good night's sleep. - @@ -491,67 +420,65 @@ export const CoverImage = () => ( export const PrimaryAction = () => { const list = [ { - title: 'Orange', - img: '/images/fruit-1.jpeg', - price: '$5.50' + title: "Orange", + img: "/images/fruit-1.jpeg", + price: "$5.50", }, { - title: 'Tangerine', - img: '/images/fruit-2.jpeg', - price: '$3.00' + title: "Tangerine", + img: "/images/fruit-2.jpeg", + price: "$3.00", }, { - title: 'Raspberry', - img: '/images/fruit-3.jpeg', - price: '$10.00' + title: "Raspberry", + img: "/images/fruit-3.jpeg", + price: "$10.00", }, { - title: 'Lemon', - img: '/images/fruit-4.jpeg', - price: '$5.30' + title: "Lemon", + img: "/images/fruit-4.jpeg", + price: "$5.30", }, { - title: 'Advocato', - img: '/images/fruit-5.jpeg', - price: '$15.70' + title: "Advocato", + img: "/images/fruit-5.jpeg", + price: "$15.70", }, { - title: 'Lemon 2', - img: '/images/fruit-6.jpeg', - price: '$8.00' + title: "Lemon 2", + img: "/images/fruit-6.jpeg", + price: "$8.00", }, { - title: 'Banana', - img: '/images/fruit-7.jpeg', - price: '$7.50' + title: "Banana", + img: "/images/fruit-7.jpeg", + price: "$7.50", }, { - title: 'Watermelon', - img: '/images/fruit-8.jpeg', - price: '$12.20' - } + title: "Watermelon", + img: "/images/fruit-8.jpeg", + price: "$12.20", + }, ]; return ( {list.map((item, index) => ( - + - + - - + + {item.title} - - {item.price} - + {item.price} @@ -564,59 +491,55 @@ export const PrimaryAction = () => { export const CenterImgWithHeader = () => { const list = [ { - title: 'Mac', - img: require('../../assets/mac.png') + title: "Mac", + img: require("../../assets/mac.png"), }, { - title: 'iPhone', - img: require('../../assets/iphone.png') + title: "iPhone", + img: require("../../assets/iphone.png"), }, { - title: 'iPad', - img: require('../../assets/ipad.png') + title: "iPad", + img: require("../../assets/ipad.png"), }, { - title: 'Apple Watch', - img: require('../../assets/apple-watch.png') + title: "Apple Watch", + img: require("../../assets/apple-watch.png"), }, { - title: 'AirPods', - img: require('../../assets/airpods.png') + title: "AirPods", + img: require("../../assets/airpods.png"), }, { - title: 'AirTag', - img: require('../../assets/airtag.png') + title: "AirTag", + img: require("../../assets/airtag.png"), }, { - title: 'Apple TV', - img: require('../../assets/appletv.png') + title: "Apple TV", + img: require("../../assets/appletv.png"), }, { - title: 'HomePod mini', - img: require('../../assets/homepod-mini.png') + title: "HomePod mini", + img: require("../../assets/homepod-mini.png"), }, { - title: 'Accessories', - img: require('../../assets/accessories.png') - } + title: "Accessories", + img: require("../../assets/accessories.png"), + }, ]; + return ( {list.map((item, index) => ( - - - + + + {item.title} - - + + @@ -626,20 +549,18 @@ export const CenterImgWithHeader = () => { }; export const WithDivider = () => ( - + Description - - The Object constructor creates an object wrapper for the given value. - + The Object constructor creates an object wrapper for the given value. - When called in a non-constructor context, Object behaves identically to{' '} + When called in a non-constructor context, Object behaves identically to{" "} new Object(). @@ -647,33 +568,33 @@ export const WithDivider = () => ( ); export const Shadows = () => { - const Box = styled('div', { - size: '120px', - dflex: 'center', - bg: '$backgroundContrast', - br: '$md' + const Box = styled("div", { + size: "120px", + dflex: "center", + bg: "$backgroundContrast", + br: "$md", }); - const shadows = ['$xs', '$sm', '$md', '$lg', '$xl']; + const shadows = ["$xs", "$sm", "$md", "$lg", "$xl"]; return ( - - + + Drop shadows {shadows.map((shadow, index) => ( - - + + Shadow: {shadow} ))} - + Box shadows {shadows.map((shadow, index) => ( - - + + Shadow: {shadow} @@ -684,8 +605,8 @@ export const Shadows = () => { export const withForm = () => { return ( - - + + Welcome to  @@ -693,40 +614,40 @@ export const withForm = () => { - + } + placeholder="Email" + size="lg" /> } + placeholder="Password" + size="lg" /> - + - + Remember me - + Forgot password? - - + + - + npm install @nextui-org/react - + diff --git a/apps/docs/src/components/kbar/index.tsx b/apps/docs/src/components/kbar/index.tsx index 2838bc0cb0..18d2d8e497 100644 --- a/apps/docs/src/components/kbar/index.tsx +++ b/apps/docs/src/components/kbar/index.tsx @@ -1,43 +1,29 @@ -import React from 'react'; -import { useTheme, Backdrop } from '@nextui-org/react'; -import { - KBarPortal, - KBarPositioner, - KBarAnimator, - VisualState, - useKBar -} from 'kbar'; -import KBarOption from './option'; -import KBarSearch from './search'; -import KBarResults from './results'; -import generateStyles from './styles'; -import { Action, ResultHandlers, ResultState } from './types'; +import React from "react"; +import {useTheme, Backdrop} from "@nextui-org/react"; +import {KBarPortal, KBarPositioner, KBarAnimator, VisualState, useKBar} from "kbar"; + +import KBarOption from "./option"; +import KBarSearch from "./search"; +import KBarResults from "./results"; +import generateStyles from "./styles"; +import {Action, ResultHandlers, ResultState} from "./types"; const KBar: React.FC = () => { - const { theme } = useTheme(); + const {theme} = useTheme(); const styles = generateStyles(theme); - const { visible } = useKBar((state) => ({ - visible: state.visualState !== VisualState.hidden + const {visible} = useKBar((state) => ({ + visible: state.visualState !== VisualState.hidden, })); return ( - + ( + onRender={(action: Action, handlers: ResultHandlers, state: ResultState) => ( )} /> diff --git a/apps/docs/src/components/kbar/option.tsx b/apps/docs/src/components/kbar/option.tsx index 3f7d063db5..449d9a5ec6 100644 --- a/apps/docs/src/components/kbar/option.tsx +++ b/apps/docs/src/components/kbar/option.tsx @@ -1,12 +1,14 @@ -import React, { useCallback } from 'react'; -import cn from 'classnames'; -import Image from 'next/image'; -import { useTheme } from '@nextui-org/react'; -import { addColorAlpha } from '@utils/index'; -import Keyboard from '../keyboard'; -import Icon from '../icons/map-icons'; -import { isEmpty } from 'lodash'; -import { Action, ResultHandlers, ResultState } from './types'; +import React, {useCallback} from "react"; +import cn from "classnames"; +import Image from "next/image"; +import {useTheme} from "@nextui-org/react"; +import {addColorAlpha} from "@utils/index"; +import {isEmpty} from "lodash"; + +import Keyboard from "../keyboard"; +import Icon from "../icons/map-icons"; + +import {Action, ResultHandlers, ResultState} from "./types"; interface Props { action: Action; @@ -14,10 +16,10 @@ interface Props { state: ResultState; } -const KBarOption: React.FC = ({ action, handlers, state }) => { +const KBarOption: React.FC = ({action, handlers, state}) => { const ownRef = React.useRef(null); const active = state.index === state.activeIndex; - const { theme, isDark } = useTheme(); + const {theme, isDark} = useTheme(); React.useEffect(() => { if (active) { @@ -26,16 +28,17 @@ const KBarOption: React.FC = ({ action, handlers, state }) => { window.requestAnimationFrame(() => window.requestAnimationFrame(() => { const element = ownRef.current; + if (!element) { return; } // @ts-ignore element.scrollIntoView({ - block: 'nearest', - behavior: 'smooth', - inline: 'start' + block: "nearest", + behavior: "smooth", + inline: "start", }); - }) + }), ); } }, [active]); @@ -45,61 +48,45 @@ const KBarOption: React.FC = ({ action, handlers, state }) => { return (
); } - if ( - action.icon && - typeof action.icon === 'string' && - action.icon.includes('.svg') - ) { + if (action.icon && typeof action.icon === "string" && action.icon.includes(".svg")) { return (
{`${action.name}
); - } else if (action.icon && typeof action.icon === 'string') { + } else if (action.icon && typeof action.icon === "string") { return (
); } + return
{action.icon}
; }, [active, isDark]); return (
  • -
    +
    {renderIcon()}
    {action.name} - {action.subtitle && ( - {action.subtitle} - )} + {action.subtitle && {action.subtitle}}
    diff --git a/apps/docs/src/components/kbar/results.tsx b/apps/docs/src/components/kbar/results.tsx index 69bf5e6beb..fefaa23ec7 100644 --- a/apps/docs/src/components/kbar/results.tsx +++ b/apps/docs/src/components/kbar/results.tsx @@ -1,30 +1,28 @@ -import * as React from 'react'; -import cn from 'classnames'; -import { matchSorter } from 'match-sorter'; -import { VisualState, useKBar } from 'kbar'; -import { groupBy, isEmpty } from 'lodash'; -import { useTheme } from '@nextui-org/react'; -import { Action, ResultState, KBarResultsProps, ResultHandlers } from './types'; +import * as React from "react"; +import cn from "classnames"; +import {matchSorter} from "match-sorter"; +import {VisualState, useKBar} from "kbar"; +import {groupBy, isEmpty} from "lodash"; +import {useTheme} from "@nextui-org/react"; + +import {Action, ResultState, KBarResultsProps, ResultHandlers} from "./types"; function useMatches(term: string, actions: Action[]) { // TODO: we can throttle this if needed return React.useMemo( - () => - term.trim() === '' - ? actions - : matchSorter(actions, term, { keys: ['keywords', 'name'] }), - [term, actions] + () => (term.trim() === "" ? actions : matchSorter(actions, term, {keys: ["keywords", "name"]})), + [term, actions], ); } export default function KBarResults(props: KBarResultsProps) { - const { search, actions, currentRootActionId, query } = useKBar((state) => ({ + const {search, actions, currentRootActionId, query} = useKBar((state) => ({ search: state.searchQuery, currentRootActionId: state.currentRootActionId, - actions: state.actions + actions: state.actions, })); - const { theme } = useTheme(); + const {theme} = useTheme(); // Store reference to a list of all actions const actionsList = React.useMemo( @@ -32,7 +30,7 @@ export default function KBarResults(props: KBarResultsProps) { Object.keys(actions).map((key) => { return actions[key]; }), - [actions] + [actions], ); const currActions = React.useMemo(() => { @@ -41,6 +39,7 @@ export default function KBarResults(props: KBarResultsProps) { if (!curr.parent) { acc[curr.id] = curr; } + return acc; }, {}); } @@ -50,15 +49,16 @@ export default function KBarResults(props: KBarResultsProps) { if (!children) { return { - [root.id]: root + [root.id]: root, }; } return { ...children.reduce((acc: any, actionId) => { acc[actionId] = actions[actionId]; + return acc; - }, {}) + }, {}), }; }, [actions, actionsList, currentRootActionId]); @@ -66,9 +66,10 @@ export default function KBarResults(props: KBarResultsProps) { () => Object.keys(currActions).map((key) => { const action = currActions[key]; + return action; }) as Action[], - [currActions] + [currActions], ); const matches = useMatches(search, filteredList); @@ -96,7 +97,7 @@ export default function KBarResults(props: KBarResultsProps) { React.useEffect(() => { function handleKeyDown(event: KeyboardEvent) { event.stopPropagation(); - if (event.key === 'ArrowDown' || (event.ctrlKey && event.key === 'j')) { + if (event.key === "ArrowDown" || (event.ctrlKey && event.key === "j")) { event.preventDefault(); setActiveIndex((index) => { if (index >= matches.length - 1) { @@ -107,7 +108,7 @@ export default function KBarResults(props: KBarResultsProps) { }); } - if (event.key === 'ArrowUp' || (event.ctrlKey && event.key === 'k')) { + if (event.key === "ArrowUp" || (event.ctrlKey && event.key === "k")) { event.preventDefault(); setActiveIndex((index) => { if (index === 0) { @@ -117,13 +118,14 @@ export default function KBarResults(props: KBarResultsProps) { } }); } - if (event.key === 'Enter') { + if (event.key === "Enter") { event.preventDefault(); select(); } } - window.addEventListener('keydown', handleKeyDown); - return () => window.removeEventListener('keydown', handleKeyDown); + window.addEventListener("keydown", handleKeyDown); + + return () => window.removeEventListener("keydown", handleKeyDown); }, [matches, select, activeIndex]); // Reset focused index when searching & updated results. @@ -131,49 +133,46 @@ export default function KBarResults(props: KBarResultsProps) { setActiveIndex(0); }, [filteredList.length, search]); - const groupedMatches = groupBy(matches, 'section'); + const groupedMatches = groupBy(matches, "section"); const renderAction = (action: any, index: number) => { const handlers: ResultHandlers = { onClick: select, onPointerDown: () => setActiveIndex(index), - onMouseEnter: () => setActiveIndex(index) + onMouseEnter: () => setActiveIndex(index), }; const state: ResultState = { activeIndex, - index + index, }; + if (props.onRender) { // Implicitly add a `key` so the user won't have to. return React.cloneElement(props.onRender(action, handlers, state), { - key: action.id + key: action.id, }); } + return ( - + {action.name} ); }; let idx = -1; + return ( -
    +
    {!isEmpty(groupedMatches) ? Object.keys(groupedMatches).map((section, sectionIndex) => { return ( -
      - {section && section !== 'undefined' ? ( +
        + {section && section !== "undefined" ? ( {section} ) : null} {groupedMatches[section].map((action) => { idx = idx + 1; + return renderAction(action, idx); })}
      @@ -203,11 +202,7 @@ export default function KBarResults(props: KBarResultsProps) { } // Separate component to ensure we can scrollTo active elements properly. -const DefaultResultWrapper: React.FC<{ isActive: boolean }> = ({ - isActive, - children, - ...rest -}) => { +const DefaultResultWrapper: React.FC<{isActive: boolean}> = ({isActive, children, ...rest}) => { const ownRef = React.useRef(null); React.useEffect(() => { @@ -217,11 +212,12 @@ const DefaultResultWrapper: React.FC<{ isActive: boolean }> = ({ window.requestAnimationFrame(() => window.requestAnimationFrame(() => { const element = ownRef.current; + if (!element) { return; } - element.scrollIntoView({ block: 'nearest' }); - }) + element.scrollIntoView({block: "nearest"}); + }), ); } }, [isActive]); diff --git a/apps/docs/src/components/kbar/search.tsx b/apps/docs/src/components/kbar/search.tsx index 22e468fa3d..406d30f61e 100644 --- a/apps/docs/src/components/kbar/search.tsx +++ b/apps/docs/src/components/kbar/search.tsx @@ -1,21 +1,19 @@ -import * as React from 'react'; -import { useKBar } from 'kbar'; -import { useTheme } from '@nextui-org/react'; +import * as React from "react"; +import {useKBar} from "kbar"; +import {useTheme} from "@nextui-org/react"; -export default function KBarSearch( - props: React.InputHTMLAttributes -) { - const { query, search, actions, currentRootActionId } = useKBar((state) => ({ +export default function KBarSearch(props: React.InputHTMLAttributes) { + const {query, search, actions, currentRootActionId} = useKBar((state) => ({ search: state.searchQuery, currentRootActionId: state.currentRootActionId, - actions: state.actions + actions: state.actions, })); - const { theme } = useTheme(); + const {theme} = useTheme(); const ownRef = React.useRef(null); React.useEffect(() => { - query.setSearch(''); + query.setSearch(""); ownRef.current?.focus(); }, [currentRootActionId, query]); @@ -30,8 +28,9 @@ export default function KBarSearch( query.setSearch(event.target.value); }} onKeyDown={(event) => { - if (currentRootActionId && !search && event.key === 'Backspace') { + if (currentRootActionId && !search && event.key === "Backspace") { const parent = actions[currentRootActionId].parent; + query.setCurrentRootAction(parent); } }} diff --git a/apps/docs/src/components/kbar/styles.ts b/apps/docs/src/components/kbar/styles.ts index 04e858016d..b1b064fca2 100644 --- a/apps/docs/src/components/kbar/styles.ts +++ b/apps/docs/src/components/kbar/styles.ts @@ -1,20 +1,20 @@ -import { NextUITheme } from '@nextui-org/react'; +import {NextUITheme} from "@nextui-org/react"; export default function generateStyles(theme?: NextUITheme) { return { container: { - maxWidth: '500px', - width: '100%', + maxWidth: "500px", + width: "100%", background: theme?.colors?.accents1?.value, color: theme?.colors?.text?.value, - borderRadius: '8px', - overflow: 'hidden', - boxShadow: theme?.shadows?.md?.value + borderRadius: "8px", + overflow: "hidden", + boxShadow: theme?.shadows?.md?.value, }, result: { maxHeight: 400, - paddingBottom: '8px', - overflow: 'auto' - } + paddingBottom: "8px", + overflow: "auto", + }, }; } diff --git a/apps/docs/src/components/kbar/types.ts b/apps/docs/src/components/kbar/types.ts index 8d06c5ed3f..f1a40fe972 100644 --- a/apps/docs/src/components/kbar/types.ts +++ b/apps/docs/src/components/kbar/types.ts @@ -1,4 +1,4 @@ -import { ReactElement, ReactNode, CSSProperties } from 'react'; +import {ReactElement, ReactNode, CSSProperties} from "react"; export type ActionId = string; @@ -28,9 +28,5 @@ export interface ResultState { export interface KBarResultsProps { style?: CSSProperties; className?: string; - onRender?: ( - action: Action, - handlers: ResultHandlers, - state: ResultState - ) => ReactElement; + onRender?: (action: Action, handlers: ResultHandlers, state: ResultState) => ReactElement; } diff --git a/apps/docs/src/components/keyboard/index.tsx b/apps/docs/src/components/keyboard/index.tsx index d542fd06ec..ccb9261719 100644 --- a/apps/docs/src/components/keyboard/index.tsx +++ b/apps/docs/src/components/keyboard/index.tsx @@ -1,7 +1,7 @@ -import React, { useMemo } from 'react'; -import withDefaults from '@utils/with-defaults'; -import { NextUITheme, useTheme } from '@nextui-org/react'; -import { addColorAlpha } from '@utils/index'; +import React, {useMemo} from "react"; +import withDefaults from "@utils/with-defaults"; +import {NextUITheme, useTheme} from "@nextui-org/react"; +import {addColorAlpha} from "@utils/index"; interface Props { command?: boolean; @@ -19,7 +19,7 @@ const defaultProps = { option: false, ctrl: false, small: false, - className: '' + className: "", }; type NativeAttrs = Omit, keyof Props>; @@ -35,13 +35,14 @@ const getLayout = (small: boolean, theme?: NextUITheme): CustomLayout => { if (small) return { padding: 0, - fontSize: '.75rem', - minWidth: theme ? theme?.space?.lg?.value : 'initial' + fontSize: ".75rem", + minWidth: theme ? theme?.space?.lg?.value : "initial", }; + return { - padding: theme ? theme?.space[2]?.value : '0.25rem', - fontSize: '0.875rem', - minWidth: `calc(1.5 * ${theme?.space?.lg})` + padding: theme ? theme?.space[2]?.value : "0.25rem", + fontSize: "0.875rem", + minWidth: `calc(1.5 * ${theme?.space?.lg})`, }; }; @@ -56,15 +57,15 @@ const Keyboard: React.FC> = ({ onClick, ...props }) => { - const { theme, isDark } = useTheme(); + const {theme, isDark} = useTheme(); - const { padding, fontSize, minWidth } = useMemo( + const {padding, fontSize, minWidth} = useMemo( () => getLayout(small, theme), - [small, theme] + [small, theme], ); return ( - + {command && } {shift && } {option && } @@ -76,19 +77,13 @@ const Keyboard: React.FC> = ({ line-height: 2em; text-align: center; display: inline-block; - cursor: ${onClick ? 'pointer' : 'default'}; + cursor: ${onClick ? "pointer" : "default"}; color: ${addColorAlpha(theme?.colors?.text?.value, 0.6)}; - background-color: ${addColorAlpha( - theme?.colors?.background?.value, - 0.8 - )}; + background-color: ${addColorAlpha(theme?.colors?.background?.value, 0.8)}; border: ${isDark - ? `1px solid ${addColorAlpha( - theme?.colors?.foreground?.value, - 0.2 - )}` - : 'none'}; - box-shadow: ${isDark ? 'none' : '0 0 2px 0 rgb(0 0 0 / 14%)'}; + ? `1px solid ${addColorAlpha(theme?.colors?.foreground?.value, 0.2)}` + : "none"}; + box-shadow: ${isDark ? "none" : "0 0 2px 0 rgb(0 0 0 / 14%)"}; font-family: ${theme?.fonts?.sans?.value}; border-radius: 6px; padding: 0 ${padding}; diff --git a/apps/docs/src/components/logo/index.tsx b/apps/docs/src/components/logo/index.tsx index 8e27cb58e2..642e49b10a 100644 --- a/apps/docs/src/components/logo/index.tsx +++ b/apps/docs/src/components/logo/index.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { CSS, styled } from '@nextui-org/react'; +import React from "react"; +import {CSS, styled} from "@nextui-org/react"; export interface LogoProps { auto?: boolean; @@ -13,32 +13,32 @@ export interface LogoProps { css?: CSS; } -const StyledSmallLogo = styled('svg', { - '& path': { fill: '$foreground' }, +const StyledSmallLogo = styled("svg", { + "& path": {fill: "$foreground"}, variants: { auto: { true: { - display: 'none', - '@mdMax': { - display: 'block' - } - } - } - } + display: "none", + "@mdMax": { + display: "block", + }, + }, + }, + }, }); -const StyledLargeLogo = styled('svg', { - display: 'block', - '& path': { fill: '$foreground' }, +const StyledLargeLogo = styled("svg", { + display: "block", + "& path": {fill: "$foreground"}, variants: { auto: { true: { - '@mdMax': { - display: 'none' - } - } - } - } + "@mdMax": { + display: "none", + }, + }, + }, + }, }); const Logo: React.FC = ({ @@ -54,12 +54,12 @@ const Logo: React.FC = ({ }) => { const Small = () => ( @@ -68,11 +68,11 @@ const Logo: React.FC = ({ const Large = () => ( @@ -91,6 +91,7 @@ const Logo: React.FC = ({ if (small) { return ; } + return ; }; diff --git a/apps/docs/src/components/looper-bg/index.tsx b/apps/docs/src/components/looper-bg/index.tsx index f6e3e484e9..a01d89746b 100644 --- a/apps/docs/src/components/looper-bg/index.tsx +++ b/apps/docs/src/components/looper-bg/index.tsx @@ -1,6 +1,6 @@ -import React from 'react'; -import { styled, CSS } from '@nextui-org/react'; -import withDefaults from '@utils/with-defaults'; +import React from "react"; +import {styled, CSS} from "@nextui-org/react"; +import withDefaults from "@utils/with-defaults"; export interface Props { width?: number; @@ -11,493 +11,493 @@ export interface Props { const defaultProps = { width: 1371, - height: 1352 + height: 1352, }; -const StyledSvg = styled('svg', {}); +const StyledSvg = styled("svg", {}); -const LooperBG: React.FC = ({ width, height, ...props }) => { +const LooperBG: React.FC = ({width, height, ...props}) => { return ( = ({ width, height, ...props }) => { /> diff --git a/apps/docs/src/components/mdx/index.tsx b/apps/docs/src/components/mdx/index.tsx index fe4f8beb58..edef1f3c59 100644 --- a/apps/docs/src/components/mdx/index.tsx +++ b/apps/docs/src/components/mdx/index.tsx @@ -1,15 +1,16 @@ /* eslint-disable react/display-name */ -import * as React from 'react'; -import Playground from '../playground'; -import Codeblock from '../codeblock'; -import CarbonAd from '../carbon-ad'; -import * as Icons from '../icons'; -import { styled, useTheme } from '@nextui-org/react'; -import { Anchor } from '@components'; -import Block from '../templates/example-block'; -import cn from 'classnames'; +import * as React from "react"; +import {styled, useTheme} from "@nextui-org/react"; +import {Anchor} from "@components"; +import cn from "classnames"; -const Table: React.FC> = ({ children }) => { +import Playground from "../playground"; +import Codeblock from "../codeblock"; +import CarbonAd from "../carbon-ad"; +import * as Icons from "../icons"; +import Block from "../templates/example-block"; + +const Table: React.FC> = ({children}) => { return (
      {children}
      @@ -27,8 +28,9 @@ const Table: React.FC> = ({ children }) => {
      ); }; -const Thead: React.FC> = ({ children }) => { - const { theme } = useTheme(); +const Thead: React.FC> = ({children}) => { + const {theme} = useTheme(); + return ( {children} @@ -46,22 +48,21 @@ const Thead: React.FC> = ({ children }) => { } :global(.docs-thead th:nth-child(1)) { padding-left: 1rem; - border-radius: ${theme?.radii?.lg?.value} 0 0 - ${theme?.radii?.lg?.value}; + border-radius: ${theme?.radii?.lg?.value} 0 0 ${theme?.radii?.lg?.value}; } :global(.docs-thead th:last-child) { - border-radius: 0 ${theme?.radii?.lg?.value} ${theme?.radii?.lg?.value} - 0; + border-radius: 0 ${theme?.radii?.lg?.value} ${theme?.radii?.lg?.value} 0; } `} ); }; -const Trow: React.FC> = ({ children }) => { +const Trow: React.FC> = ({children}) => { return {children}; }; -const Tcol: React.FC> = ({ children }) => { - const { theme } = useTheme(); +const Tcol: React.FC> = ({children}) => { + const {theme} = useTheme(); + return ( {children} @@ -77,30 +78,25 @@ const Tcol: React.FC> = ({ children }) => { ); }; + export interface LinkedHeadingProps { as: keyof JSX.IntrinsicElements; linked?: boolean; } -const LinkedHeading: React.FC = ({ - as, - linked = true, - ...props -}) => { +const LinkedHeading: React.FC = ({as, linked = true, ...props}) => { const Component = as; + return ( - + {linked ? {props.children} : <>{props.children}} ); }; -const List: React.FC> = ({ children }) => { - const { theme } = useTheme(); +const List: React.FC> = ({children}) => { + const {theme} = useTheme(); + return (
        {children} @@ -119,8 +115,8 @@ const List: React.FC> = ({ children }) => { }; // @ts-ignore -const Paragraph = styled('p', { - fontSize: '1.125rem' +const Paragraph = styled("p", { + fontSize: "1.125rem", }); const MDXComponents = { @@ -128,15 +124,9 @@ const MDXComponents = { h1: (props: React.DetailsHTMLAttributes) => ( ), - h2: (props: React.DetailsHTMLAttributes) => ( - - ), - h3: (props: React.DetailsHTMLAttributes) => ( - - ), - h4: (props: React.DetailsHTMLAttributes) => ( - - ), + h2: (props: React.DetailsHTMLAttributes) => , + h3: (props: React.DetailsHTMLAttributes) => , + h4: (props: React.DetailsHTMLAttributes) => , p: Paragraph, table: Table, thead: Thead, @@ -146,7 +136,7 @@ const MDXComponents = { CarbonAd, code: Codeblock, ul: List, - Block + Block, }; export default MDXComponents; diff --git a/apps/docs/src/components/menu-toggle/index.tsx b/apps/docs/src/components/menu-toggle/index.tsx index 5f8c2210a1..bdd06ff642 100644 --- a/apps/docs/src/components/menu-toggle/index.tsx +++ b/apps/docs/src/components/menu-toggle/index.tsx @@ -1,16 +1,17 @@ -import * as React from 'react'; -import { useTheme } from '@nextui-org/react'; +import * as React from "react"; +import {useTheme} from "@nextui-org/react"; export interface MenuToggleProps { expanded: boolean; } -const MenuToggle: React.FC = ({ expanded }) => { - const { theme } = useTheme(); +const MenuToggle: React.FC = ({expanded}) => { + const {theme} = useTheme(); + return (
        diff --git a/apps/docs/src/components/mobile-navigation/index.tsx b/apps/docs/src/components/mobile-navigation/index.tsx index 411b6931d2..a653060b15 100644 --- a/apps/docs/src/components/mobile-navigation/index.tsx +++ b/apps/docs/src/components/mobile-navigation/index.tsx @@ -1,10 +1,10 @@ -import React from 'react'; -import { usePortal } from '@nextui-org/react'; -import cn from 'classnames'; -import withDefaults from '@utils/with-defaults'; -import { Route } from '@lib/docs/page'; -import { createPortal } from 'react-dom'; -import { Sidebar } from '@components'; +import React from "react"; +import {usePortal} from "@nextui-org/react"; +import cn from "classnames"; +import withDefaults from "@utils/with-defaults"; +import {Route} from "@lib/docs/page"; +import {createPortal} from "react-dom"; +import {Sidebar} from "@components"; interface Props { opened: boolean; @@ -16,17 +16,11 @@ interface Props { const defaultProps = { opened: false, - detached: false + detached: false, }; -const MobileNavigation: React.FC = ({ - opened, - detached, - hasNotify, - routes, - onClose -}) => { - const portal = usePortal('mobile-navigation'); +const MobileNavigation: React.FC = ({opened, detached, hasNotify, routes, onClose}) => { + const portal = usePortal("mobile-navigation"); const handlePostClick = () => { onClose && onClose(); @@ -35,10 +29,10 @@ const MobileNavigation: React.FC = ({ return portal ? createPortal( , - portal + portal, ) : null; }; diff --git a/apps/docs/src/components/nav-link/index.tsx b/apps/docs/src/components/nav-link/index.tsx index db930fffc3..1cd3d235d4 100644 --- a/apps/docs/src/components/nav-link/index.tsx +++ b/apps/docs/src/components/nav-link/index.tsx @@ -1,7 +1,7 @@ -import React from 'react'; -import NextLink from 'next/link'; -import { useRouter } from 'next/router'; -import { Link, styled } from '@nextui-org/react'; +import React from "react"; +import NextLink from "next/link"; +import {useRouter} from "next/router"; +import {Link, styled} from "@nextui-org/react"; export interface Props { href: string; @@ -15,10 +15,10 @@ export interface Props { } const defaultProps = { - href: '', - pathname: '', - title: '', - selected: false + href: "", + pathname: "", + title: "", + selected: false, }; type NativeAttrs = Omit, keyof Props>; @@ -26,36 +26,36 @@ type NativeAttrs = Omit, keyof Props>; export type NavLinkProps = Props & typeof defaultProps & NativeAttrs; const BaseLink = styled(Link, { - d: 'flex', - textDecoration: 'none', - '@smMax': { + d: "flex", + textDecoration: "none", + "@smMax": { pt: 0, pl: 0, pb: 0, - d: 'flex', - ai: 'center' + d: "flex", + ai: "center", }, - '&:active': { - opacity: 0.7 + "&:active": { + opacity: 0.7, }, variants: { selected: { true: { - boxSizing: 'border-box', - fontWeight: '$semibold', - '@smMax': { - borderLeft: 'none', - paddingLeft: 0 - } - } + boxSizing: "border-box", + fontWeight: "$semibold", + "@smMax": { + borderLeft: "none", + paddingLeft: 0, + }, + }, }, disabled: { true: { - cursor: 'not-allowed', - pe: 'none' - } - } - } + cursor: "not-allowed", + pe: "none", + }, + }, + }, }); const NavLink: React.FC = ({ @@ -65,7 +65,7 @@ const NavLink: React.FC = ({ color, selected, comingSoon, - onClick + onClick, }) => { const router = useRouter(); const onlyHashChange = pathname === router.pathname; @@ -73,12 +73,12 @@ const NavLink: React.FC = ({ if (onlyHashChange) { return ( {title} @@ -86,15 +86,15 @@ const NavLink: React.FC = ({ } return ( - + !comingSoon && onClick && onClick(e)} - css={{ - color: color ? color : 'inherit' - }} > {title} diff --git a/apps/docs/src/components/notify-banner/index.ts b/apps/docs/src/components/notify-banner/index.ts index 6be67cf5a7..7921c9df20 100644 --- a/apps/docs/src/components/notify-banner/index.ts +++ b/apps/docs/src/components/notify-banner/index.ts @@ -1,3 +1,3 @@ -import NotifyBanner from './notify-banner'; +import NotifyBanner from "./notify-banner"; export default NotifyBanner; diff --git a/apps/docs/src/components/notify-banner/notify-banner.tsx b/apps/docs/src/components/notify-banner/notify-banner.tsx index 254e40c72a..69fc414889 100644 --- a/apps/docs/src/components/notify-banner/notify-banner.tsx +++ b/apps/docs/src/components/notify-banner/notify-banner.tsx @@ -1,9 +1,10 @@ -import * as React from 'react'; -import NextLink from 'next/link'; -import { Badge } from '@components'; -import { Text, Spacer } from '@nextui-org/react'; -import { ChevronRight } from '@components'; -import { StyledNotifyBanner, StyledContent, StyledImg } from './styles'; +import * as React from "react"; +import NextLink from "next/link"; +import {Badge} from "@components"; +import {Text, Spacer} from "@nextui-org/react"; +import {ChevronRight} from "@components"; + +import {StyledNotifyBanner, StyledContent, StyledImg} from "./styles"; interface Props { text: string; @@ -12,24 +13,24 @@ interface Props { } const NotifyBanner: React.FC = (props) => { - const { showBadge = true, text, href = '#' } = props; + const {showBadge = true, text, href = "#"} = props; return ( {showBadge && ( - + 🚀   New @@ -38,15 +39,11 @@ const NotifyBanner: React.FC = (props) => { - + {text} - + diff --git a/apps/docs/src/components/notify-banner/styles.ts b/apps/docs/src/components/notify-banner/styles.ts index 72733cbc85..1d1cf994c4 100644 --- a/apps/docs/src/components/notify-banner/styles.ts +++ b/apps/docs/src/components/notify-banner/styles.ts @@ -1,47 +1,47 @@ -import { styled } from '@nextui-org/react'; -import { StyledCardBlur } from '@primitives'; -import { lightTheme } from '@theme/shared'; +import {styled} from "@nextui-org/react"; +import {StyledCardBlur} from "@primitives"; +import {lightTheme} from "@theme/shared"; export const StyledNotifyBanner = styled(StyledCardBlur, { - dflex: 'center', - fd: 'row', + dflex: "center", + fd: "row", p: 0, br: 0, - position: 'relative', - zIndex: '$1', - height: '40px', - color: '$text', - width: '100%', - border: '1.5px solid $border', - borderTopColor: 'transparent', - borderLeftColor: 'transparent', - borderRightColor: 'transparent', + position: "relative", + zIndex: "$1", + height: "40px", + color: "$text", + width: "100%", + border: "1.5px solid $border", + borderTopColor: "transparent", + borderLeftColor: "transparent", + borderRightColor: "transparent", [`.${lightTheme} &`]: { - '& .notify-gradient': { - display: 'none' - } - } + "& .notify-gradient": { + display: "none", + }, + }, }); -export const StyledContent = styled('a', { - display: 'flex', - position: 'relative', - zIndex: '$10', - fd: 'row', - alignItems: 'center', - textDecoration: 'none', - color: '$text', - cursor: 'pointer', - transition: '$default', - '& .chevron-right-icon': { - transition: 'transform cubic-bezier(0.4, 0, 0.2, 1) 0.2s' +export const StyledContent = styled("a", { + display: "flex", + position: "relative", + zIndex: "$10", + fd: "row", + alignItems: "center", + textDecoration: "none", + color: "$text", + cursor: "pointer", + transition: "$default", + "& .chevron-right-icon": { + transition: "transform cubic-bezier(0.4, 0, 0.2, 1) 0.2s", }, - '&:hover': { + "&:hover": { opacity: 0.8, - '& .chevron-right-icon': { - transform: 'translateX(2px)' - } - } + "& .chevron-right-icon": { + transform: "translateX(2px)", + }, + }, }); -export const StyledImg = styled('img', {}); +export const StyledImg = styled("img", {}); diff --git a/apps/docs/src/components/page-nav/index.tsx b/apps/docs/src/components/page-nav/index.tsx index ed3eb191dd..0a2cc21717 100644 --- a/apps/docs/src/components/page-nav/index.tsx +++ b/apps/docs/src/components/page-nav/index.tsx @@ -1,10 +1,11 @@ -import * as React from 'react'; -import withDefaults from '@utils/with-defaults'; -import { Route, addTagToSlug } from '@lib/docs/page'; -import NextLink from 'next/link'; -import { useTheme, styled, Container, Link } from '@nextui-org/react'; -import { ArrowRight, ArrowLeft } from '../icons'; -import { removeFromLast } from '@utils/index'; +import * as React from "react"; +import withDefaults from "@utils/with-defaults"; +import {Route, addTagToSlug} from "@lib/docs/page"; +import NextLink from "next/link"; +import {useTheme, styled, Container, Link} from "@nextui-org/react"; +import {removeFromLast} from "@utils/index"; + +import {ArrowRight, ArrowLeft} from "../icons"; export interface PageNavProps { tag?: string; @@ -15,30 +16,29 @@ export interface PageNavProps { const defaultProps = {}; const StyledLink = styled(Link, { - '&.page-nav__link': { - d: 'flex', - ai: 'center', - color: '$text', - '&:hover': { - bg: '$accents2' - } - } + "&.page-nav__link": { + d: "flex", + ai: "center", + color: "$text", + "&:hover": { + bg: "$accents2", + }, + }, }); -const PageNav: React.FC = ({ tag, prevRoute, nextRoute }) => { - const { theme } = useTheme(); +const PageNav: React.FC = ({tag, prevRoute, nextRoute}) => { + const {theme} = useTheme(); + return ( {prevRoute ? ( - + {prevRoute.title} @@ -48,9 +48,7 @@ const PageNav: React.FC = ({ tag, prevRoute, nextRoute }) => { )} {nextRoute && ( - + {nextRoute.title} diff --git a/apps/docs/src/components/palette/index.tsx b/apps/docs/src/components/palette/index.tsx index 39f74d8657..4f2fddd493 100644 --- a/apps/docs/src/components/palette/index.tsx +++ b/apps/docs/src/components/palette/index.tsx @@ -1,7 +1,8 @@ -import React, { useMemo } from 'react'; -import { Grid, Text, getTokenValue, useTheme } from '@nextui-org/react'; -import { toNumber } from 'lodash'; -import Item from './item'; +import React, {useMemo} from "react"; +import {Grid, Text, getTokenValue, useTheme} from "@nextui-org/react"; +import {toNumber} from "lodash"; + +import Item from "./item"; export interface Props { colors: string[] | string[][]; @@ -20,18 +21,18 @@ type MappedColor = { colors: Color[]; }; -const reverseColors: { [key in string]: string } = { - background: '$foreground', - foreground: '$background', - text: '$background', - border: '$text', - white: '$black', - black: '$white', - backgroundContrast: '$foreground' +const reverseColors: {[key in string]: string} = { + background: "$foreground", + foreground: "$background", + text: "$background", + border: "$text", + white: "$black", + black: "$white", + backgroundContrast: "$foreground", }; const getColorTitle = (color: string) => { - return color.replace(/[0-9]/g, ''); + return color.replace(/[0-9]/g, ""); }; const getColorNumber = (color: string) => { @@ -39,7 +40,8 @@ const getColorNumber = (color: string) => { if (!color.match(/[0-9]/g)) { return -1; // brand colors } - return toNumber(color.replace(/[^0-9]/g, '')); + + return toNumber(color.replace(/[^0-9]/g, "")); }; const mapColors = (colors: string[]): Color[] => { @@ -51,8 +53,8 @@ const mapColors = (colors: string[]): Color[] => { const reverseColor = reverseColors[color]; const textColor = isBrand - ? color === 'gradient' - ? '$white' + ? color === "gradient" + ? "$white" : `$${color}SolidContrast` : (isAccent && num <= 5) || (isBase && num <= 500) ? `$${colors[colors.length - 1]}` @@ -61,9 +63,9 @@ const mapColors = (colors: string[]): Color[] => { return { name: color, value: `$${color}`, - hexColor: getTokenValue('colors', color), + hexColor: getTokenValue("colors", color), number: num, - textColor: reverseColor || textColor + textColor: reverseColor || textColor, }; }); }; @@ -72,20 +74,18 @@ const mapMatrixColors = (colors: string[][]): MappedColor[] => { return colors.map((row, i) => { return { title: getColorTitle(row[i]), - colors: mapColors(row) + colors: mapColors(row), }; }); }; -const Palette: React.FC = ({ colors }) => { - const { isDark } = useTheme(); +const Palette: React.FC = ({colors}) => { + const {isDark} = useTheme(); const isMatrix = Array.isArray(colors[0]); const mappedColors = useMemo(() => { - return isMatrix - ? mapMatrixColors(colors as string[][]) - : mapColors(colors as string[]); + return isMatrix ? mapMatrixColors(colors as string[][]) : mapColors(colors as string[]); }, [isMatrix, colors, isDark]); if (isMatrix) { @@ -94,22 +94,20 @@ const Palette: React.FC = ({ colors }) => { {mappedColors.map((row: any, i: number) => ( - - - {row.title} - + + {row.title} {row.colors.map((color: Color, j: number) => ( - + ))} @@ -123,17 +121,17 @@ const Palette: React.FC = ({ colors }) => { {mappedColors?.map((color: any, i) => { return ( ); })} diff --git a/apps/docs/src/components/palette/item.tsx b/apps/docs/src/components/palette/item.tsx index 605f6b2da8..db499f8abb 100644 --- a/apps/docs/src/components/palette/item.tsx +++ b/apps/docs/src/components/palette/item.tsx @@ -1,12 +1,6 @@ -import React from 'react'; -import cn from 'classnames'; -import { - Grid, - Text, - Tooltip, - GridProps, - useClipboard -} from '@nextui-org/react'; +import React from "react"; +import cn from "classnames"; +import {Grid, Text, Tooltip, GridProps, useClipboard} from "@nextui-org/react"; interface Props { color: string; @@ -18,46 +12,39 @@ interface Props { export type ItemProps = Props & GridProps; -const Item: React.FC = ({ - color, - title, - inverted, - textColor, - hexColor, - ...props -}) => { - const isGradient = color.includes('gradient'); +const Item: React.FC = ({color, title, inverted, textColor, hexColor, ...props}) => { + const isGradient = color.includes("gradient"); - const { copy } = useClipboard(); + const {copy} = useClipboard(); const renderItem = () => { return ( @@ -66,11 +53,11 @@ const Item: React.FC = ({ className="text" css={{ m: 0, - fontWeight: '$semibold', + fontWeight: "$semibold", color: textColor, - '@smMax': { - fontSize: '$xs' - } + "@smMax": { + fontSize: "$xs", + }, }} > {title} @@ -81,11 +68,11 @@ const Item: React.FC = ({ className="text" css={{ m: 0, - fontWeight: '$semibold', + fontWeight: "$semibold", color: textColor, - '@smMax': { - fontSize: '$xs' - } + "@smMax": { + fontSize: "$xs", + }, }} > {title} @@ -94,11 +81,11 @@ const Item: React.FC = ({ className="hex-text" css={{ m: 0, - fontSize: '$xs', + fontSize: "$xs", color: textColor, opacity: 0.8, - tt: 'uppercase', - fontWeight: '$bold' + tt: "uppercase", + fontWeight: "$bold", }} > {hexColor} @@ -112,15 +99,11 @@ const Item: React.FC = ({ return ( <> {isGradient ? ( - + <>{renderItem()} ) : ( - copy(hexColor.trim())} - > + copy(hexColor.trim())}> <>{renderItem()} )} diff --git a/apps/docs/src/components/playground/code-theme.ts b/apps/docs/src/components/playground/code-theme.ts index fa8c9c8661..60b315c925 100644 --- a/apps/docs/src/components/playground/code-theme.ts +++ b/apps/docs/src/components/playground/code-theme.ts @@ -1,163 +1,143 @@ -import { PrismTheme } from 'prism-react-renderer'; -import { green } from '@nextui-org/react'; +import {PrismTheme} from "prism-react-renderer"; +import {green} from "@nextui-org/react"; const makeCodeTheme = (): PrismTheme => ({ plain: { - backgroundColor: 'var(--nextui-colors-codeBackground)', - color: '#F4F4F4', - fontWeight: '500', - fontStyle: 'normal', - fontFamily: '$mono', - fontSize: '$xs', - textRendering: 'geometricPrecision' + backgroundColor: "var(--nextui-colors-codeBackground)", + color: "#F4F4F4", + fontWeight: "500", + fontStyle: "normal", + fontFamily: "$mono", + fontSize: "$xs", + textRendering: "geometricPrecision", }, styles: [ { - types: ['comment', 'prolog', 'doctype', 'cdata'], + types: ["comment", "prolog", "doctype", "cdata"], style: { - color: 'var(--nextui-colors-codeComment)' - } + color: "var(--nextui-colors-codeComment)", + }, }, { - types: ['symbol', 'text'], + types: ["symbol", "text"], style: { - color: 'var(--nextui-colors-white)' - } + color: "var(--nextui-colors-white)", + }, }, { - types: ['punctuation'], + types: ["punctuation"], style: { - color: green.green200 - } + color: green.green200, + }, }, { - types: ['function'], + types: ["function"], style: { - color: '#61AFEF' - } + color: "#61AFEF", + }, }, { - types: ['namespace'], + types: ["namespace"], style: { - opacity: 1 - } + opacity: 1, + }, }, { - types: ['tag', 'operator', 'number'], + types: ["tag", "operator", "number"], style: { - color: '#E5C07B' - } + color: "#E5C07B", + }, }, { - types: ['property', 'function'], + types: ["property", "function"], style: { - color: 'var(--nextui-colors-success)' - } + color: "var(--nextui-colors-success)", + }, }, { - types: ['tag-id', 'selector', 'atrule-id'], + types: ["tag-id", "selector", "atrule-id"], style: { - color: '#E06C75' - } + color: "#E06C75", + }, }, { - types: ['attr-name'], + types: ["attr-name"], style: { - color: 'var(--nextui-colors-yellow600)' - } + color: "var(--nextui-colors-yellow600)", + }, }, { types: [ - 'boolean', - 'string', - 'entity', - 'url', - 'attr-value', - 'keyword', - 'control', - 'directive', - 'unit', - 'statement', - 'regex', - 'at-rule', - 'placeholder', - 'variable' + "boolean", + "string", + "entity", + "url", + "attr-value", + "keyword", + "control", + "directive", + "unit", + "statement", + "regex", + "at-rule", + "placeholder", + "variable", ], style: { - color: '#98C379' - } + color: "#98C379", + }, }, { - types: ['deleted'], + types: ["deleted"], style: { - textDecorationLine: 'line-through' - } + textDecorationLine: "line-through", + }, }, { - types: ['language-javascript', 'script'], + types: ["language-javascript", "script"], style: { - color: 'var(--nextui-colors-success)' - } + color: "var(--nextui-colors-success)", + }, }, { - types: ['inserted'], + types: ["inserted"], style: { - textDecorationLine: 'underline' - } + textDecorationLine: "underline", + }, }, { - types: ['italic'], + types: ["italic"], style: { - fontStyle: 'italic' - } + fontStyle: "italic", + }, }, { - types: ['important', 'bold'], + types: ["important", "bold"], style: { - fontWeight: 'bold' - } + fontWeight: "bold", + }, }, { - types: ['important', 'primitive'], + types: ["important", "primitive"], style: { - color: '#c678dd' - } - } - ] + color: "#c678dd", + }, + }, + ], }); export const getCodeThemeColors = () => { const codeTheme = makeCodeTheme(); - const stringColor = codeTheme.styles.find((style) => - style.types.includes('string') - ); - const punctuationColor = codeTheme.styles.find((style) => - style.types.includes('punctuation') - ); - const numberColor = codeTheme.styles.find((style) => - style.types.includes('number') - ); - const textColor = codeTheme.styles.find((style) => - style.types.includes('text') - ); - const selectorColor = codeTheme.styles.find((style) => - style.types.includes('selector') - ); - const commentColor = codeTheme.styles.find((style) => - style.types.includes('comment') - ); - const classnameColor = codeTheme.styles.find((style) => - style.types.includes('tag') - ); - const attrColor = codeTheme.styles.find((style) => - style.types.includes('attr-name') - ); - const functionColor = codeTheme.styles.find((style) => - style.types.includes('function') - ); - const primitiveColor = codeTheme.styles.find((style) => - style.types.includes('primitive') - ); + const stringColor = codeTheme.styles.find((style) => style.types.includes("string")); + const punctuationColor = codeTheme.styles.find((style) => style.types.includes("punctuation")); + const numberColor = codeTheme.styles.find((style) => style.types.includes("number")); + const textColor = codeTheme.styles.find((style) => style.types.includes("text")); + const selectorColor = codeTheme.styles.find((style) => style.types.includes("selector")); + const commentColor = codeTheme.styles.find((style) => style.types.includes("comment")); + const classnameColor = codeTheme.styles.find((style) => style.types.includes("tag")); + const attrColor = codeTheme.styles.find((style) => style.types.includes("attr-name")); + const functionColor = codeTheme.styles.find((style) => style.types.includes("function")); + const primitiveColor = codeTheme.styles.find((style) => style.types.includes("primitive")); return { ...codeTheme.plain, @@ -170,7 +150,7 @@ export const getCodeThemeColors = () => { classnameColor, attrColor, functionColor, - primitiveColor + primitiveColor, }; }; diff --git a/apps/docs/src/components/playground/dynamic-live.tsx b/apps/docs/src/components/playground/dynamic-live.tsx index 9c4c38ff0a..eba1a86416 100644 --- a/apps/docs/src/components/playground/dynamic-live.tsx +++ b/apps/docs/src/components/playground/dynamic-live.tsx @@ -1,66 +1,68 @@ -import React from 'react'; -import { LivePreview, LiveProvider, LiveError } from 'react-live'; -import makeCodeTheme from './code-theme'; -import Editor from './editor'; -import NextLink from 'next/link'; -import Palette from '../palette'; -import * as TemplateComponents from '../templates'; -import { useMediaQuery } from '@hooks/use-media-query'; -import { validateEmail } from '@utils/index'; -import withDefaults from '@utils/with-defaults'; -import { Box } from '@primitives'; -import * as Components from '@nextui-org/react'; -import * as Icons from '../icons'; +import React from "react"; +import {LivePreview, LiveProvider, LiveError} from "react-live"; +import NextLink from "next/link"; +import {useMediaQuery} from "@hooks/use-media-query"; +import {validateEmail} from "@utils/index"; +import withDefaults from "@utils/with-defaults"; +import {Box} from "@primitives"; +import * as Components from "@nextui-org/react"; + +import * as TemplateComponents from "../templates"; +import Palette from "../palette"; +import * as Icons from "../icons"; + +import Editor from "./editor"; +import makeCodeTheme from "./code-theme"; export interface Props { code: string; showEditor?: boolean; noInline?: boolean; initialEditorOpen?: boolean; - overflow?: 'auto' | 'visible' | 'hidden'; + overflow?: "auto" | "visible" | "hidden"; } const defaultProps = { - showEditor: true + showEditor: true, }; const StyledWrapper = Components.styled(Box, { - width: '100%', - padding: '$10', - marginLeft: '-$sm', - display: 'flex', - flexWrap: 'wrap', - color: '$text', - flexDirection: 'column', - background: 'transparent', - '& > div': { - width: '100%' + width: "100%", + padding: "$10", + marginLeft: "-$sm", + display: "flex", + flexWrap: "wrap", + color: "$text", + flexDirection: "column", + background: "transparent", + "& > div": { + width: "100%", }, - '@xsMax': { - p: '$5' + "@xsMax": { + p: "$5", }, variants: { overflow: { visible: { - overflowX: 'visible' + overflowX: "visible", }, hidden: { - overflowX: 'hidden' + overflowX: "hidden", }, auto: { - overflowX: 'auto' - } + overflowX: "auto", + }, }, noInline: { true: { - pb: '$10', - ml: 0 - } - } + pb: "$10", + ml: 0, + }, + }, }, defaultVariants: { - overflow: 'hidden' - } + overflow: "hidden", + }, }); export const scope = { @@ -70,35 +72,26 @@ export const scope = { NextLink, Palette, useMediaQuery, - validateEmail + validateEmail, }; -const DynamicLive: React.FC = ({ +const DynamicLive: React.FC = ({ code, showEditor, initialEditorOpen, noInline, overflow, - css + css, }) => { const codeTheme = makeCodeTheme(); + return ( - - + + - {showEditor && } + {showEditor && } ); }; diff --git a/apps/docs/src/components/playground/editor.tsx b/apps/docs/src/components/playground/editor.tsx index 42a7f9c3f7..fd7ee18818 100644 --- a/apps/docs/src/components/playground/editor.tsx +++ b/apps/docs/src/components/playground/editor.tsx @@ -1,33 +1,34 @@ -import React, { useState } from 'react'; -import { useRouter } from 'next/router'; -import { LiveEditor } from 'react-live'; -import { useTheme, Row, Col, Tooltip, useClipboard } from '@nextui-org/react'; -import { capitalize, join } from 'lodash'; -import CopyIcon from '../icons/copy'; -import BugIcon from '../icons/bug'; -import RightIcon from '../icons/arrow-right'; -import { ISSUE_REPORT_URL } from '../../lib/github/constants'; +import React, {useState} from "react"; +import {useRouter} from "next/router"; +import {LiveEditor} from "react-live"; +import {useTheme, Row, Col, Tooltip, useClipboard} from "@nextui-org/react"; +import {capitalize, join} from "lodash"; + +import CopyIcon from "../icons/copy"; +import BugIcon from "../icons/bug"; +import RightIcon from "../icons/arrow-right"; +import {ISSUE_REPORT_URL} from "../../lib/github/constants"; export interface Props { initialOpen?: boolean; code: string; } -const Editor: React.FC = ({ initialOpen, code }) => { - const { theme, isDark } = useTheme(); +const Editor: React.FC = ({initialOpen, code}) => { + const {theme, isDark} = useTheme(); const [visible, setVisible] = useState(initialOpen); const [copied, setCopied] = useState(false); const router = useRouter(); - const { copy } = useClipboard(); + const {copy} = useClipboard(); - const slug = router.query.slug || ''; + const slug = router.query.slug || ""; const componentTitle = Array.isArray(slug) ? join( slug.map((s) => capitalize(s)), - '/' + "/", ) : capitalize(slug); @@ -54,10 +55,10 @@ const Editor: React.FC = ({ initialOpen, code }) => { event.stopPropagation(); event.preventDefault(); - Object.assign(document.createElement('a'), { - target: '_blank', - rel: 'noopener noreferrer', - href: `${ISSUE_REPORT_URL}${componentTitle}` + Object.assign(document.createElement("a"), { + target: "_blank", + rel: "noopener noreferrer", + href: `${ISSUE_REPORT_URL}${componentTitle}`, }).click(); }; @@ -65,20 +66,12 @@ const Editor: React.FC = ({ initialOpen, code }) => {
        - + Live Editor @@ -88,42 +81,30 @@ const Editor: React.FC = ({ initialOpen, code }) => { - + - + @@ -150,7 +131,7 @@ const Editor: React.FC = ({ initialOpen, code }) => { transition: all 0.2s ease; overflow: hidden; border-radius: ${theme?.radii?.lg?.value}; - background-color: ${!isDark ? '#363449' : '#111'}; + background-color: ${!isDark ? "#363449" : "#111"}; box-shadow: 0px 5px 20px -5px rgb(0 0 0 / 20%); } details[open] :global(.right-side) { @@ -164,9 +145,7 @@ const Editor: React.FC = ({ initialOpen, code }) => { justify-content: space-between; align-items: center; padding: 0 ${theme?.space?.lg?.value}; - color: ${!isDark - ? theme?.colors?.accents2?.value - : theme?.colors?.accents5?.value}; + color: ${!isDark ? theme?.colors?.accents2?.value : theme?.colors?.accents5?.value}; height: 2.875rem; list-style: none; user-select: none; diff --git a/apps/docs/src/components/playground/index.ts b/apps/docs/src/components/playground/index.ts index c4f6ff3fbf..1ab7ae7209 100644 --- a/apps/docs/src/components/playground/index.ts +++ b/apps/docs/src/components/playground/index.ts @@ -1,3 +1,3 @@ -import Playground from './playground'; +import Playground from "./playground"; export default Playground; diff --git a/apps/docs/src/components/playground/playground.tsx b/apps/docs/src/components/playground/playground.tsx index c80a87312c..3d948db350 100644 --- a/apps/docs/src/components/playground/playground.tsx +++ b/apps/docs/src/components/playground/playground.tsx @@ -1,37 +1,34 @@ -import React from 'react'; -import dynamic from 'next/dynamic'; -import { Loading } from '@nextui-org/react'; -import withDefaults from '@utils/with-defaults'; -import { - SandpackFiles, - SandpackPredefinedTemplate, - SandpackHighlightedLines -} from '@components'; -import { Box } from '@primitives'; -import Title from './title'; -import { isEmpty } from 'lodash'; -import LiveCode, { scope } from './dynamic-live'; -import { transformCode, joinCode, getFileName } from './utils'; -import { FileCode } from './types'; - -const DynamicLive = dynamic(() => import('./dynamic-live'), { +import React from "react"; +import dynamic from "next/dynamic"; +import {Loading} from "@nextui-org/react"; +import withDefaults from "@utils/with-defaults"; +import {SandpackFiles, SandpackPredefinedTemplate, SandpackHighlightedLines} from "@components"; +import {Box} from "@primitives"; +import {isEmpty} from "lodash"; + +import Title from "./title"; +import LiveCode, {scope} from "./dynamic-live"; +import {transformCode, joinCode, getFileName} from "./utils"; +import {FileCode} from "./types"; + +const DynamicLive = dynamic(() => import("./dynamic-live"), { ssr: false, // eslint-disable-next-line react/display-name loading: () => ( -
        +
        - ) + ), }); -const DynamicSandpack = dynamic(() => import('../sandpack'), { +const DynamicSandpack = dynamic(() => import("../sandpack"), { ssr: false, // eslint-disable-next-line react/display-name loading: () => ( -
        +
        - ) + ), }); interface Props { @@ -40,7 +37,7 @@ interface Props { showEditor?: boolean; showSandpackPreview?: boolean; initialEditorOpen?: boolean; - overflow?: 'auto' | 'visible' | 'hidden'; + overflow?: "auto" | "visible" | "hidden"; files?: SandpackFiles; template?: SandpackPredefinedTemplate; highlightedLines?: SandpackHighlightedLines; @@ -48,15 +45,15 @@ interface Props { } const defaultProps = { - desc: '', - title: '', - code: '', + desc: "", + title: "", + code: "", files: {}, showEditor: true, showSandpackPreview: false, initialEditorOpen: false, - overflow: 'visible', - bindings: {} + overflow: "visible", + bindings: {}, }; export type PlaygroundProps = Props & typeof defaultProps; @@ -70,7 +67,7 @@ const Playground: React.FC = ({ showSandpackPreview, files, overflow, - desc + desc, }) => { const isSanpackEditor = !isEmpty(files); @@ -84,10 +81,11 @@ const Playground: React.FC = ({ const scopeKeys = Object.keys(scope); // convert scopeKeys to string values const scopeValues = scopeKeys.map((key) => { - return { [key]: `${key}` }; + return {[key]: `${key}`}; }); + // add 'React' to scopeValues - scopeValues.push({ React: 'React' }); + scopeValues.push({React: "React"}); // convert scopeValues to object const imports = Object.assign({}, ...scopeValues); @@ -95,6 +93,7 @@ const Playground: React.FC = ({ if (Object.keys(files).length === 1) { // get first item from files const file = Object.values(files)[0] as string; + code = transformCode(file, imports); } // else if multiple files @@ -102,20 +101,17 @@ const Playground: React.FC = ({ // get files with its code Object.entries(files).forEach(([fileName, fileCode]) => { //only files with .js can processes by react-live - if (!fileName.includes('.js')) { + if (!fileName.includes(".js")) { return; } const componentName = getFileName(fileName); - const transformedCode = transformCode( - fileCode as string, - imports, - componentName - ); + const transformedCode = transformCode(fileCode as string, imports, componentName); + // add to filesCode filesCode.push({ fileName, - code: transformedCode + code: transformedCode, }); }); @@ -127,6 +123,7 @@ const Playground: React.FC = ({ if (b.code.includes(getFileName(a.fileName))) { return -1; } + return 0; }); @@ -134,38 +131,33 @@ const Playground: React.FC = ({ } } - noInline = code.includes('render'); + noInline = code.includes("render"); return ( <> - {(title || desc) && } + {(title || desc) && <Title desc={desc} title={title} />} <Box className="playground" css={{ - w: '100%', - mb: '$xl', - ov: 'auto' + w: "100%", + mb: "$xl", + ov: "auto", }} > {isSanpackEditor ? ( <DynamicSandpack files={files} - showPreview={showSandpackPreview} highlightedLines={highlightedLines} + showPreview={showSandpackPreview} > - <LiveCode - noInline={noInline} - showEditor={false} - code={code} - overflow={overflow} - /> + <LiveCode code={code} noInline={noInline} overflow={overflow} showEditor={false} /> </DynamicSandpack> ) : ( <DynamicLive - showEditor={showEditor} - initialEditorOpen={initialEditorOpen} code={code} + initialEditorOpen={initialEditorOpen} overflow={overflow} + showEditor={showEditor} /> )} </Box> diff --git a/apps/docs/src/components/playground/title.tsx b/apps/docs/src/components/playground/title.tsx index 01e42f9ca5..cff24ba603 100644 --- a/apps/docs/src/components/playground/title.tsx +++ b/apps/docs/src/components/playground/title.tsx @@ -1,8 +1,8 @@ -import React from 'react'; -import withDefaults from '@utils/with-defaults'; -import { Anchor } from '@components'; -import ReactMarkdown from 'react-markdown'; -import { kebabCase, isString } from 'lodash'; +import React from "react"; +import withDefaults from "@utils/with-defaults"; +import {Anchor} from "@components"; +import ReactMarkdown from "react-markdown"; +import {kebabCase, isString} from "lodash"; interface Props { title: React.ReactNode | string; @@ -10,18 +10,18 @@ interface Props { } const defaultProps = { - desc: '' + desc: "", }; export type TitleProps = Props & typeof defaultProps; -const Title: React.FC<TitleProps> = ({ title, desc }) => { +const Title: React.FC<TitleProps> = ({title, desc}) => { return ( <> <h3 - id={`${isString(title) && kebabCase(title)}`} - data-name={title} className="linked-heading" + data-name={title} + id={`${isString(title) && kebabCase(title)}`} > <Anchor>{title}</Anchor> </h3> diff --git a/apps/docs/src/components/playground/utils.ts b/apps/docs/src/components/playground/utils.ts index 7473331c4c..3dc89e2b22 100644 --- a/apps/docs/src/components/playground/utils.ts +++ b/apps/docs/src/components/playground/utils.ts @@ -1,25 +1,26 @@ -import { get } from 'lodash'; -import { FileCode } from './types'; +import {get} from "lodash"; + +import {FileCode} from "./types"; const importRegex = /^(import)\s(?!type(of\s|\s)(?!from)).*?$/gm; const exportDefaultRegex = /export\s+default\s+function\s+\w+\s*\(\s*\)\s*\{/; -export const transformCode = (code: string, imports = {}, compName = 'App') => { +export const transformCode = (code: string, imports = {}, compName = "App") => { let cleanedCode = code .replace(importRegex, (match) => { // get component name from the match ex. "import { Table } from '@nextui-org/react'" - const componentName = match.match(/\w+/g)?.[1] || ''; + const componentName = match.match(/\w+/g)?.[1] || ""; const matchingImport = get(imports, componentName); if (matchingImport) { // remove the matching import - return ''; + return ""; } // if match includes './' or '../' then remove it - if (match.includes('./') || match.includes('../')) { - return ''; + if (match.includes("./") || match.includes("../")) { + return ""; } return match; @@ -28,25 +29,27 @@ export const transformCode = (code: string, imports = {}, compName = 'App') => { // replace match with const Name = () => ( return `const ${compName} = () => {`; }) - .replace('export', ''); + .replace("export", ""); // add render(<App/>) to cleanedClode if has const App = () => { if (cleanedCode.includes(`const App = () => {`)) { cleanedCode = `${cleanedCode}\nrender(<${compName}/>);`; } // delete comments from the code - cleanedCode = cleanedCode.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, ''); + cleanedCode = cleanedCode.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, ""); + return cleanedCode; }; export const joinCode = (filesCode: FileCode[]) => { // join all the code - const code = filesCode.reduce((acc, { code }) => { + const code = filesCode.reduce((acc, {code}) => { return `${acc}${code}`; - }, ''); + }, ""); + return code; }; export const getFileName = (filePath: string) => { - return filePath?.split('.')?.[0]?.replace(/\W/g, ''); + return filePath?.split(".")?.[0]?.replace(/\W/g, ""); }; diff --git a/apps/docs/src/components/primitives/index.ts b/apps/docs/src/components/primitives/index.ts index f80bc80024..34a1311e07 100644 --- a/apps/docs/src/components/primitives/index.ts +++ b/apps/docs/src/components/primitives/index.ts @@ -1,138 +1,138 @@ -import { styled, Link } from '@nextui-org/react'; +import {styled, Link} from "@nextui-org/react"; -export const Title = styled('h1', { - display: 'inline', - fontWeight: '$bold', - color: '$text', - lh: '1.2', - fs: '2.5rem', +export const Title = styled("h1", { + display: "inline", + fontWeight: "$bold", + color: "$text", + lh: "1.2", + fs: "2.5rem", mb: 0, - '@sm': { - fs: '3rem' + "@sm": { + fs: "3rem", }, - '@lg': { - fs: '3.5rem' + "@lg": { + fs: "3.5rem", }, - '&::selection': { - WebkitTextFillColor: '$colors$text' + "&::selection": { + WebkitTextFillColor: "$colors$text", }, variants: { color: { violet: { - textGradient: '180deg, #FF1CF7 25%, #b249f8 100%' + textGradient: "180deg, #FF1CF7 25%, #b249f8 100%", }, warning: { - textGradient: '180deg, #f36534 25%, #F69F27 100%' + textGradient: "180deg, #f36534 25%, #F69F27 100%", }, blue: { - textGradient: '180deg, #5EA2EF 25%, #0072F5 100%' + textGradient: "180deg, #5EA2EF 25%, #0072F5 100%", }, cyan: { - textGradient: '180deg, #00b7fa 25%, #01cfea 100%' + textGradient: "180deg, #00b7fa 25%, #01cfea 100%", }, green: { - textGradient: '180deg, #6FEE8D 25%, #17c964 100%' + textGradient: "180deg, #6FEE8D 25%, #17c964 100%", }, pink: { - textGradient: '180deg, #FF4ECD 25%, #F21361 100%' - } + textGradient: "180deg, #FF4ECD 25%, #F21361 100%", + }, }, fullWidth: { true: { - display: 'block', - width: '100%' - } - } - } + display: "block", + width: "100%", + }, + }, + }, }); -export const Subtitle = styled('p', { - pl: '$1', - fs: '$xl', - fontWeight: '$medium', - color: '$accents7', - display: 'block', - mw: '100%', - width: '100%', - '@sm': { - mw: '50%' - } +export const Subtitle = styled("p", { + pl: "$1", + fs: "$xl", + fontWeight: "$medium", + color: "$accents7", + display: "block", + mw: "100%", + width: "100%", + "@sm": { + mw: "50%", + }, }); -export const Section = styled('section', { - zIndex: '$2', - width: '100%' +export const Section = styled("section", { + zIndex: "$2", + width: "100%", }); -export const Box = styled('div', { +export const Box = styled("div", { // Reset - boxSizing: 'border-box' + boxSizing: "border-box", }); export const BlockLink = styled(Link, { - mt: '$12', - py: '$2', - px: '$6', - br: '$pill', - bg: '$blockLinkBackground', - fontSize: '$xs', - color: '$blockLinkColor', - fontWeight: '$medium', - '&:hover': { - bg: '$blockLinkHoverBackground' + mt: "$12", + py: "$2", + px: "$6", + br: "$pill", + bg: "$blockLinkBackground", + fontSize: "$xs", + color: "$blockLinkColor", + fontWeight: "$medium", + "&:hover": { + bg: "$blockLinkHoverBackground", }, variants: { color: { default: { - color: '$blockLinkColor' + color: "$blockLinkColor", }, green: { - color: '$green800', - bg: '$green100', - '&:hover': { - bg: '$green300' - } + color: "$green800", + bg: "$green100", + "&:hover": { + bg: "$green300", + }, }, pink: { - color: '$pink600', - bg: '$pink100', - '&:hover': { - bg: '$pink300' - } + color: "$pink600", + bg: "$pink100", + "&:hover": { + bg: "$pink300", + }, }, violet: { - color: '$purple600', - bg: '$purple100', - '&:hover': { - bg: '$purple300' - } + color: "$purple600", + bg: "$purple100", + "&:hover": { + bg: "$purple300", + }, }, blue: { - color: '$blue700', - bg: '$blue100', - '&:hover': { - bg: '$blue300' - } - } - } + color: "$blue700", + bg: "$blue100", + "&:hover": { + bg: "$blue300", + }, + }, + }, }, defaultVariants: { - color: 'default' - } + color: "default", + }, }); -export const StyledCardBlur = styled('div', { - background: '$accents1', - boxShadow: '$sm', - borderRadius: '$lg', - display: 'flex', - flexDirection: 'column', - p: '$8', - bg: '$backgroundContrast', - '@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none))': { - bf: 'saturate(180%) blur(14px)', - bg: 'rgba(255, 255, 255, 0.05)' - } +export const StyledCardBlur = styled("div", { + background: "$accents1", + boxShadow: "$sm", + borderRadius: "$lg", + display: "flex", + flexDirection: "column", + p: "$8", + bg: "$backgroundContrast", + "@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none))": { + bf: "saturate(180%) blur(14px)", + bg: "rgba(255, 255, 255, 0.05)", + }, }); -export const StyledImg = styled('img', {}); +export const StyledImg = styled("img", {}); diff --git a/apps/docs/src/components/sandpack/bugreport-button.tsx b/apps/docs/src/components/sandpack/bugreport-button.tsx index 8a4d999e10..24ff3658d4 100644 --- a/apps/docs/src/components/sandpack/bugreport-button.tsx +++ b/apps/docs/src/components/sandpack/bugreport-button.tsx @@ -1,30 +1,31 @@ -import React from 'react'; -import { useRouter } from 'next/router'; -import { capitalize, join } from 'lodash'; -import { Tooltip } from '@nextui-org/react'; -import { Box } from '@primitives'; -import BugIcon from '../icons/bug'; -import { ISSUE_REPORT_URL } from '../../lib/github/constants'; +import React from "react"; +import {useRouter} from "next/router"; +import {capitalize, join} from "lodash"; +import {Tooltip} from "@nextui-org/react"; +import {Box} from "@primitives"; + +import BugIcon from "../icons/bug"; +import {ISSUE_REPORT_URL} from "../../lib/github/constants"; const BugReportButton = () => { const router = useRouter(); - const slug = router.query.slug || ''; + const slug = router.query.slug || ""; const componentTitle = Array.isArray(slug) ? join( slug.map((s) => capitalize(s)), - '/' + "/", ) : capitalize(slug); const linkHandler = (event: React.MouseEvent) => { event.stopPropagation(); event.preventDefault(); - Object.assign(document.createElement('a'), { - target: '_blank', - rel: 'noopener noreferrer', - href: `${ISSUE_REPORT_URL}${componentTitle}` + Object.assign(document.createElement("a"), { + target: "_blank", + rel: "noopener noreferrer", + href: `${ISSUE_REPORT_URL}${componentTitle}`, }).click(); }; @@ -33,22 +34,22 @@ const BugReportButton = () => { hideArrow content="Report a bug" triggerCss={{ - cursor: 'pointer', - ml: '$2', - '&:hover': { - opacity: 0.8 - } + cursor: "pointer", + ml: "$2", + "&:hover": { + opacity: 0.8, + }, }} > <Box as="a" - title="Report a bug" + href={`${ISSUE_REPORT_URL}${componentTitle}`} rel="noopener noreferrer" target="_blank" + title="Report a bug" onClick={linkHandler} - href={`${ISSUE_REPORT_URL}${componentTitle}`} > - <BugIcon size={20} fill="var(--nextui-colors-codeCopyIconColor)" /> + <BugIcon fill="var(--nextui-colors-codeCopyIconColor)" size={20} /> </Box> </Tooltip> ); diff --git a/apps/docs/src/components/sandpack/code-viewer.tsx b/apps/docs/src/components/sandpack/code-viewer.tsx index 727df9fc5e..6c770a91d7 100644 --- a/apps/docs/src/components/sandpack/code-viewer.tsx +++ b/apps/docs/src/components/sandpack/code-viewer.tsx @@ -1,17 +1,19 @@ -import * as React from 'react'; +import type {SandpackInitMode} from "@codesandbox/sandpack-react"; + +import * as React from "react"; import { FileTabs, CodeEditor, useSandpack, useActiveCode, - SandpackStack -} from '@codesandbox/sandpack-react'; -import type { SandpackInitMode } from '@codesandbox/sandpack-react'; -import scrollIntoView from 'scroll-into-view-if-needed'; -import { Decorators } from './types'; -import { getId } from '@utils/collections'; -import { Box } from '@primitives'; -import { StyledShoreMoreButton } from './styles'; + SandpackStack, +} from "@codesandbox/sandpack-react"; +import scrollIntoView from "scroll-into-view-if-needed"; +import {getId} from "@utils/collections"; +import {Box} from "@primitives"; + +import {Decorators} from "./types"; +import {StyledShoreMoreButton} from "./styles"; export interface CodeViewerProps { showTabs?: boolean; @@ -37,29 +39,21 @@ export interface CodeViewerProps { */ const SandpackCodeViewer = React.forwardRef<any, CodeViewerProps>( ( - { - showTabs, - code: propCode, - decorators, - initMode, - showLineNumbers, - wrapContent, - containerRef - }, - ref + {showTabs, code: propCode, decorators, initMode, showLineNumbers, wrapContent, containerRef}, + ref, ) => { - const { sandpack } = useSandpack(); - const { code } = useActiveCode(); + const {sandpack} = useSandpack(); + const {code} = useActiveCode(); - const { activePath } = sandpack; + const {activePath} = sandpack; const [isExpanded, setIsExpanded] = React.useState(false); // hack to make sure we re-render the code editor and chenge current file // TODO: open an issue on sandpack-react const [internalKey, setInternalKey] = React.useState(getId()); - const lineCountRef = React.useRef<{ [key: string]: number }>({}); + const lineCountRef = React.useRef<{[key: string]: number}>({}); if (!lineCountRef.current[activePath]) { - lineCountRef.current[activePath] = code.split('\n').length; + lineCountRef.current[activePath] = code.split("\n").length; } const shouldShowTabs = showTabs ?? sandpack.openPaths.length > 1; @@ -69,7 +63,7 @@ const SandpackCodeViewer = React.forwardRef<any, CodeViewerProps>( React.useEffect(() => { if (containerRef && containerRef?.current !== null && isExpandable) { - containerRef.current.style.height = '350px'; + containerRef.current.style.height = "350px"; } }, [containerRef]); @@ -79,17 +73,19 @@ const SandpackCodeViewer = React.forwardRef<any, CodeViewerProps>( const handleExpand = () => { const nextIsExpanded = !isExpanded; + setIsExpanded(nextIsExpanded); if (containerRef && containerRef?.current !== null) { const container = containerRef?.current; + if (nextIsExpanded) { - container.style.height = 'auto'; + container.style.height = "auto"; } else { - container.style.height = '350px'; + container.style.height = "350px"; scrollIntoView(container, { - behavior: 'smooth', - scrollMode: 'if-needed', - block: 'center' + behavior: "smooth", + scrollMode: "if-needed", + block: "center", }); } } @@ -99,9 +95,9 @@ const SandpackCodeViewer = React.forwardRef<any, CodeViewerProps>( <SandpackStack> {shouldShowTabs ? <FileTabs /> : null} <CodeEditor - readOnly key={internalKey} ref={ref} + readOnly code={propCode || code} decorators={decorators} filePath={sandpack.activePath} @@ -111,17 +107,17 @@ const SandpackCodeViewer = React.forwardRef<any, CodeViewerProps>( wrapContent={wrapContent} /> {isExpandable && ( - <Box css={{ py: '$3', pl: 'var(--sp-space-4)' }}> + <Box css={{py: "$3", pl: "var(--sp-space-4)"}}> <StyledShoreMoreButton onClick={handleExpand}> - {isExpanded ? 'Show less' : 'Show more'} + {isExpanded ? "Show less" : "Show more"} </StyledShoreMoreButton> </Box> )} </SandpackStack> ); - } + }, ); -SandpackCodeViewer.displayName = 'SandpackCodeViewer'; +SandpackCodeViewer.displayName = "SandpackCodeViewer"; export default SandpackCodeViewer; diff --git a/apps/docs/src/components/sandpack/codesanbox-button.tsx b/apps/docs/src/components/sandpack/codesanbox-button.tsx index 3644201527..a6d778914f 100644 --- a/apps/docs/src/components/sandpack/codesanbox-button.tsx +++ b/apps/docs/src/components/sandpack/codesanbox-button.tsx @@ -1,16 +1,10 @@ -import React from 'react'; -import { UnstyledOpenInCodeSandboxButton } from '@codesandbox/sandpack-react'; -import { Tooltip } from '@nextui-org/react'; -import { Box } from '@primitives'; +import React from "react"; +import {UnstyledOpenInCodeSandboxButton} from "@codesandbox/sandpack-react"; +import {Tooltip} from "@nextui-org/react"; +import {Box} from "@primitives"; export const CSBIcon = (): React.ReactElement => ( - <svg - fill="none" - height="24" - width="24" - viewBox="0 0 18 18" - xmlns="http://www.w3.org/2000/svg" - > + <svg fill="none" height="24" viewBox="0 0 18 18" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M3.24284 5.11427L8.63639 2.17808C8.92945 2.01854 9.28432 2.02264 9.57361 2.18889L14.7726 5.17673C15.011 5.3137 15.1579 5.56762 15.1579 5.84251V12.1884C15.1579 12.4639 15.0103 12.7183 14.7711 12.8551L9.38463 15.9346C9.1466 16.0707 8.85406 16.0696 8.61711 15.9316L3.22361 12.7912C2.9874 12.6537 2.8421 12.4009 2.8421 12.1276V5.7887C2.8421 5.50747 2.99584 5.24873 3.24284 5.11427Z" /> <path clipRule="evenodd" @@ -33,23 +27,23 @@ const CodeSandboxButton = () => { hideArrow content="Open in CodeSandbox" triggerCss={{ - cursor: 'pointer', - ml: '$2', - '&:hover': { - opacity: 0.8 - } + cursor: "pointer", + ml: "$2", + "&:hover": { + opacity: 0.8, + }, }} > <Box as="span" title="Open in CodeSandbox"> <UnstyledOpenInCodeSandboxButton style={{ // reset button styles - background: 'none', - border: 'none', + background: "none", + border: "none", padding: 0, margin: 0, - outline: 'none', - cursor: 'pointer' + outline: "none", + cursor: "pointer", }} > <CSBIcon /> diff --git a/apps/docs/src/components/sandpack/copy-button.tsx b/apps/docs/src/components/sandpack/copy-button.tsx index 68d358aa5b..2c9dcf9ac9 100644 --- a/apps/docs/src/components/sandpack/copy-button.tsx +++ b/apps/docs/src/components/sandpack/copy-button.tsx @@ -1,20 +1,21 @@ -import React, { useState } from 'react'; -import { useSandpack } from '@codesandbox/sandpack-react'; -import { Tooltip, useClipboard } from '@nextui-org/react'; -import { Copy as CopyIcon } from '@components'; -import { Box } from '@primitives'; +import React, {useState} from "react"; +import {useSandpack} from "@codesandbox/sandpack-react"; +import {Tooltip, useClipboard} from "@nextui-org/react"; +import {Copy as CopyIcon} from "@components"; +import {Box} from "@primitives"; const CopyButton = () => { - const { copy } = useClipboard(); + const {copy} = useClipboard(); const [copied, setCopied] = useState(false); - const { sandpack } = useSandpack(); + const {sandpack} = useSandpack(); const copyHandler = (event: React.MouseEvent) => { event.stopPropagation(); event.preventDefault(); setCopied(true); const code = sandpack.files[sandpack.activePath].code; + copy(code); }; @@ -28,13 +29,13 @@ const CopyButton = () => { <Tooltip hideArrow className="action-tooltip" - content={copied ? 'Copied!' : 'Copy'} + content={copied ? "Copied!" : "Copy"} triggerCss={{ - cursor: 'pointer', - ml: '$3', - '&:hover': { - opacity: 0.8 - } + cursor: "pointer", + ml: "$3", + "&:hover": { + opacity: 0.8, + }, }} onVisibleChange={handleTooltipVisibleChange} > diff --git a/apps/docs/src/components/sandpack/index.ts b/apps/docs/src/components/sandpack/index.ts index 9068d989ce..5dc1f28f6f 100644 --- a/apps/docs/src/components/sandpack/index.ts +++ b/apps/docs/src/components/sandpack/index.ts @@ -1,9 +1,6 @@ -import Sandpack from './sandpack'; -export type { - SandpackFiles, - SandpackPredefinedTemplate -} from '@codesandbox/sandpack-react'; +import Sandpack from "./sandpack"; +export type {SandpackFiles, SandpackPredefinedTemplate} from "@codesandbox/sandpack-react"; -export type { HighlightedLines as SandpackHighlightedLines } from './types'; +export type {HighlightedLines as SandpackHighlightedLines} from "./types"; export default Sandpack; diff --git a/apps/docs/src/components/sandpack/language-selector.tsx b/apps/docs/src/components/sandpack/language-selector.tsx index 50b35045be..563a5ec5bd 100644 --- a/apps/docs/src/components/sandpack/language-selector.tsx +++ b/apps/docs/src/components/sandpack/language-selector.tsx @@ -1,8 +1,9 @@ -import React from 'react'; -import cn from 'classnames'; -import { SandpackPredefinedTemplate } from '@codesandbox/sandpack-react'; -import { TypescriptLogo, JavascriptLogo } from '@components'; -import { StyledPlaygroundButtons, StyledLanguageButton } from './styles'; +import React from "react"; +import cn from "classnames"; +import {SandpackPredefinedTemplate} from "@codesandbox/sandpack-react"; +import {TypescriptLogo, JavascriptLogo} from "@components"; + +import {StyledPlaygroundButtons, StyledLanguageButton} from "./styles"; interface Props { template: SandpackPredefinedTemplate; @@ -11,12 +12,10 @@ interface Props { export type LanguageSelectorProps = Props; -const LanguageSelector: React.FC<LanguageSelectorProps> = ({ - template, - onChange -}) => { +const LanguageSelector: React.FC<LanguageSelectorProps> = ({template, onChange}) => { const handleToggle = () => { - const newTemplate = template === 'react' ? 'react-ts' : 'react'; + const newTemplate = template === "react" ? "react-ts" : "react"; + onChange?.(newTemplate); }; @@ -24,15 +23,15 @@ const LanguageSelector: React.FC<LanguageSelectorProps> = ({ <StyledPlaygroundButtons bottom> <StyledLanguageButton onClick={handleToggle}> <JavascriptLogo - className={cn('sp-language-icon', { - 'sp-language-icon--selected': template === 'react' + className={cn("sp-language-icon", { + "sp-language-icon--selected": template === "react", })} /> </StyledLanguageButton> <StyledLanguageButton onClick={handleToggle}> <TypescriptLogo - className={cn('sp-language-icon', { - 'sp-language-icon--selected': template === 'react-ts' + className={cn("sp-language-icon", { + "sp-language-icon--selected": template === "react-ts", })} /> </StyledLanguageButton> diff --git a/apps/docs/src/components/sandpack/preview.tsx b/apps/docs/src/components/sandpack/preview.tsx index 2132c87c21..c3bee63408 100644 --- a/apps/docs/src/components/sandpack/preview.tsx +++ b/apps/docs/src/components/sandpack/preview.tsx @@ -1,24 +1,20 @@ -import * as React from 'react'; -import { useClasser } from '@code-hike/classer'; -import cn from 'classnames'; +import * as React from "react"; +import {useClasser} from "@code-hike/classer"; +import cn from "classnames"; import { LoadingOverlay, SandpackStack, Navigator, useSandpack, OpenInCodeSandboxButton, - ErrorOverlay -} from '@codesandbox/sandpack-react'; -import { - ViewportOrientation, - ViewportSize, - computeViewportSize, - generateRandomId -} from './utils'; -import { useTheme } from '@nextui-org/react'; -import { RefreshButton } from './refresh-button'; -import { StyledPreviewIframe } from './sandpack.styles'; -import { darkTheme, lightTheme } from '@theme/shared'; + ErrorOverlay, +} from "@codesandbox/sandpack-react"; +import {useTheme} from "@nextui-org/react"; +import {darkTheme, lightTheme} from "@theme/shared"; + +import {ViewportOrientation, ViewportSize, computeViewportSize, generateRandomId} from "./utils"; +import {RefreshButton} from "./refresh-button"; +import {StyledPreviewIframe} from "./sandpack.styles"; export interface PreviewProps { customStyle?: React.CSSProperties; @@ -39,26 +35,25 @@ export const Preview = ({ showRefreshButton = true, showOpenInCodeSandbox = true, showSandpackErrorOverlay = true, - viewportSize = 'auto', - viewportOrientation = 'portrait' + viewportSize = "auto", + viewportOrientation = "portrait", }: PreviewProps): JSX.Element => { - const { sandpack, listen } = useSandpack(); - const [iframeComputedHeight, setComputedAutoHeight] = - React.useState<number | null>(null); + const {sandpack, listen} = useSandpack(); + const [iframeComputedHeight, setComputedAutoHeight] = React.useState<number | null>(null); const { status, registerBundler, unregisterBundler, errorScreenRegisteredRef, openInCSBRegisteredRef, - loadingScreenRegisteredRef + loadingScreenRegisteredRef, } = sandpack; - const c = useClasser('sp'); + const c = useClasser("sp"); const clientId = React.useRef<string>(generateRandomId()); const iframeRef = React.useRef<HTMLIFrameElement | null>(null); - const { isDark } = useTheme(); + const {isDark} = useTheme(); // SandpackPreview immediately registers the custom screens/components so the bundler does not render any of them openInCSBRegisteredRef.current = true; @@ -73,7 +68,7 @@ export const Preview = ({ registerBundler(iframeElement, clientIdValue); const unsubscribe = listen((message) => { - if (message.type === 'resize') { + if (message.type === "resize") { setComputedAutoHeight(message.height); } }, clientIdValue); @@ -86,6 +81,7 @@ export const Preview = ({ React.useEffect(() => { const iframeElement = iframeRef.current; + if (!iframeElement) { return; } @@ -117,35 +113,28 @@ export const Preview = ({ <SandpackStack customStyle={{ ...customStyle, - ...viewportStyle + ...viewportStyle, }} > - {showNavigator ? ( - <Navigator clientId={clientId.current} onURLChange={handleNewURL} /> - ) : null} + {showNavigator ? <Navigator clientId={clientId.current} onURLChange={handleNewURL} /> : null} - <div className={c('preview-container')}> + <div className={c("preview-container")}> <StyledPreviewIframe ref={iframeRef} - className={cn( - 'sp-preview-iframe', - isDark ? darkTheme.className : lightTheme.className - )} + className={cn("sp-preview-iframe", isDark ? darkTheme.className : lightTheme.className)} style={{ // set height based on the content only in auto mode // and when the computed height was returned by the bundler height: - viewportSize === 'auto' && iframeComputedHeight - ? iframeComputedHeight - : undefined + viewportSize === "auto" && iframeComputedHeight ? iframeComputedHeight : undefined, }} title="Sandpack Preview" /> {showSandpackErrorOverlay ? <ErrorOverlay /> : null} - <div className={c('preview-actions')}> - {!showNavigator && showRefreshButton && status === 'running' ? ( + <div className={c("preview-actions")}> + {!showNavigator && showRefreshButton && status === "running" ? ( <RefreshButton clientId={clientId.current} /> ) : null} diff --git a/apps/docs/src/components/sandpack/refresh-button.tsx b/apps/docs/src/components/sandpack/refresh-button.tsx index 1e82c64f0f..feb0a9e087 100644 --- a/apps/docs/src/components/sandpack/refresh-button.tsx +++ b/apps/docs/src/components/sandpack/refresh-button.tsx @@ -1,7 +1,6 @@ -import { useClasser } from '@code-hike/classer'; -import * as React from 'react'; - -import { useSandpackNavigation } from '@codesandbox/sandpack-react'; +import {useClasser} from "@code-hike/classer"; +import * as React from "react"; +import {useSandpackNavigation} from "@codesandbox/sandpack-react"; export const RefreshIcon = (): React.ReactElement => ( <svg @@ -26,18 +25,16 @@ interface RefreshButtonProps { /** * @category Components */ -export const RefreshButton = ({ - clientId -}: RefreshButtonProps): JSX.Element => { - const { refresh } = useSandpackNavigation(clientId); - const c = useClasser('sp'); +export const RefreshButton = ({clientId}: RefreshButtonProps): JSX.Element => { + const {refresh} = useSandpackNavigation(clientId); + const c = useClasser("sp"); return ( <button - className={c('button', 'icon-standalone')} - onClick={refresh} + className={c("button", "icon-standalone")} title="Refresh Sandpack" type="button" + onClick={refresh} > <RefreshIcon /> </button> diff --git a/apps/docs/src/components/sandpack/sandpack.styles.ts b/apps/docs/src/components/sandpack/sandpack.styles.ts index 09292bcba1..bb8681e76b 100644 --- a/apps/docs/src/components/sandpack/sandpack.styles.ts +++ b/apps/docs/src/components/sandpack/sandpack.styles.ts @@ -1,5 +1,5 @@ -import { styled } from '@nextui-org/react'; +import {styled} from "@nextui-org/react"; -export const StyledPreviewIframe = styled('iframe', { - bg: '$background' +export const StyledPreviewIframe = styled("iframe", { + bg: "$background", }); diff --git a/apps/docs/src/components/sandpack/sandpack.tsx b/apps/docs/src/components/sandpack/sandpack.tsx index 259e6d7d04..142b1edde7 100644 --- a/apps/docs/src/components/sandpack/sandpack.tsx +++ b/apps/docs/src/components/sandpack/sandpack.tsx @@ -1,24 +1,25 @@ -import React, { useMemo, useRef } from 'react'; +import React, {useMemo, useRef} from "react"; import { SandpackProvider, SandpackLayout, SandpackFiles, SandpackPredefinedTemplate, - SandpackPreview -} from '@codesandbox/sandpack-react'; -import { Grid } from '@nextui-org/react'; -import withDefaults from '@utils/with-defaults'; -import useLocalStorage from '@hooks/use-local-storage'; -import { getHighlightedLines, getFileName } from './utils'; -import CopyButton from './copy-button'; -import { entry } from './entry'; -import { nextuiTheme } from './themes'; -import CodeSandboxButton from './codesanbox-button'; -import BugReportButton from './bugreport-button'; -import { StyledPlaygroundButtons } from './styles'; -import LanguageSelector from './language-selector'; -import { HighlightedLines } from './types'; -import CodeViewer from './code-viewer'; + SandpackPreview, +} from "@codesandbox/sandpack-react"; +import {Grid} from "@nextui-org/react"; +import withDefaults from "@utils/with-defaults"; +import useLocalStorage from "@hooks/use-local-storage"; + +import {getHighlightedLines, getFileName} from "./utils"; +import CopyButton from "./copy-button"; +import {entry} from "./entry"; +import {nextuiTheme} from "./themes"; +import CodeSandboxButton from "./codesanbox-button"; +import BugReportButton from "./bugreport-button"; +import {StyledPlaygroundButtons} from "./styles"; +import LanguageSelector from "./language-selector"; +import {HighlightedLines} from "./types"; +import CodeViewer from "./code-viewer"; interface Props { files?: SandpackFiles; @@ -38,7 +39,7 @@ const defaultProps = { showOpenInCodeSandbox: true, showReportBug: true, showCopyCode: true, - template: 'react' + template: "react", }; export type SandpackProps = Props & typeof defaultProps; @@ -52,38 +53,37 @@ const Sandpack: React.FC<React.PropsWithChildren<SandpackProps>> = ({ showReportBug, showOpenInCodeSandbox, showCopyCode, - template + template, }) => { // once the user select a template we store it in local storage - const [currentTemplate, setCurrentTemplate] = - useLocalStorage<SandpackPredefinedTemplate>('currentTemplate', template); + const [currentTemplate, setCurrentTemplate] = useLocalStorage<SandpackPredefinedTemplate>( + "currentTemplate", + template, + ); const editorContainerRef = useRef<HTMLDivElement>(null); const hasTypescript = Object.keys(files).some( - (file) => file.includes('.ts') || file.includes('.tsx') + (file) => file.includes(".ts") || file.includes(".tsx"), ); const decorators = getHighlightedLines(highlightedLines, currentTemplate); const sandpackTemplate = useMemo( - () => - currentTemplate === 'react-ts' && hasTypescript - ? currentTemplate - : 'react', - [currentTemplate, hasTypescript] + () => (currentTemplate === "react-ts" && hasTypescript ? currentTemplate : "react"), + [currentTemplate, hasTypescript], ); // map current template to its mime type const mimeType = useMemo( - () => (sandpackTemplate === 'react-ts' ? '.ts' : '.js'), - [sandpackTemplate] + () => (sandpackTemplate === "react-ts" ? ".ts" : ".js"), + [sandpackTemplate], ); // get entry file by current template const entryFile = useMemo( - () => (sandpackTemplate === 'react-ts' ? '/index.tsx' : '/index.js'), - [sandpackTemplate] + () => (sandpackTemplate === "react-ts" ? "/index.tsx" : "/index.js"), + [sandpackTemplate], ); // filter files by current template @@ -92,6 +92,7 @@ const Sandpack: React.FC<React.PropsWithChildren<SandpackProps>> = ({ // @ts-ignore acc[key] = files[key]; } + return acc; }, {}); @@ -102,89 +103,86 @@ const Sandpack: React.FC<React.PropsWithChildren<SandpackProps>> = ({ const bFile = files[b] as string; const aName = getFileName(a); const bName = getFileName(b); + if (aFile?.includes(bName)) { return -1; } if (bFile.includes(aName)) { return 1; } + return 0; }) .reduce((acc, key) => { return { ...acc, - [key]: files[key] + [key]: files[key], }; }, {}); return ( <SandpackProvider skipEval - template={sandpackTemplate} customSetup={{ files: { ...sortedFiles, [entryFile]: { code: entry, - hidden: true - } + hidden: true, + }, }, entry: entryFile, dependencies: { - '@nextui-org/react': 'latest' - } + "@nextui-org/react": "latest", + }, }} + template={sandpackTemplate} > <SandpackLayout - theme={nextuiTheme} style={{ // @ts-ignore - '--sp-border-radius': 'var(--nextui-radii-lg)', - '--sp-colors-fg-inactive': 'transparent' + "--sp-border-radius": "var(--nextui-radii-lg)", + "--sp-colors-fg-inactive": "transparent", }} + theme={nextuiTheme} > - <Grid.Container css={{ maxWidth: '100%' }}> + <Grid.Container css={{maxWidth: "100%"}}> <Grid - xs={12} css={{ - height: showPreview ? '350px' : 'auto' + height: showPreview ? "350px" : "auto", }} + xs={12} > {showPreview ? <SandpackPreview /> : children} </Grid> <Grid ref={editorContainerRef} - xs={12} css={{ - maxHeight: 'auto', - position: 'relative', - '.sp-playground-buttons': { - opacity: 0 + maxHeight: "auto", + position: "relative", + ".sp-playground-buttons": { + opacity: 0, + }, + "&:hover": { + ".sp-playground-buttons": { + opacity: 1, + }, }, - '&:hover': { - '.sp-playground-buttons': { - opacity: 1 - } + ".sp-stack": { + background: "var(--sp-colors-bg-default)", + borderRadius: "$lg", + overflowX: "auto", }, - '.sp-stack': { - background: 'var(--sp-colors-bg-default)', - borderRadius: '$lg', - overflowX: 'auto' + ".sp-cm": { + p: "var(--sp-space-4)", }, - '.sp-cm': { - p: 'var(--sp-space-4)' + ".cm-scroller::-webkit-scrollbar": { + width: "0px", }, - '.cm-scroller::-webkit-scrollbar': { - width: '0px' - } }} + xs={12} > - {showEditor && ( - <CodeViewer - containerRef={editorContainerRef} - decorators={decorators} - /> - )} + {showEditor && <CodeViewer containerRef={editorContainerRef} decorators={decorators} />} <StyledPlaygroundButtons className="sp-playground-buttons"> {showReportBug && <BugReportButton />} {showCopyCode && <CopyButton />} @@ -192,10 +190,7 @@ const Sandpack: React.FC<React.PropsWithChildren<SandpackProps>> = ({ </StyledPlaygroundButtons> {hasTypescript && sandpackTemplate && ( - <LanguageSelector - template={sandpackTemplate} - onChange={setCurrentTemplate} - /> + <LanguageSelector template={sandpackTemplate} onChange={setCurrentTemplate} /> )} </Grid> </Grid.Container> diff --git a/apps/docs/src/components/sandpack/styles.ts b/apps/docs/src/components/sandpack/styles.ts index f2ecf1aedf..6ecf21fb00 100644 --- a/apps/docs/src/components/sandpack/styles.ts +++ b/apps/docs/src/components/sandpack/styles.ts @@ -1,49 +1,49 @@ -import { styled } from '@nextui-org/react'; +import {styled} from "@nextui-org/react"; -export const StyledPlaygroundButtons = styled('div', { - transition: '$default', - position: 'absolute', - right: '$4', - top: '$7', - d: 'flex', - jc: 'center', - ai: 'center', - '.sp-language-icon': { - transition: '$default', - fill: 'var(--sp-colors-fg-default)', - ml: '$2', - '&:hover': { - opacity: 0.8 - } +export const StyledPlaygroundButtons = styled("div", { + transition: "$default", + position: "absolute", + right: "$4", + top: "$7", + d: "flex", + jc: "center", + ai: "center", + ".sp-language-icon": { + transition: "$default", + fill: "var(--sp-colors-fg-default)", + ml: "$2", + "&:hover": { + opacity: 0.8, + }, }, - '.sp-language-icon--selected': { - fill: 'var(--sp-colors-fg-active)' + ".sp-language-icon--selected": { + fill: "var(--sp-colors-fg-active)", }, variants: { bottom: { true: { - top: 'auto', - right: '$5', - bottom: '$7' - } - } - } + top: "auto", + right: "$5", + bottom: "$7", + }, + }, + }, }); -export const StyledLanguageButton = styled('button', { +export const StyledLanguageButton = styled("button", { // reset styles m: 0, p: 0, - bg: 'transparent', - border: 'none', - outline: 'none', - cursor: 'pointer' + bg: "transparent", + border: "none", + outline: "none", + cursor: "pointer", }); export const StyledShoreMoreButton = styled(StyledLanguageButton, { - color: 'var(--sp-colors-fg-default)', - transition: '$default', - '&:hover': { - color: 'var(--sp-colors-fg-active)' - } + color: "var(--sp-colors-fg-default)", + transition: "$default", + "&:hover": { + color: "var(--sp-colors-fg-active)", + }, }); diff --git a/apps/docs/src/components/sandpack/themes.ts b/apps/docs/src/components/sandpack/themes.ts index 2a21b304fb..14e87b8194 100644 --- a/apps/docs/src/components/sandpack/themes.ts +++ b/apps/docs/src/components/sandpack/themes.ts @@ -1,35 +1,35 @@ -import { SandpackTheme } from '@codesandbox/sandpack-react'; +import {SandpackTheme} from "@codesandbox/sandpack-react"; export const nextuiTheme: SandpackTheme = { palette: { - activeText: '#F4F4F4', - defaultText: 'var(--nextui-colors-codeComment)', - inactiveText: '#e4e7eb', - activeBackground: '#A258DF2b', - defaultBackground: 'var(--nextui-colors-codeBackground)', - inputBackground: '#ffffff', - accent: '#A258DF', - errorBackground: '#ffcdca', - errorForeground: '#811e18' + activeText: "#F4F4F4", + defaultText: "var(--nextui-colors-codeComment)", + inactiveText: "#e4e7eb", + activeBackground: "#A258DF2b", + defaultBackground: "var(--nextui-colors-codeBackground)", + inputBackground: "#ffffff", + accent: "#A258DF", + errorBackground: "#ffcdca", + errorForeground: "#811e18", }, syntax: { - plain: '#F4F4F4', + plain: "#F4F4F4", comment: { - color: 'var(--nextui-colors-codeComment)', - fontStyle: 'italic' + color: "var(--nextui-colors-codeComment)", + fontStyle: "italic", }, - keyword: '#c678dd', - tag: '#E5C07B', - punctuation: '#F4F4F4', - definition: '#F4F4F4', - property: '#F4F4F4', - static: 'var(--nextui-colors-yellow600)', - string: '#98C379' + keyword: "#c678dd", + tag: "#E5C07B", + punctuation: "#F4F4F4", + definition: "#F4F4F4", + property: "#F4F4F4", + static: "var(--nextui-colors-yellow600)", + string: "#98C379", }, typography: { - bodyFont: 'var(--nextui-fonts-sans)', - monoFont: 'var(--nextui-fonts-mono)', - fontSize: '14px', - lineHeight: '1.4' - } + bodyFont: "var(--nextui-fonts-sans)", + monoFont: "var(--nextui-fonts-mono)", + fontSize: "14px", + lineHeight: "1.4", + }, }; diff --git a/apps/docs/src/components/sandpack/types.ts b/apps/docs/src/components/sandpack/types.ts index c1010c144e..c60f768641 100644 --- a/apps/docs/src/components/sandpack/types.ts +++ b/apps/docs/src/components/sandpack/types.ts @@ -1,4 +1,4 @@ -import { SandpackPredefinedTemplate } from '@codesandbox/sandpack-react'; +import {SandpackPredefinedTemplate} from "@codesandbox/sandpack-react"; export type HighlightedLines = | string @@ -6,7 +6,7 @@ export type HighlightedLines = [key in SandpackPredefinedTemplate]?: string; }; -export type Language = 'typescript' | 'javascript'; +export type Language = "typescript" | "javascript"; export type HighlightedLine = { start?: number | string; diff --git a/apps/docs/src/components/sandpack/utils.ts b/apps/docs/src/components/sandpack/utils.ts index 339c527415..1fde9441f3 100644 --- a/apps/docs/src/components/sandpack/utils.ts +++ b/apps/docs/src/components/sandpack/utils.ts @@ -1,67 +1,55 @@ -import { SandpackPredefinedTemplate } from '@components'; -import { HighlightedLines, HighlightedLine } from './types'; - -export type ViewportSizePreset = - | 'iPhone X' - | 'Pixel 2' - | 'iPad' - | 'Moto G4' - | 'Surface Duo'; - -export type ViewportSize = - | ViewportSizePreset - | 'auto' - | { width: number; height: number }; - -export type ViewportOrientation = 'portrait' | 'landscape'; - -const VIEWPORT_SIZE_PRESET_MAP: Record< - ViewportSizePreset, - { x: number; y: number } -> = { - 'iPhone X': { x: 375, y: 812 }, - iPad: { x: 768, y: 1024 }, - 'Pixel 2': { x: 411, y: 731 }, - 'Moto G4': { x: 360, y: 640 }, - 'Surface Duo': { x: 540, y: 720 } +import {SandpackPredefinedTemplate} from "@components"; + +import {HighlightedLines, HighlightedLine} from "./types"; + +export type ViewportSizePreset = "iPhone X" | "Pixel 2" | "iPad" | "Moto G4" | "Surface Duo"; + +export type ViewportSize = ViewportSizePreset | "auto" | {width: number; height: number}; + +export type ViewportOrientation = "portrait" | "landscape"; + +const VIEWPORT_SIZE_PRESET_MAP: Record<ViewportSizePreset, {x: number; y: number}> = { + "iPhone X": {x: 375, y: 812}, + iPad: {x: 768, y: 1024}, + "Pixel 2": {x: 411, y: 731}, + "Moto G4": {x: 360, y: 640}, + "Surface Duo": {x: 540, y: 720}, }; -export const generateRandomId = (): string => - Math.floor(Math.random() * 10000).toString(); +export const generateRandomId = (): string => Math.floor(Math.random() * 10000).toString(); export const computeViewportSize = ( viewport: ViewportSize, - orientation: ViewportOrientation -): { width?: number; height?: number } => { - if (viewport === 'auto') { + orientation: ViewportOrientation, +): {width?: number; height?: number} => { + if (viewport === "auto") { return {}; } - if (typeof viewport === 'string') { - const { x, y } = VIEWPORT_SIZE_PRESET_MAP[viewport]; - return orientation === 'portrait' - ? { width: x, height: y } - : { width: y, height: x }; + if (typeof viewport === "string") { + const {x, y} = VIEWPORT_SIZE_PRESET_MAP[viewport]; + + return orientation === "portrait" ? {width: x, height: y} : {width: y, height: x}; } return viewport; }; const getLines = (lines?: string): HighlightedLine => { - const [start, end] = lines?.includes('-') ? lines?.split('-') : [0, 0]; + const [start, end] = lines?.includes("-") ? lines?.split("-") : [0, 0]; const count = end ? parseInt(`${end}`, 10) - parseInt(`${start}`, 10) + 1 : 0; return { start, end, - count + count, }; }; export const getHighlightedLines = ( highlightedLines?: HighlightedLines, - template?: SandpackPredefinedTemplate + template?: SandpackPredefinedTemplate, ) => { if (!highlightedLines) { return []; @@ -73,24 +61,25 @@ export const getHighlightedLines = ( if (Number.isInteger(Number(highlightedLines))) { return [ { - className: 'sp-highlight', - line: Number(highlightedLines) - } + className: "sp-highlight", + line: Number(highlightedLines), + }, ]; } - if (typeof highlightedLines === 'string') { + if (typeof highlightedLines === "string") { lines = getLines(highlightedLines); } - if (typeof highlightedLines === 'object' && template) { + if (typeof highlightedLines === "object" && template) { const templateLines = highlightedLines[template]; + if (Number.isInteger(Number(templateLines))) { return [ { - className: 'sp-highlight', - line: Number(templateLines) - } + className: "sp-highlight", + line: Number(templateLines), + }, ]; } lines = getLines(templateLines); @@ -101,12 +90,12 @@ export const getHighlightedLines = ( } // map linesCount to { className: 'sp-highlight', line: 1 } - return Array.from({ length: lines.count }, (_, i) => ({ - className: 'sp-highlight', - line: parseInt(`${lines.start}`, 10) + i + return Array.from({length: lines.count}, (_, i) => ({ + className: "sp-highlight", + line: parseInt(`${lines.start}`, 10) + i, })); }; export const getFileName = (filePath: string) => { - return filePath?.split('.')?.[0]?.replace(/\W/g, ''); + return filePath?.split(".")?.[0]?.replace(/\W/g, ""); }; diff --git a/apps/docs/src/components/search/autocomplete.tsx b/apps/docs/src/components/search/autocomplete.tsx index 22c1380f4f..7490408c5a 100644 --- a/apps/docs/src/components/search/autocomplete.tsx +++ b/apps/docs/src/components/search/autocomplete.tsx @@ -1,57 +1,56 @@ -import * as React from 'react'; -import { createPortal } from 'react-dom'; -import cn from 'classnames'; -import { isMacOs } from 'react-device-detect'; -import { useRouter } from 'next/router'; -import { useTheme, useBodyScroll, useClickAway } from '@nextui-org/react'; +import * as React from "react"; +import {createPortal} from "react-dom"; +import cn from "classnames"; +import {isMacOs} from "react-device-detect"; +import {useRouter} from "next/router"; +import {useTheme, useBodyScroll, useClickAway} from "@nextui-org/react"; import AutoSuggest, { ChangeEvent, OnSuggestionSelected, RenderSuggestionsContainerParams, - RenderInputComponentProps -} from 'react-autosuggest'; -import { useIsMobile } from '@hooks/use-media-query'; -import { SearchByAlgolia, Close } from '../icons'; -import { addColorAlpha } from '@utils/index'; -import { - connectAutoComplete, - connectStateResults -} from 'react-instantsearch-dom'; -import { isEmpty } from 'lodash'; -import { AutocompleteProvided } from 'react-instantsearch-core'; -import Keyboard from '../keyboard'; -import Suggestion from './suggestion'; -import { VisualState, useKBar } from 'kbar'; -import Blockholder from '../blockholder'; -import useIsMounted from '@hooks/use-is-mounted'; -import usePortal from '@hooks/use-portal'; -import withDeaults from '@utils/with-defaults'; + RenderInputComponentProps, +} from "react-autosuggest"; +import {useIsMobile} from "@hooks/use-media-query"; +import {addColorAlpha} from "@utils/index"; +import {connectAutoComplete, connectStateResults} from "react-instantsearch-dom"; +import {isEmpty} from "lodash"; +import {AutocompleteProvided} from "react-instantsearch-core"; +import {VisualState, useKBar} from "kbar"; +import useIsMounted from "@hooks/use-is-mounted"; +import usePortal from "@hooks/use-portal"; +import withDeaults from "@utils/with-defaults"; + +import Blockholder from "../blockholder"; +import Keyboard from "../keyboard"; +import {SearchByAlgolia, Close} from "../icons"; + +import Suggestion from "./suggestion"; interface Props extends AutocompleteProvided { offsetTop?: number; } const defaultProps = { - offsetTop: 0 + offsetTop: 0, }; -const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { - const [value, setValue] = React.useState(''); +const Autocomplete: React.FC<Props> = ({hits, refine, offsetTop}) => { + const [value, setValue] = React.useState(""); const [isFocused, setIsFocused] = React.useState(false); - const [, setBodyHidden] = useBodyScroll(null, { scrollLayer: true }); + const [, setBodyHidden] = useBodyScroll(null, {scrollLayer: true}); const router = useRouter(); - const suggestionsPortal = usePortal('suggestions', () => { - return document?.getElementById('navbar-container'); + const suggestionsPortal = usePortal("suggestions", () => { + return document?.getElementById("navbar-container"); }); - const noResultsPortal = usePortal('no-results', () => { - return document?.getElementById('navbar-container'); + const noResultsPortal = usePortal("no-results", () => { + return document?.getElementById("navbar-container"); }); - const { theme, isDark, type: themeType } = useTheme(); + const {theme, isDark, type: themeType} = useTheme(); const isMobile = useIsMobile(); - const { query } = useKBar(); + const {query} = useKBar(); const isMounted = useIsMounted(); let inputRef = React.useRef<HTMLInputElement>(null); @@ -64,18 +63,17 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { React.useEffect(() => { if (isMobile) { const isOpen = !isEmpty( - document.getElementsByClassName( - 'react-autosuggest__suggestions-container--open' - ) + document.getElementsByClassName("react-autosuggest__suggestions-container--open"), ); const noResults = isEmpty(hits) && !isEmpty(value); + setBodyHidden(isFocused && (isOpen || noResults)); } else { setBodyHidden(false); } }, [hits, value, isFocused, isMobile]); - const onChange = (_: unknown, { newValue }: ChangeEvent) => { + const onChange = (_: unknown, {newValue}: ChangeEvent) => { setValue(newValue); }; @@ -83,20 +81,17 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { value, onChange, ref: inputRef, - type: 'search', + type: "search", onFocus: () => setIsFocused(true), - onBlur: () => setIsFocused(false) + onBlur: () => setIsFocused(false), }; - const onSuggestionsFetchRequested = ({ value }: any) => { + const onSuggestionsFetchRequested = ({value}: any) => { refine(value); }; - const onSuggestionSelected: OnSuggestionSelected<any> = ( - _, - { suggestion, method } - ) => { - if (method === 'enter') { + const onSuggestionSelected: OnSuggestionSelected<any> = (_, {suggestion, method}) => { + if (method === "enter") { onClear(); router.push(suggestion.url); } @@ -104,14 +99,13 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { const getSuggestionValue = () => value; - const renderSuggestion = ( - hit: any, - { isHighlighted }: { isHighlighted: boolean } - ) => <Suggestion highlighted={isHighlighted} hit={hit} />; + const renderSuggestion = (hit: any, {isHighlighted}: {isHighlighted: boolean}) => ( + <Suggestion highlighted={isHighlighted} hit={hit} /> + ); const onClear = () => { refine(); - setValue(''); + setValue(""); inputRef && inputRef?.current?.blur(); }; @@ -119,7 +113,7 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { query.setVisualState((vs) => [VisualState.animatingOut, VisualState.hidden].includes(vs) ? VisualState.animatingIn - : VisualState.animatingOut + : VisualState.animatingOut, ); }; @@ -127,11 +121,7 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { (inputProps: RenderInputComponentProps) => { return ( <label className="search__input-container"> - <input - className="search__input" - {...inputProps} - placeholder="Search..." - /> + <input className="search__input" {...inputProps} placeholder="Search..." /> {!value ? ( <span className="search__placeholder-container"> <Keyboard @@ -144,42 +134,42 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { </Keyboard> </span> ) : ( - <span className="search__reset-container" onClick={onClear}> - <Close size={16} fill={theme?.colors?.accents6?.value} /> + <span className="search__reset-container" role="button" onClick={onClear}> + <Close fill={theme?.colors?.accents6?.value} size={16} /> </span> )} </label> ); }, - [value, themeType] + [value, themeType], ); const renderSuggestionsContainer = ({ containerProps, - children + children, }: RenderSuggestionsContainerParams) => suggestionsPortal ? ( createPortal( <div {...containerProps}> <a + className="react-autosuggest__suggestions-header" href="https://www.algolia.com/" - target="_blank" rel="noreferrer" - className="react-autosuggest__suggestions-header" + target="_blank" > <SearchByAlgolia fill={theme?.colors?.accents6?.value} /> </a> {children} </div>, - suggestionsPortal + suggestionsPortal, ) ) : ( <div {...containerProps}> <a + className="react-autosuggest__suggestions-header" href="https://www.algolia.com/" - target="_blank" rel="noreferrer" - className="react-autosuggest__suggestions-header" + target="_blank" > <SearchByAlgolia fill={theme?.colors?.accents6?.value} /> </a> @@ -187,40 +177,33 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { </div> ); - const NoResults = connectStateResults( - ({ searchState, searchResults, searching }) => { - const open = - searchState && - searchState.query && - !searching && - searchResults && - searchResults.nbHits === 0; - const NoResultsContainer = () => ( - <div className="no-results"> - <span> - No results for <span>"{value}"</span> - </span> - <br /> - <span>Try again with a different keyword</span> - </div> - ); - if (isMobile && open) { - if (!noResultsPortal) return null; - return createPortal(<NoResultsContainer />, noResultsPortal); - } - return open ? <NoResultsContainer /> : null; + const NoResults = connectStateResults(({searchState, searchResults, searching}) => { + const open = + searchState && searchState.query && !searching && searchResults && searchResults.nbHits === 0; + const NoResultsContainer = () => ( + <div className="no-results"> + <span> + No results for <span>"{value}"</span> + </span> + <br /> + <span>Try again with a different keyword</span> + </div> + ); + + if (isMobile && open) { + if (!noResultsPortal) return null; + + return createPortal(<NoResultsContainer />, noResultsPortal); } - ); + + return open ? <NoResultsContainer /> : null; + }); if (!isMounted) { return ( <> - <Blockholder - className="search__placeholder-block" - alt="search placeholder" - height="38px" - /> - <style jsx global>{` + <Blockholder alt="search placeholder" className="search__placeholder-block" height="38px" /> + <style global jsx>{` .search__placeholder-block { max-width: 200px; } @@ -247,27 +230,27 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { return ( <div - className={cn('search__container', { + className={cn("search__container", { focused: isFocused, - 'has-value': !!value.length + "has-value": !!value.length, })} > <AutoSuggest - highlightFirstSuggestion={true} - onSuggestionsFetchRequested={onSuggestionsFetchRequested} - onSuggestionsClearRequested={onClear} - onSuggestionSelected={onSuggestionSelected} getSuggestionValue={getSuggestionValue} - renderSuggestion={renderSuggestion} + highlightFirstSuggestion={true} + inputProps={inputProps} renderInputComponent={renderInput} + renderSuggestion={renderSuggestion} renderSuggestionsContainer={renderSuggestionsContainer} suggestions={hits} - inputProps={inputProps} + onSuggestionSelected={onSuggestionSelected} + onSuggestionsClearRequested={onClear} + onSuggestionsFetchRequested={onSuggestionsFetchRequested} /> <NoResults /> - <style jsx global> + <style global jsx> {` .search__container { display: flex; @@ -321,9 +304,7 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { align-items: center; z-index: 9999; background: ${addColorAlpha(theme?.colors?.background?.value, 0.7)}; - box-shadow: ${isDark - ? '0px 5px 20px -5px rgba(0, 0, 0, 0.1)' - : 'none'}; + box-shadow: ${isDark ? "0px 5px 20px -5px rgba(0, 0, 0, 0.1)" : "none"}; border-radius: 8px; } .react-autosuggest__input { @@ -369,9 +350,7 @@ const Autocomplete: React.FC<Props> = ({ hits, refine, offsetTop }) => { .no-results { background: var(--nextui-colors-accents0); } - @supports ( - (-webkit-backdrop-filter: none) or (backdrop-filter: none) - ) { + @supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) { .search__input-container, .react-autosuggest__suggestions-container, .no-results { diff --git a/apps/docs/src/components/search/index.ts b/apps/docs/src/components/search/index.ts index 87aed32e68..e532aa21f5 100644 --- a/apps/docs/src/components/search/index.ts +++ b/apps/docs/src/components/search/index.ts @@ -1 +1 @@ -export { default as SearchInput } from './instant-search'; +export {default as SearchInput} from "./instant-search"; diff --git a/apps/docs/src/components/search/input.tsx b/apps/docs/src/components/search/input.tsx index d050f061df..b59d28baac 100644 --- a/apps/docs/src/components/search/input.tsx +++ b/apps/docs/src/components/search/input.tsx @@ -1,7 +1,8 @@ -import * as React from 'react'; -import { connectStateResults } from 'react-instantsearch-dom'; -import { useTheme, Loading } from '@nextui-org/react'; -import { Search, Close } from '../icons'; +import * as React from "react"; +import {connectStateResults} from "react-instantsearch-dom"; +import {useTheme, Loading} from "@nextui-org/react"; + +import {Search, Close} from "../icons"; export interface InputProps { value: string; @@ -9,31 +10,27 @@ export interface InputProps { searching: boolean; } -const Input: React.FC<InputProps> = ({ - onClear, - value, - searching, - ...inputProps -}) => { - const { theme } = useTheme(); +const Input: React.FC<InputProps> = ({onClear, value, searching, ...inputProps}) => { + const {theme} = useTheme(); + return ( <div className="search__input-container"> <input {...inputProps} value={value} /> {!value ? ( <span className="search__placeholder-container"> <Search - size={16} - fill={theme?.colors?.accents8?.value} className="search__placeholder-icon" + fill={theme?.colors?.accents8?.value} + size={16} /> <p className="search__placeholder-text">Search...</p> </span> ) : ( - <span className="search__reset-container" onClick={() => onClear()}> + <span className="search__reset-container" role="button" onClick={() => onClear()}> {searching ? ( <Loading size="xs" /> ) : ( - <Close size={16} fill={theme?.colors?.accents6?.value} /> + <Close fill={theme?.colors?.accents6?.value} size={16} /> )} </span> )} diff --git a/apps/docs/src/components/search/instant-search.tsx b/apps/docs/src/components/search/instant-search.tsx index eba157addf..4239128834 100644 --- a/apps/docs/src/components/search/instant-search.tsx +++ b/apps/docs/src/components/search/instant-search.tsx @@ -1,11 +1,9 @@ -import * as React from 'react'; -import { - InstantSearch as BaseInstantSearch, - Configure -} from 'react-instantsearch-dom'; -import getAlgoliaClient from '@lib/get-algolia'; -import Autocomplete from './autocomplete'; -import { useIsMobile } from '@hooks/use-media-query'; +import * as React from "react"; +import {InstantSearch as BaseInstantSearch, Configure} from "react-instantsearch-dom"; +import getAlgoliaClient from "@lib/get-algolia"; +import {useIsMobile} from "@hooks/use-media-query"; + +import Autocomplete from "./autocomplete"; const searchClient = getAlgoliaClient(); const INDEX_NAME = process.env.NEXT_PUBLIC_ALGOLIA_INDEX; @@ -16,11 +14,9 @@ export interface Props { const InstantSearch: React.FC<Props> = (props) => { const isMobile = useIsMobile(); + return ( - <BaseInstantSearch - indexName={INDEX_NAME || 'prod_docs'} - searchClient={searchClient} - > + <BaseInstantSearch indexName={INDEX_NAME || "prod_docs"} searchClient={searchClient}> <Configure hitsPerPage={isMobile ? 6 : 8} /> <Autocomplete {...props} /> </BaseInstantSearch> diff --git a/apps/docs/src/components/search/suggestion.tsx b/apps/docs/src/components/search/suggestion.tsx index 878b423c08..af00c818fa 100644 --- a/apps/docs/src/components/search/suggestion.tsx +++ b/apps/docs/src/components/search/suggestion.tsx @@ -1,38 +1,40 @@ -import * as React from 'react'; -import cn from 'classnames'; -import { Highlight } from 'react-instantsearch-dom'; -import NextLink from 'next/link'; -import { Hit } from 'react-instantsearch-core'; -import { useTheme } from '@nextui-org/react'; -import { CodeDocument, Hash, ArrowRight } from '../icons'; -import { addColorAlpha } from '@utils/index'; -import { includes } from 'lodash'; +import * as React from "react"; +import cn from "classnames"; +import {Highlight} from "react-instantsearch-dom"; +import NextLink from "next/link"; +import {Hit} from "react-instantsearch-core"; +import {useTheme} from "@nextui-org/react"; +import {addColorAlpha} from "@utils/index"; +import {includes} from "lodash"; + +import {CodeDocument, Hash, ArrowRight} from "../icons"; interface Props { hit: Hit; highlighted: boolean; } -const Suggestion: React.FC<Props> = ({ hit, highlighted }) => { - const { theme } = useTheme(); +const Suggestion: React.FC<Props> = ({hit, highlighted}) => { + const {theme} = useTheme(); + return ( <NextLink href={hit.url}> - <span className={cn('suggestion__container', { highlighted })}> + <span className={cn("suggestion__container", {highlighted})}> <div className="suggestion__icon-container"> - {hit.type !== 'lvl1' || includes(hit.url, '#') ? ( + {hit.type !== "lvl1" || includes(hit.url, "#") ? ( <Hash fill={theme?.colors?.accents6?.value} /> ) : ( <CodeDocument fill={theme?.colors?.accents6?.value} /> )} </div> <div className="suggestion__data-container"> - {hit.type !== 'lvl1' && ( + {hit.type !== "lvl1" && ( <span className="suggestion__title"> - <Highlight hit={hit} attribute="hierarchy.lvl1" tagName="mark" /> + <Highlight attribute="hierarchy.lvl1" hit={hit} tagName="mark" /> </span> )} <span className="suggestion__content"> - <Highlight hit={hit} attribute="content" tagName="mark" /> + <Highlight attribute="content" hit={hit} tagName="mark" /> </span> </div> <div> @@ -47,8 +49,7 @@ const Suggestion: React.FC<Props> = ({ hit, highlighted }) => { cursor: pointer; padding: 16px 8px; justify-content: space-between; - border-bottom: 1px solid - ${addColorAlpha(theme?.colors?.border?.value, 0.6)}; + border-bottom: 1px solid ${addColorAlpha(theme?.colors?.border?.value, 0.6)}; min-height: 68px; transition: all 0.2s ease; } diff --git a/apps/docs/src/components/sidebar/category.tsx b/apps/docs/src/components/sidebar/category.tsx index 5eef44f9f5..e0b10a8a1b 100644 --- a/apps/docs/src/components/sidebar/category.tsx +++ b/apps/docs/src/components/sidebar/category.tsx @@ -1,11 +1,12 @@ -import React, { useRef, useMemo, useState, useEffect } from 'react'; -import cn from 'classnames'; -import Image from 'next/image'; -import ArrowRight from '../icons/arrow-right'; -import withDefaults from '@utils/with-defaults'; -import { useTheme } from '@nextui-org/react'; -import { Route } from '@lib/docs/page'; -import { Badge } from '@components'; +import React, {useRef, useMemo, useState, useEffect} from "react"; +import cn from "classnames"; +import Image from "next/image"; +import withDefaults from "@utils/with-defaults"; +import {useTheme} from "@nextui-org/react"; +import {Route} from "@lib/docs/page"; +import {Badge} from "@components"; + +import ArrowRight from "../icons/arrow-right"; export interface Props { level: number; @@ -22,7 +23,7 @@ const defaultProps = { level: 1, isMobile: false, selected: false, - opened: false + opened: false, }; type NativeAttrs = Omit<React.HTMLAttributes<HTMLDivElement>, keyof Props>; @@ -38,10 +39,10 @@ const Category: React.FC<React.PropsWithChildren<CategoryProps>> = ({ iconUrl, updated, opened, - children + children, }) => { const ref = useRef<HTMLDivElement>(null); - const { theme, isDark } = useTheme(); + const {theme, isDark} = useTheme(); const [toggle, setToggle] = useState<boolean>(selected || opened); const [shouldScroll, setShouldScroll] = useState<boolean>(false); @@ -55,7 +56,7 @@ const Category: React.FC<React.PropsWithChildren<CategoryProps>> = ({ const postsHeight = useMemo( () => routes.length * (isMobile ? 32 : 26) + margin * (routes.length - 1), - [routes, isMobile] + [routes, isMobile], ); // If a category is selected indirectly, open it. This can happen when using the search input @@ -69,9 +70,10 @@ const Category: React.FC<React.PropsWithChildren<CategoryProps>> = ({ useEffect(() => { if (toggle && shouldScroll) { const content = document.querySelector( - isMobile ? '.docs-dropdown' : '.sidebar-content' + isMobile ? ".docs-dropdown" : ".sidebar-content", ) as HTMLDivElement; let height = 0; + // 10 is added for better margin if (ref.current && content) { height = ref.current?.offsetTop - (isMobile ? 10 : content?.offsetTop); @@ -82,33 +84,26 @@ const Category: React.FC<React.PropsWithChildren<CategoryProps>> = ({ }, [toggle, shouldScroll, isMobile]); return ( - <div - ref={ref} - className={cn('category', levelClass, { open: toggle, selected })} - > - <div className="label-container" onClick={toggleCategory}> + <div ref={ref} className={cn("category", levelClass, {open: toggle, selected})}> + <div className="label-container" role="button" onClick={toggleCategory}> {iconUrl && ( <Image - width={24} - height={24} - className="category-image" - src={iconUrl.replace('.svg', isDark ? '-dark.svg' : '-light.svg')} alt={`${title} icon`} + className="category-image" + height={24} + src={iconUrl.replace(".svg", isDark ? "-dark.svg" : "-light.svg")} + width={24} /> )} <span className="label noselect">{title}</span> <ArrowRight className="arrow-right" - width={14} - height={14} fill={theme?.colors?.accents8?.value} + height={14} + width={14} /> {updated && ( - <Badge - className="category__update-badge" - type="secondary" - css={{ ml: '$6' }} - > + <Badge className="category__update-badge" css={{ml: "$6"}} type="secondary"> Updated </Badge> )} diff --git a/apps/docs/src/components/sidebar/index.tsx b/apps/docs/src/components/sidebar/index.tsx index 9195063ac0..b7b3b1c05a 100644 --- a/apps/docs/src/components/sidebar/index.tsx +++ b/apps/docs/src/components/sidebar/index.tsx @@ -1,12 +1,14 @@ -import * as React from 'react'; -import withDefaults from '@utils/with-defaults'; -import { Route, addTagToSlug } from '@lib/docs/page'; -import { removeFromLast } from '@utils/index'; -import { useIsMobile } from '@hooks/use-media-query'; -import { Heading } from '@components'; -import Category from './category'; -import Post from './post'; -import { NavLinkProps } from '../nav-link'; +import * as React from "react"; +import withDefaults from "@utils/with-defaults"; +import {Route, addTagToSlug} from "@lib/docs/page"; +import {removeFromLast} from "@utils/index"; +import {useIsMobile} from "@hooks/use-media-query"; +import {Heading} from "@components"; + +import {NavLinkProps} from "../nav-link"; + +import Category from "./category"; +import Post from "./post"; export interface Props { routes?: Route[]; @@ -18,8 +20,8 @@ export interface Props { const defaultProps = { level: 1, - tag: '', - slug: '' + tag: "", + slug: "", }; type NativeAttrs = Omit<React.HTMLAttributes<unknown>, keyof Props>; @@ -28,100 +30,83 @@ export type SidebarProps = Props & typeof defaultProps & NativeAttrs; function getCategoryPath(routes: Route[]): string { const route = routes.find((r) => r.path); - return route && route.path ? removeFromLast(route.path, '/') : ''; + + return route && route.path ? removeFromLast(route.path, "/") : ""; } -const Sidebar: React.FC<SidebarProps> = ({ - routes, - level, - tag, - slug, - onPostClick -}) => { +const Sidebar: React.FC<SidebarProps> = ({routes, level, tag, slug, onPostClick}) => { const isMobile = useIsMobile(); + return ( <> - {routes?.map( - ({ - path, - title, - icon, - routes, - newPost, - comingSoon, - updated, - heading, - open - }) => { - if (routes) { - const pathname = getCategoryPath(routes); - const categorySelected = slug.startsWith(pathname); - const opened = categorySelected || isMobile ? false : open; - - if (heading) { - return ( - <Heading key={pathname} title={title}> - <Sidebar - routes={routes} - level={level + 1} - tag={tag} - slug={slug} - onPostClick={onPostClick} - /> - </Heading> - ); - } + {routes?.map(({path, title, icon, routes, newPost, comingSoon, updated, heading, open}) => { + if (routes) { + const pathname = getCategoryPath(routes); + const categorySelected = slug.startsWith(pathname); + const opened = categorySelected || isMobile ? false : open; + if (heading) { return ( - <Category - key={pathname} - routes={routes} - isMobile={isMobile} - iconUrl={icon} - level={level} - title={title} - selected={categorySelected} - opened={opened} - updated={updated} - > + <Heading key={pathname} title={title}> <Sidebar - routes={routes} level={level + 1} - tag={tag} + routes={routes} slug={slug} + tag={tag} onPostClick={onPostClick} /> - </Category> + </Heading> ); } - const href = '/docs/[[...slug]]'; - const pagePath: string | undefined = - path && removeFromLast(path, '.'); - const pathname = pagePath && addTagToSlug(pagePath, tag); - const selected = pagePath && pagePath === slug; - - const route = { - href, - path, - title, - pathname, - selected, - comingSoon, - updated, - newPost - } as NavLinkProps; return ( - <Post - key={title} + <Category + key={pathname} + iconUrl={icon} isMobile={isMobile} level={level} - route={route} - onClick={() => onPostClick && onPostClick(route)} - /> + opened={opened} + routes={routes} + selected={categorySelected} + title={title} + updated={updated} + > + <Sidebar + level={level + 1} + routes={routes} + slug={slug} + tag={tag} + onPostClick={onPostClick} + /> + </Category> ); } - )} + const href = "/docs/[[...slug]]"; + const pagePath: string | undefined = path && removeFromLast(path, "."); + const pathname = pagePath && addTagToSlug(pagePath, tag); + const selected = pagePath && pagePath === slug; + + const route = { + href, + path, + title, + pathname, + selected, + comingSoon, + updated, + newPost, + } as NavLinkProps; + + return ( + <Post + key={title} + isMobile={isMobile} + level={level} + route={route} + onClick={() => onPostClick && onPostClick(route)} + /> + ); + })} </> ); }; diff --git a/apps/docs/src/components/sidebar/post.tsx b/apps/docs/src/components/sidebar/post.tsx index 491755cf82..aedfc662ab 100644 --- a/apps/docs/src/components/sidebar/post.tsx +++ b/apps/docs/src/components/sidebar/post.tsx @@ -1,9 +1,10 @@ -import React, { useRef, useEffect, useMemo } from 'react'; -import cn from 'classnames'; -import NavLink, { NavLinkProps } from '../nav-link'; -import withDefaults from '@utils/with-defaults'; -import { Badge } from '@components'; -import { useTheme, Spacer } from '@nextui-org/react'; +import React, {useRef, useEffect, useMemo} from "react"; +import cn from "classnames"; +import withDefaults from "@utils/with-defaults"; +import {Badge} from "@components"; +import {useTheme, Spacer} from "@nextui-org/react"; + +import NavLink, {NavLinkProps} from "../nav-link"; export interface Props { level: number; @@ -14,7 +15,7 @@ export interface Props { const defaultProps = { level: 1, - isMobile: false + isMobile: false, }; type NativeAttrs = Omit<React.HTMLAttributes<HTMLDivElement>, keyof Props>; @@ -25,17 +26,15 @@ const Post: React.FC<React.PropsWithChildren<PostProps>> = ({ isMobile, route, level = 1, - onClick + onClick, }) => { const selectedRef = useRef<HTMLDivElement>(null); const ref = route.selected ? selectedRef : null; - const { theme, isDark } = useTheme(); + const {theme, isDark} = useTheme(); useEffect(() => { if (ref && ref.current && !isMobile) { - const content = document.querySelector( - '.sidebar-content' - ) as HTMLDivElement; + const content = document.querySelector(".sidebar-content") as HTMLDivElement; // 32 is the top and bottom margin for `.link` const height = ref.current.offsetTop - 32; @@ -48,14 +47,12 @@ const Post: React.FC<React.PropsWithChildren<PostProps>> = ({ const linkColor = useMemo(() => { if (route.selected) return theme?.colors?.text?.value; if (route.comingSoon) return theme?.colors?.accents5?.value; + return theme?.colors?.accents8?.value; }, [isDark, route.selected]); return ( - <div - ref={ref} - className={cn('link', `level-${level}`, { disabled: route?.comingSoon })} - > + <div ref={ref} className={cn("link", `level-${level}`, {disabled: route?.comingSoon})}> <NavLink {...route} color={linkColor} onClick={onClick} /> <Spacer inline x={0.2} /> {route?.newPost && ( @@ -84,7 +81,7 @@ const Post: React.FC<React.PropsWithChildren<PostProps>> = ({ cursor: not-allowed; } .link::before { - content: ''; + content: ""; flex-basis: 4px; flex-shrink: 0; display: block; diff --git a/apps/docs/src/components/table-of-content/index.tsx b/apps/docs/src/components/table-of-content/index.tsx index 3c110e79dd..1766af0f84 100644 --- a/apps/docs/src/components/table-of-content/index.tsx +++ b/apps/docs/src/components/table-of-content/index.tsx @@ -1,26 +1,23 @@ -import * as React from 'react'; -import cn from 'classnames'; -import { useScrollSpy } from '@hooks/use-scroll-spy'; -import { Heading } from '@utils/get-headings'; -import { useTheme } from '@nextui-org/react'; -import { useIsMobile } from '@hooks/use-media-query'; +import * as React from "react"; +import cn from "classnames"; +import {useScrollSpy} from "@hooks/use-scroll-spy"; +import {Heading} from "@utils/get-headings"; +import {useTheme} from "@nextui-org/react"; +import {useIsMobile} from "@hooks/use-media-query"; interface TableOfContentProps { headings: Heading[]; } -const TableOfContent: React.FC<TableOfContentProps> = ({ - headings, - ...props -}) => { +const TableOfContent: React.FC<TableOfContentProps> = ({headings, ...props}) => { const isMobile = useIsMobile(); const activeId = useScrollSpy( - headings.map(({ id }) => `[id="${id}"]`), + headings.map(({id}) => `[id="${id}"]`), { - rootMargin: '0% 0% -80% 0%' - } + rootMargin: "0% 0% -80% 0%", + }, ); - const { theme } = useTheme(); + const {theme} = useTheme(); if (headings.length <= 0 || isMobile) return null; @@ -31,8 +28,8 @@ const TableOfContent: React.FC<TableOfContentProps> = ({ {headings.map((heading, i) => ( <li key={i} - className={cn('list-item', { - active: activeId == heading.id + className={cn("list-item", { + active: activeId == heading.id, })} > <a href={`#${heading.id}`}>{heading.text}</a> @@ -80,7 +77,7 @@ const TableOfContent: React.FC<TableOfContentProps> = ({ font-weight: 500; } .list-item:after { - content: ''; + content: ""; position: absolute; top: 50%; right: auto; diff --git a/apps/docs/src/components/templates/custom-button/index.tsx b/apps/docs/src/components/templates/custom-button/index.tsx index 15f2c48732..33d7ff71ac 100644 --- a/apps/docs/src/components/templates/custom-button/index.tsx +++ b/apps/docs/src/components/templates/custom-button/index.tsx @@ -1,27 +1,22 @@ -import React from 'react'; -import { Button } from '@nextui-org/react'; -import confetti from 'canvas-confetti'; +import React from "react"; +import {Button} from "@nextui-org/react"; +import confetti from "canvas-confetti"; const CustomButton = () => { - const handleConfetti = ( - event: React.MouseEvent<HTMLButtonElement, MouseEvent> - ) => { - const { currentTarget } = event; - const { clientWidth, clientHeight } = document.documentElement; - const { - y: targetY, - x: targetX, - width: targetWidth - } = currentTarget.getBoundingClientRect(); + const handleConfetti = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => { + const {currentTarget} = event; + const {clientWidth, clientHeight} = document.documentElement; + const {y: targetY, x: targetX, width: targetWidth} = currentTarget.getBoundingClientRect(); const targetCenterX = targetX + targetWidth / 2; + confetti({ zIndex: 999, particleCount: 100, spread: 70, origin: { y: targetY / clientHeight, - x: targetCenterX / clientWidth - } + x: targetCenterX / clientWidth, + }, }); }; @@ -29,39 +24,39 @@ const CustomButton = () => { <Button auto rounded - ripple={false} - onClick={handleConfetti} css={{ - background: '$white', - fontWeight: '$semibold', - boxShadow: '$lg', - position: 'relative', - overflow: 'visible', - color: '#0F9549', - fontSize: '$lg', - px: '$18', - py: '$11', - '&:after': { + background: "$white", + fontWeight: "$semibold", + boxShadow: "$lg", + position: "relative", + overflow: "visible", + color: "#0F9549", + fontSize: "$lg", + px: "$18", + py: "$11", + "&:after": { content: '""', - position: 'absolute', - width: '100%', - height: '100%', - background: '$white', + position: "absolute", + width: "100%", + height: "100%", + background: "$white", opacity: 1, - borderRadius: '$pill', - transition: 'all 0.4s ease' + borderRadius: "$pill", + transition: "all 0.4s ease", }, - '&:hover': { - transform: 'translateY(-5px)', - '&:after': { - transform: 'scaleX(1.5) scaleY(1.6)', - opacity: 0 - } + "&:hover": { + transform: "translateY(-5px)", + "&:after": { + transform: "scaleX(1.5) scaleY(1.6)", + opacity: 0, + }, + }, + "&:active": { + transform: "translateY(-2px)", }, - '&:active': { - transform: 'translateY(-2px)' - } }} + ripple={false} + onClick={handleConfetti} > Click me </Button> diff --git a/apps/docs/src/components/templates/delete-user/index.tsx b/apps/docs/src/components/templates/delete-user/index.tsx index 13a1f72ede..4dde1d2f36 100644 --- a/apps/docs/src/components/templates/delete-user/index.tsx +++ b/apps/docs/src/components/templates/delete-user/index.tsx @@ -1,28 +1,28 @@ -import React from 'react'; -import { useTheme, Text, Button, Grid, Row } from '@nextui-org/react'; +import React from "react"; +import {useTheme, Text, Button, Grid, Row} from "@nextui-org/react"; const DeleteUser: React.FC = () => { - const { theme } = useTheme(); + const {theme} = useTheme(); return ( <Grid.Container className="delete-user__container"> - <Row justify="center" align="center"> + <Row align="center" justify="center"> <Text b>Confirm</Text> </Row> <Row> <Text> - Are you sure you want to delete this user ?, by doing this, you will - not be able to recover the data. + Are you sure you want to delete this user ?, by doing this, you will not be able to + recover the data. </Text> </Row> - <Grid.Container justify="space-between" alignContent="center"> + <Grid.Container alignContent="center" justify="space-between"> <Grid> - <Button size="sm" light> + <Button light size="sm"> Cancel </Button> </Grid> <Grid> - <Button size="sm" shadow color="error"> + <Button shadow color="error" size="sm"> Delete </Button> </Grid> diff --git a/apps/docs/src/components/templates/example-block/index.tsx b/apps/docs/src/components/templates/example-block/index.tsx index 80ab8fff6b..7cf2da9a89 100644 --- a/apps/docs/src/components/templates/example-block/index.tsx +++ b/apps/docs/src/components/templates/example-block/index.tsx @@ -1,6 +1,6 @@ -import React, { useMemo } from 'react'; -import { NextUITheme, useTheme } from '@nextui-org/react'; -import withDefaults from '@utils/with-defaults'; +import React, {useMemo} from "react"; +import {NextUITheme, useTheme} from "@nextui-org/react"; +import withDefaults from "@utils/with-defaults"; interface Props { plain?: number | boolean; @@ -12,21 +12,22 @@ interface Props { const defaultProps = { plain: false, height: 30, - radius: '10px' + radius: "10px", }; export type ExampleBlockProps = Props & typeof defaultProps; const getBackground = (plain: number | boolean, theme?: NextUITheme) => { - if (typeof plain !== 'number') return theme?.colors?.primary?.value; + if (typeof plain !== "number") return theme?.colors?.primary?.value; const colors = [ theme?.colors?.accents1?.value, theme?.colors?.accents2?.value, theme?.colors?.accents3?.value, theme?.colors?.accents4?.value, theme?.colors?.accents5?.value, - theme?.colors?.accents6?.value + theme?.colors?.accents6?.value, ]; + return colors[plain - 1] || theme?.colors?.primary?.value; }; @@ -38,9 +39,9 @@ const ExampleBlock: React.FC<React.PropsWithChildren<ExampleBlockProps>> = ({ radius, ...props }) => { - const { theme } = useTheme(); + const {theme} = useTheme(); const blockWidth = useMemo(() => { - return width ? `${width}px` : '100%'; + return width ? `${width}px` : "100%"; }, [width]); const bg = useMemo(() => getBackground(plain, theme), [theme, plain]); diff --git a/apps/docs/src/components/templates/index.ts b/apps/docs/src/components/templates/index.ts index 98e9f2660d..669f2c6a63 100644 --- a/apps/docs/src/components/templates/index.ts +++ b/apps/docs/src/components/templates/index.ts @@ -1,7 +1,7 @@ -export { default as DeleteUser } from './delete-user'; -export { default as ExampleBlock } from './example-block'; -export { default as UserTwitterCard } from './user-twitter-card'; -export { default as SendButton } from './send-button'; -export { default as Player } from './player'; -export { default as CustomButton } from './custom-button'; -export { default as ShopCard } from './shop-card'; +export {default as DeleteUser} from "./delete-user"; +export {default as ExampleBlock} from "./example-block"; +export {default as UserTwitterCard} from "./user-twitter-card"; +export {default as SendButton} from "./send-button"; +export {default as Player} from "./player"; +export {default as CustomButton} from "./custom-button"; +export {default as ShopCard} from "./shop-card"; diff --git a/apps/docs/src/components/templates/player/index.ts b/apps/docs/src/components/templates/player/index.ts index bac22ce4de..c0c89817fd 100644 --- a/apps/docs/src/components/templates/player/index.ts +++ b/apps/docs/src/components/templates/player/index.ts @@ -1,3 +1,3 @@ -import Player from './player'; +import Player from "./player"; export default Player; diff --git a/apps/docs/src/components/templates/player/player.tsx b/apps/docs/src/components/templates/player/player.tsx index 9e793469f4..9dddb329a9 100644 --- a/apps/docs/src/components/templates/player/player.tsx +++ b/apps/docs/src/components/templates/player/player.tsx @@ -1,43 +1,21 @@ -import React from 'react'; -import { - Card, - Avatar, - Grid, - Text, - Row, - Progress, - StyledProgressBar, - CSS -} from '@nextui-org/react'; -import { - Box, - Heart, - Play, - Rewind5s, - Forward5s, - NextTrack, - PreviousTrack -} from '@components'; +import React from "react"; +import {Card, Avatar, Grid, Text, Row, Progress, StyledProgressBar, CSS} from "@nextui-org/react"; +import {Box, Heart, Play, Rewind5s, Forward5s, NextTrack, PreviousTrack} from "@components"; export interface Props { className?: string; css?: CSS; } -const Player: React.FC<Props> = ({ css, ...props }) => { +const Player: React.FC<Props> = ({css, ...props}) => { const [liked, setLiked] = React.useState(false); return ( - <Card css={{ p: '$6', mt: '$8', boxShadow: '$md', ...css }} {...props}> - <Card.Header css={{ d: 'flex', ai: 'center', py: '$8' }}> + <Card css={{p: "$6", mt: "$8", boxShadow: "$md", ...css}} {...props}> + <Card.Header css={{d: "flex", ai: "center", py: "$8"}}> <Grid.Container> - <Grid css={{ mr: '$8' }}> - <Avatar - squared - color="secondary" - size="xl" - src="/images/hero-card.png" - /> + <Grid css={{mr: "$8"}}> + <Avatar squared color="secondary" size="xl" src="/images/hero-card.png" /> </Grid> <Grid> <Row> @@ -46,7 +24,7 @@ const Player: React.FC<Props> = ({ css, ...props }) => { </Text> </Row> <Row> - <Text b size={14} css={{ color: '$accents6' }}> + <Text b css={{color: "$accents6"}} size={14}> 12 Tracks </Text> </Row> @@ -56,73 +34,73 @@ const Player: React.FC<Props> = ({ css, ...props }) => { </Text> </Row> <Heart - filled={liked} - fill="#FF4ECD" - onClick={() => setLiked(!liked)} css={{ - cursor: 'pointer', - position: 'absolute', - top: '$9', - right: '$10' + cursor: "pointer", + position: "absolute", + top: "$9", + right: "$10", }} + fill="#FF4ECD" + filled={liked} + onClick={() => setLiked(!liked)} /> </Grid> </Grid.Container> </Card.Header> - <Card.Body css={{ mt: '$5', py: '$8' }}> + <Card.Body css={{mt: "$5", py: "$8"}}> <Row> <Progress - value={30} - max={100} - size="sm" css={{ [`& ${StyledProgressBar}`]: { - bg: '#FF4ECD' - } + bg: "#FF4ECD", + }, }} + max={100} + size="sm" + value={30} /> </Row> - <Row justify="space-between" css={{ py: '$6', px: '$1' }}> - <Text b size={14} css={{ color: '#FF4ECD' }}> + <Row css={{py: "$6", px: "$1"}} justify="space-between"> + <Text b css={{color: "#FF4ECD"}} size={14}> 13:36 </Text> - <Text b size={14} css={{ color: '$accents6' }}> + <Text b css={{color: "$accents6"}} size={14}> 35:01 </Text> </Row> </Card.Body> - <Card.Footer css={{ pt: '$2', color: '$text', pb: '$8' }}> - <Row justify="space-between" align="center" css={{ mx: '$14' }}> + <Card.Footer css={{pt: "$2", color: "$text", pb: "$8"}}> + <Row align="center" css={{mx: "$14"}} justify="space-between"> <Rewind5s css={{ - cursor: 'pointer' + cursor: "pointer", }} /> <PreviousTrack css={{ - cursor: 'pointer' + cursor: "pointer", }} /> <Box css={{ - dflex: 'center', - bg: 'linear-gradient(180deg, #FF1CF7 25%, #b249f8 100%)', - size: '$16', - br: '$pill', - boxShadow: '$sm', - cursor: 'pointer' + dflex: "center", + bg: "linear-gradient(180deg, #FF1CF7 25%, #b249f8 100%)", + size: "$16", + br: "$pill", + boxShadow: "$sm", + cursor: "pointer", }} > - <Play css={{ ml: '$1' }} /> + <Play css={{ml: "$1"}} /> </Box> <NextTrack css={{ - cursor: 'pointer' + cursor: "pointer", }} /> <Forward5s css={{ - cursor: 'pointer' + cursor: "pointer", }} /> </Row> diff --git a/apps/docs/src/components/templates/send-button/index.tsx b/apps/docs/src/components/templates/send-button/index.tsx index 87df118ce9..c5ea471de4 100644 --- a/apps/docs/src/components/templates/send-button/index.tsx +++ b/apps/docs/src/components/templates/send-button/index.tsx @@ -1,21 +1,22 @@ -import React from 'react'; -import { useTheme } from '@nextui-org/react'; -import { Send } from '../../icons'; +import React from "react"; +import {useTheme} from "@nextui-org/react"; + +import {Send} from "../../icons"; interface Props { onClick: () => void; } -const SendButton: React.FC<Props> = ({ onClick }) => { - const { theme } = useTheme(); +const SendButton: React.FC<Props> = ({onClick}) => { + const {theme} = useTheme(); const handleClick = () => { onClick && onClick(); }; return ( - <div className="send-button-container" onClick={handleClick}> - <Send fill="white" className="send-button__arrow-icon" /> + <div className="send-button-container" role="button" onClick={handleClick}> + <Send className="send-button__arrow-icon" fill="white" /> <style jsx>{` .send-button-container { width: 24px; diff --git a/apps/docs/src/components/templates/shop-card/animations.ts b/apps/docs/src/components/templates/shop-card/animations.ts index c65a3d566f..10c5515562 100644 --- a/apps/docs/src/components/templates/shop-card/animations.ts +++ b/apps/docs/src/components/templates/shop-card/animations.ts @@ -1,108 +1,108 @@ -import { AnimationProps } from 'framer-motion'; +import {AnimationProps} from "framer-motion"; -type Animations = { [key: string]: AnimationProps['animate'] }; +type Animations = {[key: string]: AnimationProps["animate"]}; export default { nextui: { title: { - scale: 1 + scale: 1, }, subtitle: { - translateY: 0 + translateY: 0, }, price: { translateY: 0, - scale: 1 + scale: 1, }, oldPrice: { - translateY: 0 + translateY: 0, }, discount: { translateY: 0, - translateX: 0 + translateX: 0, }, productContainer: { - scale: 1 + scale: 1, }, productSizeButton: { - borderRadius: 8 - } + borderRadius: 8, + }, }, modern: { title: { - fontSize: '24px' + fontSize: "24px", }, subtitle: { - translateY: -5 + translateY: -5, }, price: { translateY: 4, - scale: 1.2 + scale: 1.2, }, oldPrice: { translateY: 4, - translateX: 5 + translateX: 5, }, discount: { marginLeft: 0, scale: 0.8, translateY: -20, - translateX: -120 + translateX: -120, }, productContainer: { - scale: 1.25 + scale: 1.25, }, productSizeButton: { - borderRadius: 20 - } + borderRadius: 20, + }, }, elegant: { productContainer: { scale: 1.2, - borderRadius: '4px' + borderRadius: "4px", }, price: { - scale: 1 + scale: 1, }, oldPrice: { scale: 0.9, - translateX: -10 + translateX: -10, }, discount: { scale: 0.8, - translateX: -10 + translateX: -10, }, productSizeButton: { - borderRadius: '4px' - } + borderRadius: "4px", + }, }, retro: { title: { - fontSize: '24px' + fontSize: "24px", }, subtitle: { - translateY: -5 + translateY: -5, }, price: { translateY: 4, - scale: 1.2 + scale: 1.2, }, oldPrice: { scale: 0.8, translateY: -20, - translateX: -80 + translateX: -80, }, discount: { marginLeft: 0, scale: 0.7, translateY: -20, - translateX: -80 + translateX: -80, }, productContainer: { - borderRadius: '0px' + borderRadius: "0px", }, productSizeButton: { - borderRadius: '0px' - } - } -} as { nextui: Animations; modern: Animations }; + borderRadius: "0px", + }, + }, +} as {nextui: Animations; modern: Animations}; diff --git a/apps/docs/src/components/templates/shop-card/content.tsx b/apps/docs/src/components/templates/shop-card/content.tsx index e0795f6460..5d52462f66 100644 --- a/apps/docs/src/components/templates/shop-card/content.tsx +++ b/apps/docs/src/components/templates/shop-card/content.tsx @@ -1,61 +1,62 @@ -import React from 'react'; -import { Palette, Magic, GamingConsole } from '../../icons'; -import { Logo } from '@components'; +import React from "react"; +import {Logo} from "@components"; + +import {Palette, Magic, GamingConsole} from "../../icons"; const themes = [ { - id: 'nextui', - title: 'NextUI', + id: "nextui", + title: "NextUI", icon: () => ( <Logo small - size={44} css={{ - '& path': { - fill: 'currentColor' - } + "& path": { + fill: "currentColor", + }, }} + size={44} /> - ) + ), }, { - id: 'modern', - title: 'Modern', - icon: () => <Palette size={44} fill="currentColor" /> + id: "modern", + title: "Modern", + icon: () => <Palette fill="currentColor" size={44} />, }, { - id: 'elegant', - title: 'Elegant', - icon: () => <Magic size={44} fill="currentColor" /> + id: "elegant", + title: "Elegant", + icon: () => <Magic fill="currentColor" size={44} />, }, { - id: 'retro', - title: 'Retro', - icon: () => <GamingConsole size={44} fill="currentColor" /> - } + id: "retro", + title: "Retro", + icon: () => <GamingConsole fill="currentColor" size={44} />, + }, ]; const sizes = [ { - id: 'extra-small', - title: 'XS' + id: "extra-small", + title: "XS", }, { - id: 'small', - title: 'S' + id: "small", + title: "S", }, { - id: 'medium', - title: 'M' + id: "medium", + title: "M", }, { - id: 'large', - title: 'L' + id: "large", + title: "L", }, { - id: 'extra-large', - title: 'XL' - } + id: "extra-large", + title: "XL", + }, ]; -export { themes, sizes }; +export {themes, sizes}; diff --git a/apps/docs/src/components/templates/shop-card/index.ts b/apps/docs/src/components/templates/shop-card/index.ts index 465235ff8e..751f7c1690 100644 --- a/apps/docs/src/components/templates/shop-card/index.ts +++ b/apps/docs/src/components/templates/shop-card/index.ts @@ -1,3 +1,3 @@ -import ShopCard from './shop-card'; +import ShopCard from "./shop-card"; export default ShopCard; diff --git a/apps/docs/src/components/templates/shop-card/shop-card.tsx b/apps/docs/src/components/templates/shop-card/shop-card.tsx index 59abfeb7fc..6c2b345b34 100644 --- a/apps/docs/src/components/templates/shop-card/shop-card.tsx +++ b/apps/docs/src/components/templates/shop-card/shop-card.tsx @@ -1,14 +1,9 @@ -import React, { useMemo } from 'react'; -import { - Card, - Col, - Grid, - Row, - Text, - Spacer, - useTheme -} from '@nextui-org/react'; -import { Box } from '@components'; +import React, {useMemo} from "react"; +import {Card, Col, Grid, Row, Text, Spacer, useTheme} from "@nextui-org/react"; +import {Box} from "@components"; +import {get} from "lodash"; +import {motion} from "framer-motion"; + import { GridItem, TabText, @@ -23,20 +18,18 @@ import { StyledPrice, StyledOldPrice, StyledDiscount, - StyledCard -} from './styles'; -import { get } from 'lodash'; -import { themes, sizes } from './content'; -import { motion } from 'framer-motion'; -import framerAnimations from './animations'; + StyledCard, +} from "./styles"; +import {themes, sizes} from "./content"; +import framerAnimations from "./animations"; import { lightModernTheme, darkModernTheme, lightElegantTheme, darkElegantTheme, lightRetroTheme, - darkRetroTheme -} from './themes'; + darkRetroTheme, +} from "./themes"; interface Props { onChangeTheme?: (theme: string) => void; @@ -44,31 +37,28 @@ interface Props { const getActiveTheme = (id: string, isDark?: boolean) => { switch (id) { - case 'nextui': + case "nextui": return; - case 'modern': + case "modern": return isDark ? darkModernTheme : lightModernTheme; - case 'elegant': + case "elegant": return isDark ? darkElegantTheme : lightElegantTheme; - case 'retro': + case "retro": return isDark ? darkRetroTheme : lightRetroTheme; default: return; } }; -const ShopCard: React.FC<Props> = ({ onChangeTheme }) => { +const ShopCard: React.FC<Props> = ({onChangeTheme}) => { const [activeTheme, setActiveTheme] = React.useState(themes[0].id); const [activeSize, setActiveSize] = React.useState(sizes[0].id); const [liked, setLiked] = React.useState(false); - const { isDark } = useTheme(); + const {isDark} = useTheme(); const animations = get(framerAnimations, activeTheme); - const theme = useMemo( - () => getActiveTheme(activeTheme, isDark), - [activeTheme, isDark] - ); + const theme = useMemo(() => getActiveTheme(activeTheme, isDark), [activeTheme, isDark]); const handleChangeTheme = (id: string) => { setActiveTheme(id); @@ -76,14 +66,14 @@ const ShopCard: React.FC<Props> = ({ onChangeTheme }) => { }; return ( - <Box className={theme} css={{ ov: 'visible' }}> - <Grid.Container gap={5} css={{ py: 0 }}> - {themes.map(({ id, title, icon }, index) => ( + <Box className={theme} css={{ov: "visible"}}> + <Grid.Container css={{py: 0}} gap={5}> + {themes.map(({id, title, icon}, index) => ( <GridItem key={`${id}-${index}`} - css={{ pl: 0, '@xs': { mr: '$10' } }} - onClick={() => handleChangeTheme(id)} + css={{pl: 0, "@xs": {mr: "$10"}}} selected={activeTheme === id} + onClick={() => handleChangeTheme(id)} > {icon()} <TabText>{title}</TabText> @@ -92,87 +82,72 @@ const ShopCard: React.FC<Props> = ({ onChangeTheme }) => { </Grid.Container> <Spacer y={0.1} /> <StyledCard> - <Card.Body css={{ px: '$8', position: 'relative', ov: 'visible' }}> - <StyledStar - size={30} - liked={liked} - onClick={() => setLiked(!liked)} - /> + <Card.Body css={{px: "$8", position: "relative", ov: "visible"}}> + <StyledStar liked={liked} size={30} onClick={() => setLiked(!liked)} /> <Grid.Container> <Grid - sm={4} css={{ - '@smMax': { - mr: '$10' + "@smMax": { + mr: "$10", + }, + "@xsMax": { + width: "100%", + mr: "0 !important", }, - '@xsMax': { - width: '100%', - mr: '0 !important' - } }} + sm={4} > - <ProductImageContainer - as={motion.div} - animate={animations.productContainer} - > + <ProductImageContainer animate={animations.productContainer} as={motion.div}> <ProductImage src="/images/shoes-1.png" /> </ProductImageContainer> </Grid> <Grid - sm={8} css={{ - px: '$10', - position: 'relative', - zIndex: '$10', - '@xsMax': { - py: '$8' - } + px: "$10", + position: "relative", + zIndex: "$10", + "@xsMax": { + py: "$8", + }, }} + sm={8} > <Col as="nav"> - <StyledTitle as={motion.h4} animate={animations.title}> + <StyledTitle animate={animations.title} as={motion.h4}> Nike Adapt BB 2.0 </StyledTitle> - <StyledSubtitle as={motion.p} animate={animations.subtitle}> + <StyledSubtitle animate={animations.subtitle} as={motion.p}> Consistent, customized fit, game-changing. </StyledSubtitle> - <Row css={{ py: '$4' }}> - <StyledPrice as={motion.p} animate={animations.price}> + <Row css={{py: "$4"}}> + <StyledPrice animate={animations.price} as={motion.p}> $279.97 </StyledPrice> - <StyledOldPrice as={motion.p} animate={animations.oldPrice}> + <StyledOldPrice animate={animations.oldPrice} as={motion.p}> $350 </StyledOldPrice> - <StyledDiscount as={motion.p} animate={animations.discount}> + <StyledDiscount animate={animations.discount} as={motion.p}> 20% off </StyledDiscount> </Row> - <Grid.Container gap={2} css={{ py: '$4' }}> - {sizes.map(({ id, title }, index) => ( - <Grid - key={`${id}-${index}`} - css={{ pl: 0 }} - onClick={() => setActiveSize(id)} - > + <Grid.Container css={{py: "$4"}} gap={2}> + {sizes.map(({id, title}, index) => ( + <Grid key={`${id}-${index}`} css={{pl: 0}} onClick={() => setActiveSize(id)}> <ProductSize + animate={animations.productSizeButton} as={motion.div} selected={activeSize === id} - animate={animations.productSizeButton} - transition={{ duration: 0.1 }} + transition={{duration: 0.1}} > - <Text - b - size={14} - css={{ textAlign: 'center', color: 'currentColor' }} - > + <Text b css={{textAlign: "center", color: "currentColor"}} size={14}> {title} </Text> </ProductSize> </Grid> ))} </Grid.Container> - <Row css={{ pt: '$4' }}> - <BuyButton auto shadow={activeTheme === 'nextui'}> + <Row css={{pt: "$4"}}> + <BuyButton auto shadow={activeTheme === "nextui"}> Buy now </BuyButton> <Spacer x={0.5} /> diff --git a/apps/docs/src/components/templates/shop-card/styles.ts b/apps/docs/src/components/templates/shop-card/styles.ts index 2fd69757db..e048109007 100644 --- a/apps/docs/src/components/templates/shop-card/styles.ts +++ b/apps/docs/src/components/templates/shop-card/styles.ts @@ -1,337 +1,339 @@ -import { styled, Grid, Button, Card } from '@nextui-org/react'; -import { darkTheme, lightTheme } from '@theme/shared'; +import {styled, Grid, Button, Card} from "@nextui-org/react"; +import {darkTheme, lightTheme} from "@theme/shared"; + +import {Star} from "../../icons"; + import { lightModernTheme, lightElegantTheme, lightRetroTheme, darkModernTheme, darkElegantTheme, - darkRetroTheme -} from './themes'; -import { Star } from '../../icons'; + darkRetroTheme, +} from "./themes"; export const StyledCard = styled(Card, { - py: '$2', - mt: '$8', - boxShadow: '$md', - br: '35px', - ov: 'visible', + py: "$2", + mt: "$8", + boxShadow: "$md", + br: "35px", + ov: "visible", [`.${darkElegantTheme} &, .${lightElegantTheme} &`]: { - br: '4px' + br: "4px", }, [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - br: '0px' + br: "0px", }, [`.${lightRetroTheme} &`]: { - bg: '#F4E8D1' + bg: "#F4E8D1", }, [`.${darkRetroTheme} &`]: { - bg: '#E1CA9E' - } + bg: "#E1CA9E", + }, }); export const GridItem = styled(Grid, { - d: 'flex', - fd: 'column', - justifyContent: 'center', - cursor: 'pointer', - transition: '$default', - '&:hover': { - opacity: 0.8 - }, - ai: 'center', + d: "flex", + fd: "column", + justifyContent: "center", + cursor: "pointer", + transition: "$default", + "&:hover": { + opacity: 0.8, + }, + ai: "center", [`.${darkTheme} &`]: { - color: '#666' + color: "#666", }, [`.${lightTheme} &`]: { - color: '#B0B0B0' + color: "#B0B0B0", }, variants: { selected: { true: { [`.${darkTheme} &`]: { - color: '$primary' + color: "$primary", }, [`.${lightTheme} &`]: { - color: '$primary' - } - } - } - } + color: "$primary", + }, + }, + }, + }, }); -export const TabText = styled('p', { +export const TabText = styled("p", { m: 0, - mt: '$3', - fontSize: '$space$8', - fontWeight: '$semibold', - color: 'currentColor' + mt: "$3", + fontSize: "$space$8", + fontWeight: "$semibold", + color: "currentColor", }); -export const ProductImageContainer = styled('div', { - d: 'flex', - minHeight: '200px', - width: '200px', - br: '32px', - position: 'relative', - background: 'linear-gradient(135deg, #010187 0%,#18000E 100%)', - '@xsMax': { - width: '100%' +export const ProductImageContainer = styled("div", { + d: "flex", + minHeight: "200px", + width: "200px", + br: "32px", + position: "relative", + background: "linear-gradient(135deg, #010187 0%,#18000E 100%)", + "@xsMax": { + width: "100%", }, [`.${darkModernTheme} &, .${lightModernTheme} &, .${darkElegantTheme} &, .${lightElegantTheme} &`]: { - ml: '-$4', - transform: 'scale(1.2)', - background: 'linear-gradient(135deg, #870172 0%,#18000E 100%)', - boxShadow: '20px 30px 60px rgba(0, 0, 0, 0.15)', - '@xsMax': { - ml: '10%', - my: '$12', - width: '80%', - bs: '$md' - } + ml: "-$4", + transform: "scale(1.2)", + background: "linear-gradient(135deg, #870172 0%,#18000E 100%)", + boxShadow: "20px 30px 60px rgba(0, 0, 0, 0.15)", + "@xsMax": { + ml: "10%", + my: "$12", + width: "80%", + bs: "$md", + }, }, [`.${darkElegantTheme} &, .${lightElegantTheme} &`]: { - background: 'linear-gradient(135deg, #323232 0%,#000000 100%)' + background: "linear-gradient(135deg, #323232 0%,#000000 100%)", }, [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - background: ' #FFD34E', - top: '5%', - left: '5%', - '@xsMax': { - width: '94%', - mb: '$8' + background: " #FFD34E", + top: "5%", + left: "5%", + "@xsMax": { + width: "94%", + mb: "$8", + }, + "&:after": { + content: "", + position: "absolute", + top: "-5%", + left: "-5%", + size: "100%", + background: "linear-gradient(135deg, #FFD34E 0%,#EE457E 100%)", }, - '&:after': { - content: '', - position: 'absolute', - top: '-5%', - left: '-5%', - size: '100%', - background: 'linear-gradient(135deg, #FFD34E 0%,#EE457E 100%)' - } - } + }, }); -export const ProductImage = styled('img', { - minWidth: '200%', - position: 'absolute', - zIndex: '$10', +export const ProductImage = styled("img", { + minWidth: "200%", + position: "absolute", + zIndex: "$10", top: 0, - left: '-45%', - '@xsMax': { - left: '0', - minWidth: '100%' + left: "-45%", + "@xsMax": { + left: "0", + minWidth: "100%", }, [`.${darkModernTheme} &, .${lightModernTheme} &, .${darkElegantTheme} &, .${lightElegantTheme} &`]: { - top: '12%', - left: '-20%', - minWidth: '140%', - '@xsMax': { - top: '15%', + top: "12%", + left: "-20%", + minWidth: "140%", + "@xsMax": { + top: "15%", left: 0, - minWidth: '100%' - } + minWidth: "100%", + }, }, [`.${darkElegantTheme} &, .${lightElegantTheme} &`]: { - filter: 'saturate(0)' + filter: "saturate(0)", }, [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - top: '-10%', - left: '-50%', - '@xsMax': { - top: '5%', - left: '-5%' - } - } + top: "-10%", + left: "-50%", + "@xsMax": { + top: "5%", + left: "-5%", + }, + }, }); -export const ProductSize = styled('div', { - color: '$text', - fontSize: '$xs', - dflex: 'center', - fontWeight: '$bold', - width: '30px', - height: '30px', - position: 'relative', +export const ProductSize = styled("div", { + color: "$text", + fontSize: "$xs", + dflex: "center", + fontWeight: "$bold", + width: "30px", + height: "30px", + position: "relative", zIndex: 10, - borderRadius: '$sm', - cursor: 'pointer', - transition: 'background 0.3s ease 0s, border-radius 0.3s ease 0s', + borderRadius: "$sm", + cursor: "pointer", + transition: "background 0.3s ease 0s, border-radius 0.3s ease 0s", [`.${darkModernTheme} &, .${lightModernTheme} &`]: { - color: '#A258DF' + color: "#A258DF", }, [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - color: '#333333' + color: "#333333", }, variants: { selected: { true: { - background: '$primary', - color: '$white', + background: "$primary", + color: "$white", [`.${darkModernTheme} &, .${lightModernTheme} &`]: { - color: '$white' + color: "$white", }, [`.${darkElegantTheme} &`]: { - color: '$black' + color: "$black", }, [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - color: '$white', - bg: '$error' - } - } - } - } + color: "$white", + bg: "$error", + }, + }, + }, + }, }); export const StyledStar = styled(Star, { - position: 'absolute', - top: '$6', - right: '$8', - zIndex: '$max', - cursor: 'pointer', - '@xsMax': { - top: '$11', - right: '$11' - }, - '& path': { - stroke: '$accents4', - fill: 'transparent' - }, - '&:hover': { - '& path': { - stroke: '$yellow700' - } + position: "absolute", + top: "$6", + right: "$8", + zIndex: "$max", + cursor: "pointer", + "@xsMax": { + top: "$11", + right: "$11", + }, + "& path": { + stroke: "$accents4", + fill: "transparent", + }, + "&:hover": { + "& path": { + stroke: "$yellow700", + }, }, [`.${darkModernTheme} &, .${lightModernTheme} &`]: { - top: '$4', - left: '$4', - '@xsMax': { - top: '$14', - left: '$14' - } + top: "$4", + left: "$4", + "@xsMax": { + top: "$14", + left: "$14", + }, }, [`.${darkElegantTheme} &, .${lightElegantTheme} &`]: { - top: '$4', - left: '28%', - '@xsMax': { - top: '$14', - left: '$14' - } + top: "$4", + left: "28%", + "@xsMax": { + top: "$14", + left: "$14", + }, }, [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - '@xsMax': { - top: '$10', - right: '$16', - '& path': { - stroke: 'rgba(255,255,255,0.5)' - } - } + "@xsMax": { + top: "$10", + right: "$16", + "& path": { + stroke: "rgba(255,255,255,0.5)", + }, + }, }, variants: { liked: { true: { - '& path': { - fill: '$yellow600', - stroke: '$yellow600' + "& path": { + fill: "$yellow600", + stroke: "$yellow600", + }, + "&:hover": { + "& path": { + fill: "$yellow600", + }, }, - '&:hover': { - '& path': { - fill: '$yellow600' - } - } }, false: { [`.${darkModernTheme} &, .${lightModernTheme} &`]: { - '& path': { - stroke: '$gray300' - } - } - } - } - } + "& path": { + stroke: "$gray300", + }, + }, + }, + }, + }, }); -const BaseText = styled('p', { +const BaseText = styled("p", { p: 0, m: 0, - transformOrigin: 'left', + transformOrigin: "left", [`.${darkElegantTheme} &, .${lightElegantTheme} &`]: { - fontFamily: '$mono', - fontWeight: '$normal' + fontFamily: "$mono", + fontWeight: "$normal", }, [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - textTransform: 'uppercase' - } + textTransform: "uppercase", + }, }); export const StyledTitle = styled(BaseText, { - transformOrigin: 'left', + transformOrigin: "left", [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - color: '$black' - } + color: "$black", + }, }); export const StyledSubtitle = styled(BaseText, { - color: '$accents7', - fontWeight: '$semibold', - fontSize: '$base', + color: "$accents7", + fontWeight: "$semibold", + fontSize: "$base", [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - fontSize: '$xs' + fontSize: "$xs", }, [`.${darkRetroTheme} &`]: { - color: '$accents4' - } + color: "$accents4", + }, }); export const StyledPrice = styled(BaseText, { - fontSize: '18px', - fontWeight: '$bold', + fontSize: "18px", + fontWeight: "$bold", [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - color: '$black' - } + color: "$black", + }, }); export const StyledOldPrice = styled(BaseText, { - ml: '$8', - textDecorationLine: 'line-through', - fontWeight: '$semibold', - fontSize: '18px', - color: '$accents6', + ml: "$8", + textDecorationLine: "line-through", + fontWeight: "$semibold", + fontSize: "18px", + color: "$accents6", [`.${darkRetroTheme} &`]: { - color: '$accents5' - } + color: "$accents5", + }, }); export const StyledDiscount = styled(BaseText, { - ml: '$4', - color: '$success', - fontSize: '18px', - fontWeight: '$semibold', + ml: "$4", + color: "$success", + fontSize: "18px", + fontWeight: "$semibold", [`.${darkRetroTheme} &`]: { - color: '$accents5' - } + color: "$accents5", + }, }); export const BuyButton = styled(Button, { - ov: 'hidden', - tt: 'none', - transition: '$default', + ov: "hidden", + tt: "none", + transition: "$default", [`.${darkModernTheme} &, .${lightModernTheme} &`]: { - borderRadius: '$pill' + borderRadius: "$pill", }, [`.${darkElegantTheme} &, .${darkRetroTheme} &, .${lightRetroTheme} &`]: { - color: '$black' + color: "$black", }, [`.${darkRetroTheme} &, .${lightRetroTheme} &`]: { - textTransform: 'uppercase', - fontWeight: '$bold' - } + textTransform: "uppercase", + fontWeight: "$bold", + }, }); export const AddToBagButton = styled(BuyButton, { [`.${darkElegantTheme} &`]: { - color: '$white' - } + color: "$white", + }, }); diff --git a/apps/docs/src/components/templates/shop-card/themes.ts b/apps/docs/src/components/templates/shop-card/themes.ts index 7e1e4121fc..e1f8c8508b 100644 --- a/apps/docs/src/components/templates/shop-card/themes.ts +++ b/apps/docs/src/components/templates/shop-card/themes.ts @@ -1,79 +1,79 @@ -import { createTheme } from '@nextui-org/react'; +import {createTheme} from "@nextui-org/react"; export const lightModernTheme = createTheme({ - type: 'light', - className: 'light-modern', + type: "light", + className: "light-modern", theme: { colors: { - primary: '#7928CA', - primaryLight: '#d9c2f0', - success: '#FF1CF7' - } - } + primary: "#7928CA", + primaryLight: "#d9c2f0", + success: "#FF1CF7", + }, + }, }); export const darkModernTheme = createTheme({ - type: 'dark', - className: 'dark-modern', + type: "dark", + className: "dark-modern", theme: { colors: { - primary: '#7928CA', - primaryLight: '#582A87', - success: '#FF1CF7' - } - } + primary: "#7928CA", + primaryLight: "#582A87", + success: "#FF1CF7", + }, + }, }); export const lightElegantTheme = createTheme({ - type: 'light', - className: 'light-elegant', + type: "light", + className: "light-elegant", theme: { colors: { - primary: '#000000', - primaryLight: '#AAAAAA', - success: '#a2a2a2' + primary: "#000000", + primaryLight: "#AAAAAA", + success: "#a2a2a2", }, radii: { - md: '4px' - } - } + md: "4px", + }, + }, }); export const darkElegantTheme = createTheme({ - type: 'dark', - className: 'dark-elegant', + type: "dark", + className: "dark-elegant", theme: { colors: { - primary: '#ffffff', - primaryLight: '#222222', - success: '#a2a2a2' + primary: "#ffffff", + primaryLight: "#222222", + success: "#a2a2a2", }, radii: { - md: '4px' - } - } + md: "4px", + }, + }, }); export const lightRetroTheme = createTheme({ - type: 'light', - className: 'light-retro', + type: "light", + className: "light-retro", theme: { colors: { - primary: '#FFD34E', - primaryLight: 'transparent', - error: '#EE457E' - } - } + primary: "#FFD34E", + primaryLight: "transparent", + error: "#EE457E", + }, + }, }); export const darkRetroTheme = createTheme({ - type: 'dark', - className: 'dark-retro', + type: "dark", + className: "dark-retro", theme: { colors: { - primary: '#FFD34E', - primaryLight: 'transparent', - error: '#EE457E' - } - } + primary: "#FFD34E", + primaryLight: "transparent", + error: "#EE457E", + }, + }, }); diff --git a/apps/docs/src/components/templates/user-twitter-card/index.tsx b/apps/docs/src/components/templates/user-twitter-card/index.tsx index 682fbace81..f4c35f8ef4 100644 --- a/apps/docs/src/components/templates/user-twitter-card/index.tsx +++ b/apps/docs/src/components/templates/user-twitter-card/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, {useState} from "react"; import { useTheme, Avatar, @@ -9,9 +9,9 @@ import { Button, Spacer, Grid, - CSS -} from '@nextui-org/react'; -import withDefaults from '@utils/with-defaults'; + CSS, +} from "@nextui-org/react"; +import withDefaults from "@utils/with-defaults"; interface Props { avatarUrl?: string; @@ -20,10 +20,10 @@ interface Props { } const defaultProps = { - avatarUrl: '/avatars/avatar-2.png' + avatarUrl: "/avatars/avatar-2.png", }; -export type UserTwitterCardProps = Props & { css?: CSS }; +export type UserTwitterCardProps = Props & {css?: CSS}; const UserTwitterCard: React.FC<UserTwitterCardProps> = ({ avatarUrl, @@ -32,43 +32,36 @@ const UserTwitterCard: React.FC<UserTwitterCardProps> = ({ onClick, ...props }) => { - const { theme } = useTheme(); + const {theme} = useTheme(); const [following, setFollowing] = useState(false); return ( <Grid.Container className="user-twitter-card__container" css={{ - mw: '250px', - borderRadius: '$lg', - padding: '$sm', - ...(css as any) + mw: "250px", + borderRadius: "$lg", + padding: "$sm", + ...(css as any), }} onClick={onClick} {...props} > - <Row justify="space-between" align="center"> + <Row align="center" justify="space-between"> <Col span={3}> - <Avatar - size="lg" - src={avatarUrl} - color="gradient" - bordered - squared - {...avatarProps} - /> + <Avatar bordered squared color="gradient" size="lg" src={avatarUrl} {...avatarProps} /> </Col> <Col span={9}> <Row> - <Grid xs={12} direction="column"> - <Text className="user-twitter-card__text" b size={15}> + <Grid direction="column" xs={12}> + <Text b className="user-twitter-card__text" size={15}> Zoey Lang </Text> <Text className="user-twitter-card__text" - size={14} - css={{ mt: '-$3' }} color={theme?.colors?.accents7?.value} + css={{mt: "-$3"}} + size={14} > @zoeylang </Text> @@ -76,18 +69,18 @@ const UserTwitterCard: React.FC<UserTwitterCardProps> = ({ <Button auto rounded - onClick={() => setFollowing(!following)} + bordered={following} + color="primary" css={{ - maxHeight: '$space$12', - fs: '$xs', - fontWeight: '$semibold', - borderColor: following ? '$foreground' : '$primary', - color: following ? '$foreground' : '$white' + maxHeight: "$space$12", + fs: "$xs", + fontWeight: "$semibold", + borderColor: following ? "$foreground" : "$primary", + color: following ? "$foreground" : "$white", }} - color="primary" - bordered={following} + onClick={() => setFollowing(!following)} > - {following ? 'Unfollow' : 'Follow'} + {following ? "Unfollow" : "Follow"} </Button> </Row> </Col> @@ -96,9 +89,9 @@ const UserTwitterCard: React.FC<UserTwitterCardProps> = ({ <Grid xs={12}> <Text className="user-twitter-card__text" - size={14} - css={{ mt: '$1' }} color={theme?.colors?.accents6?.value} + css={{mt: "$1"}} + size={14} > Full-stack developer, @getnextui lover she/her 🎉 </Text> @@ -106,37 +99,19 @@ const UserTwitterCard: React.FC<UserTwitterCardProps> = ({ </Grid.Container> <Grid.Container + alignContent="center" className="user-twitter-card__metrics-container" justify="flex-start" - alignContent="center" > - <Text - className="user-twitter-card__text" - size={14} - color={theme?.colors?.accents7?.value} - > - <Text - b - color="foreground" - className="user-twitter-card__text" - size={14} - > + <Text className="user-twitter-card__text" color={theme?.colors?.accents7?.value} size={14}> + <Text b className="user-twitter-card__text" color="foreground" size={14}> 4 </Text>  Following </Text> <Spacer inline x={0.5} /> - <Text - className="user-twitter-card__text" - size={14} - color={theme?.colors?.accents7?.value} - > - <Text - b - color="foreground" - className="user-twitter-card__text" - size={14} - > + <Text className="user-twitter-card__text" color={theme?.colors?.accents7?.value} size={14}> + <Text b className="user-twitter-card__text" color="foreground" size={14}> 97.1K </Text>  Followers diff --git a/apps/docs/src/components/theme-switch/index.tsx b/apps/docs/src/components/theme-switch/index.tsx index 667f69ecf0..44e7330103 100644 --- a/apps/docs/src/components/theme-switch/index.tsx +++ b/apps/docs/src/components/theme-switch/index.tsx @@ -1,25 +1,27 @@ -import React from 'react'; -import { Moon } from '../icons'; -import { Switch, SwitchProps, useTheme } from '@nextui-org/react'; -import { useTheme as useNextTheme } from 'next-themes'; +import React from "react"; +import {Switch, SwitchProps, useTheme} from "@nextui-org/react"; +import {useTheme as useNextTheme} from "next-themes"; -export const ThemeToggle: React.FC<Partial<SwitchProps>> = ({ ...props }) => { +import {Moon} from "../icons"; + +export const ThemeToggle: React.FC<Partial<SwitchProps>> = ({...props}) => { const [isSelfDark, setIsSelfDark] = React.useState(false); - const { setTheme } = useNextTheme(); - const { isDark } = useTheme(); + const {setTheme} = useNextTheme(); + const {isDark} = useTheme(); const handleToggleTheme = () => { - const nextTheme = isDark ? 'light' : 'dark'; - setIsSelfDark(nextTheme === 'dark'); + const nextTheme = isDark ? "light" : "dark"; + + setIsSelfDark(nextTheme === "dark"); setTheme(nextTheme); }; return ( <Switch - size="xl" checked={isSelfDark || isDark} icon={<Moon filled />} + size="xl" onChange={handleToggleTheme} {...props} /> diff --git a/apps/docs/src/components/theme-toggle/index.tsx b/apps/docs/src/components/theme-toggle/index.tsx index f9f70def8b..61709ab37b 100644 --- a/apps/docs/src/components/theme-toggle/index.tsx +++ b/apps/docs/src/components/theme-toggle/index.tsx @@ -1,53 +1,54 @@ -import React from 'react'; -import cn from 'classnames'; -import { Moon, Sun } from '../icons'; -import { CSS, styled, useTheme } from '@nextui-org/react'; -import { useTheme as useNextTheme } from 'next-themes'; -import Blockholder from '../blockholder'; -import useIsMounted from '@hooks/use-is-mounted'; +import React from "react"; +import cn from "classnames"; +import {CSS, styled, useTheme} from "@nextui-org/react"; +import {useTheme as useNextTheme} from "next-themes"; +import useIsMounted from "@hooks/use-is-mounted"; + +import Blockholder from "../blockholder"; +import {Moon, Sun} from "../icons"; interface Props { className?: string; css?: CSS; } -const StyledButton = styled('button', { - dflex: 'center', - size: 'auto', - cursor: 'pointer', - background: 'transparent', - border: 'none', +const StyledButton = styled("button", { + dflex: "center", + size: "auto", + cursor: "pointer", + background: "transparent", + border: "none", padding: 0, - '& .theme-selector-icon': { - color: '$colors$accents6' + "& .theme-selector-icon": { + color: "$colors$accents6", + }, + "@xsMax": { + px: "$2", }, - '@xsMax': { - px: '$2' - } }); -export const ThemeToggle: React.FC<Props> = ({ className, css }) => { +export const ThemeToggle: React.FC<Props> = ({className, css}) => { const isMounted = useIsMounted(); - const { setTheme } = useNextTheme(); - const { isDark } = useTheme(); + const {setTheme} = useNextTheme(); + const {isDark} = useTheme(); if (!isMounted) { return ( // to avoid layout shift on initial render - <Blockholder alt="toggle theme placeholder" width="32px" height="20px" /> + <Blockholder alt="toggle theme placeholder" height="20px" width="32px" /> ); } const handleToggleTheme = () => { - setTheme(isDark ? 'light' : 'dark'); + setTheme(isDark ? "light" : "dark"); }; return ( <StyledButton aria-label="toggle a light and dark color scheme" - className={cn('theme-selector-container', className)} - onClick={handleToggleTheme} + className={cn("theme-selector-container", className)} css={css} + onClick={handleToggleTheme} > {isDark ? ( <Sun filled className="theme-selector-icon" size={20} /> diff --git a/apps/docs/src/components/vercel-callout/index.ts b/apps/docs/src/components/vercel-callout/index.ts index 022bb4fee2..64b91e047b 100644 --- a/apps/docs/src/components/vercel-callout/index.ts +++ b/apps/docs/src/components/vercel-callout/index.ts @@ -1,3 +1,3 @@ -import VercelCallout from './vercel-callout'; +import VercelCallout from "./vercel-callout"; export default VercelCallout; diff --git a/apps/docs/src/components/vercel-callout/vercel-callout.tsx b/apps/docs/src/components/vercel-callout/vercel-callout.tsx index d3cf2c616e..238d62c3da 100644 --- a/apps/docs/src/components/vercel-callout/vercel-callout.tsx +++ b/apps/docs/src/components/vercel-callout/vercel-callout.tsx @@ -1,30 +1,30 @@ -import React from 'react'; -import { VercelLogo } from '@components'; -import { Link, Text } from '@nextui-org/react'; -import { darkTheme, lightTheme } from '@theme/shared'; +import React from "react"; +import {VercelLogo} from "@components"; +import {Link, Text} from "@nextui-org/react"; +import {darkTheme, lightTheme} from "@theme/shared"; const VercelCallout: React.FC<unknown> = () => { return ( <Link - target="_blank" - rel="noopener noreferrer" - href="https://www.vercel.com?utm_source=nextui&utm_marketing=oss" css={{ - mt: '$6', - d: 'flex', - jc: 'flex-end', - ai: 'center', - '& svg': { + mt: "$6", + d: "flex", + jc: "flex-end", + ai: "center", + "& svg": { [`.${darkTheme} &`]: { - color: '$white' + color: "$white", }, [`.${lightTheme} &`]: { - color: '$black' - } - } + color: "$black", + }, + }, }} + href="https://www.vercel.com?utm_source=nextui&utm_marketing=oss" + rel="noopener noreferrer" + target="_blank" > - <Text b css={{ my: 0, mr: '$4' }}> + <Text b css={{my: 0, mr: "$4"}}> Sponsored by </Text> <VercelLogo height={18} /> diff --git a/apps/docs/src/hooks/use-docs-route.ts b/apps/docs/src/hooks/use-docs-route.ts index 9d921668bc..944981e4c0 100644 --- a/apps/docs/src/hooks/use-docs-route.ts +++ b/apps/docs/src/hooks/use-docs-route.ts @@ -1,14 +1,16 @@ -import { Route, RouteContext } from '@lib/docs/page'; +import {Route, RouteContext} from "@lib/docs/page"; const getRouteContext = ( routes: Route[], currentRoute?: Route, - ctx: RouteContext = {} + ctx: RouteContext = {}, ): RouteContext => { const path = currentRoute?.path; - const { parent } = ctx; + const {parent} = ctx; + for (let i = 0; i < routes?.length; i += 1) { const route = routes[i]; + if (route.routes) { ctx.parent = route; ctx = getRouteContext(route.routes, currentRoute, ctx); @@ -18,9 +20,7 @@ const getRouteContext = ( if (!route.path) continue; if (ctx.route) { ctx.nextRoute = - parent && i === 0 - ? { ...route, title: `${parent.title}: ${route.title}` } - : route; + parent && i === 0 ? {...route, title: `${parent.title}: ${route.title}`} : route; return ctx; } @@ -29,17 +29,18 @@ const getRouteContext = ( ...currentRoute, title: parent && !parent.heading - ? `${parent.title}: ${currentRoute?.title}` || '' - : currentRoute?.title || '' + ? `${parent.title}: ${currentRoute?.title}` || "" + : currentRoute?.title || "", }; // Continue the loop until we know the next route continue; } ctx.prevRoute = parent && !parent.heading && !routes[i + 1]?.path - ? { ...route, title: `${parent.title}: ${route.title}` } + ? {...route, title: `${parent.title}: ${route.title}`} : route; } + return ctx; }; @@ -49,9 +50,10 @@ const getRouteContext = ( const useDocsRoute = ( routes: Route[], currentRoute?: Route, - ctx: RouteContext = {} + ctx: RouteContext = {}, ): RouteContext => { getRouteContext(routes, currentRoute, ctx); + // The loop ended and the previous route was found, or nothing return ctx; }; diff --git a/apps/docs/src/hooks/use-dom-clean.ts b/apps/docs/src/hooks/use-dom-clean.ts index 41eff8ddd4..5bae0d3393 100644 --- a/apps/docs/src/hooks/use-dom-clean.ts +++ b/apps/docs/src/hooks/use-dom-clean.ts @@ -1,9 +1,9 @@ -import { useEffect } from 'react'; +import {useEffect} from "react"; const useDomClean = (): void => { useEffect(() => { - document.documentElement.removeAttribute('style'); - document.body.removeAttribute('style'); + document.documentElement.removeAttribute("style"); + document.body.removeAttribute("style"); }, []); }; diff --git a/apps/docs/src/hooks/use-is-mounted.ts b/apps/docs/src/hooks/use-is-mounted.ts index 3b3bcb078b..d2a315afff 100644 --- a/apps/docs/src/hooks/use-is-mounted.ts +++ b/apps/docs/src/hooks/use-is-mounted.ts @@ -1,10 +1,12 @@ -import { useEffect, useState } from 'react'; +import {useEffect, useState} from "react"; function useIsMounted() { const [isMounted, setIsMounted] = useState(false); + useEffect(() => { setIsMounted(true); }, []); + return isMounted; } diff --git a/apps/docs/src/hooks/use-local-storage.ts b/apps/docs/src/hooks/use-local-storage.ts index 8be68847fe..dd703adf76 100644 --- a/apps/docs/src/hooks/use-local-storage.ts +++ b/apps/docs/src/hooks/use-local-storage.ts @@ -1,21 +1,23 @@ -import { useState } from 'react'; +import {useState} from "react"; // Hook function useLocalStorage<T>(key: string, initialValue: T) { // State to store our value // Pass initial state function to useState so logic is only executed once const [storedValue, setStoredValue] = useState<T>(() => { - if (typeof window === 'undefined') { + if (typeof window === "undefined") { return initialValue; } try { // Get from local storage by key const item = window.localStorage.getItem(key); + // Parse stored json or if none return initialValue return item ? JSON.parse(item) : initialValue; } catch (error) { // If error also return initialValue console.log(error); + return initialValue; } }); @@ -24,12 +26,12 @@ function useLocalStorage<T>(key: string, initialValue: T) { const setValue = (value: T | ((val: T) => T)) => { try { // Allow value to be a function so we have same API as useState - const valueToStore = - value instanceof Function ? value(storedValue) : value; + const valueToStore = value instanceof Function ? value(storedValue) : value; + // Save state setStoredValue(valueToStore); // Save to local storage - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { window.localStorage.setItem(key, JSON.stringify(valueToStore)); } } catch (error) { @@ -37,6 +39,7 @@ function useLocalStorage<T>(key: string, initialValue: T) { console.log(error); } }; + return [storedValue, setValue] as const; } diff --git a/apps/docs/src/hooks/use-media-query.ts b/apps/docs/src/hooks/use-media-query.ts index 9c43ade196..8e52c8c967 100644 --- a/apps/docs/src/hooks/use-media-query.ts +++ b/apps/docs/src/hooks/use-media-query.ts @@ -1,4 +1,4 @@ -import { useState, useCallback, useEffect } from 'react'; +import {useState, useCallback, useEffect} from "react"; export const useMediaQuery = (width: number): boolean => { const [targetReached, setTargetReached] = useState(false); @@ -13,6 +13,7 @@ export const useMediaQuery = (width: number): boolean => { useEffect(() => { const media = window.matchMedia(`(max-width: ${width}px)`); + media.addListener(updateTarget); // Check on mount (callback is not called until a change occurs) diff --git a/apps/docs/src/hooks/use-portal.ts b/apps/docs/src/hooks/use-portal.ts index 37fa772933..7a8d63495f 100644 --- a/apps/docs/src/hooks/use-portal.ts +++ b/apps/docs/src/hooks/use-portal.ts @@ -1,21 +1,25 @@ -import { useEffect, useState } from 'react'; -import useSSR from './use-ssr'; -import { getId } from '../utils/collections'; +import {useEffect, useState} from "react"; + +import {getId} from "../utils/collections"; + +import useSSR from "./use-ssr"; const createElement = (id: string): HTMLElement => { - const el = document.createElement('div'); - el.setAttribute('id', id); + const el = document.createElement("div"); + + el.setAttribute("id", id); + return el; }; const usePortal = ( selectId: string = getId(), - getContainer?: () => HTMLElement | null + getContainer?: () => HTMLElement | null, ): HTMLElement | null => { const id = `nextui-${selectId}`; - const { isBrowser } = useSSR(); + const {isBrowser} = useSSR(); const [elSnapshot, setElSnapshot] = useState<HTMLElement | null>( - isBrowser ? createElement(id) : null + isBrowser ? createElement(id) : null, ); useEffect(() => { diff --git a/apps/docs/src/hooks/use-scroll-spy.ts b/apps/docs/src/hooks/use-scroll-spy.ts index cbe1717944..84e967c8bd 100644 --- a/apps/docs/src/hooks/use-scroll-spy.ts +++ b/apps/docs/src/hooks/use-scroll-spy.ts @@ -1,27 +1,25 @@ /* eslint-disable no-undef */ -import * as React from 'react'; +import * as React from "react"; -export function useScrollSpy( - selectors: string[], - options?: IntersectionObserverInit -) { +export function useScrollSpy(selectors: string[], options?: IntersectionObserverInit) { const [activeId, setActiveId] = React.useState<string | null>(); const observer = React.useRef<IntersectionObserver>(); + React.useEffect(() => { - const elements = selectors.map((selector) => - document.querySelector(selector) - ); + const elements = selectors.map((selector) => document.querySelector(selector)); + if (observer.current) { observer.current.disconnect(); } observer.current = new IntersectionObserver((entries) => { entries.forEach((entry) => { if (entry?.isIntersecting) { - setActiveId(entry.target.getAttribute('id')); + setActiveId(entry.target.getAttribute("id")); } }); }, options); elements.forEach((el) => el && observer.current?.observe(el)); + return () => observer.current?.disconnect(); }, [selectors]); diff --git a/apps/docs/src/hooks/use-ssr.ts b/apps/docs/src/hooks/use-ssr.ts index 2cda094f4b..25819f7ce8 100644 --- a/apps/docs/src/hooks/use-ssr.ts +++ b/apps/docs/src/hooks/use-ssr.ts @@ -1,11 +1,7 @@ -import { useEffect, useState } from 'react'; +import {useEffect, useState} from "react"; const isBrowser = (): boolean => { - return Boolean( - typeof window !== 'undefined' && - window.document && - window.document.createElement - ); + return Boolean(typeof window !== "undefined" && window.document && window.document.createElement); }; export type SSRState = { @@ -15,6 +11,7 @@ export type SSRState = { const useSSR = (): SSRState => { const [browser, setBrowser] = useState<boolean>(false); + useEffect(() => { setBrowser(isBrowser()); }, []); diff --git a/apps/docs/src/layouts/default.tsx b/apps/docs/src/layouts/default.tsx index c0e73ed461..fa1d7cecee 100644 --- a/apps/docs/src/layouts/default.tsx +++ b/apps/docs/src/layouts/default.tsx @@ -1,10 +1,11 @@ -import React from 'react'; -import { Container } from '@nextui-org/react'; -import { NotifyBanner } from '@components'; -import { Route } from '@lib/docs/page'; -import Header from './header'; -import Footer from './footer'; -import Navbar from './navbar'; +import React from "react"; +import {Container} from "@nextui-org/react"; +import {NotifyBanner} from "@components"; +import {Route} from "@lib/docs/page"; + +import Header from "./header"; +import Footer from "./footer"; +import Navbar from "./navbar"; export interface Props { routes: Route[]; @@ -13,32 +14,26 @@ export interface Props { slug?: string; } -const DefaultLayout: React.FC<React.PropsWithChildren<Props>> = ({ - children, - routes -}) => { +const DefaultLayout: React.FC<React.PropsWithChildren<Props>> = ({children, routes}) => { return ( <div id="app-container"> <Header /> - <NotifyBanner - text="Dropdown component" - href="/docs/components/dropdown" - /> - <Navbar isHome hasNotify routes={routes} /> + <NotifyBanner href="/docs/components/dropdown" text="Dropdown component" /> + <Navbar hasNotify isHome routes={routes} /> <Container - lg={true} - id="main-container" - display="flex" - as="main" alignContent="space-between" + as="main" className="main-container" css={{ - position: 'relative', - minHeight: '100vh', - '@mdMax': { - overflowX: 'hidden' - } + position: "relative", + minHeight: "100vh", + "@mdMax": { + overflowX: "hidden", + }, }} + display="flex" + id="main-container" + lg={true} > {children} <Footer /> diff --git a/apps/docs/src/layouts/docs.tsx b/apps/docs/src/layouts/docs.tsx index fa555a58d9..9d97aa466e 100644 --- a/apps/docs/src/layouts/docs.tsx +++ b/apps/docs/src/layouts/docs.tsx @@ -1,20 +1,21 @@ -import React, { useState, useEffect } from 'react'; -import Navbar from './navbar'; -import Footer from './footer'; -import { Container, Row, Col } from '@nextui-org/react'; -import NextLink from 'next/link'; -import { Route } from '@lib/docs/page'; -import { Sidebar, TableOfContent } from '@components'; -import { Link } from '@nextui-org/react'; -import { Heading, getHeadings } from '@utils/get-headings'; -import { MetaProps } from '@lib/docs/meta'; -import Header from '@layouts/header'; -import { Fixed, PageNav } from '@components'; -import { REPO_NAME, GITHUB_URL } from '@lib/github/constants'; -import { TAG, CONTENT_PATH } from '@lib/docs/config'; -import { StyledImg } from '@primitives'; -import { darkTheme } from '@theme/shared'; -import { appears } from '@utils/animations'; +import React, {useState, useEffect} from "react"; +import {Container, Row, Col} from "@nextui-org/react"; +import NextLink from "next/link"; +import {Route} from "@lib/docs/page"; +import {Sidebar, TableOfContent} from "@components"; +import {Link} from "@nextui-org/react"; +import {Heading, getHeadings} from "@utils/get-headings"; +import {MetaProps} from "@lib/docs/meta"; +import Header from "@layouts/header"; +import {Fixed, PageNav} from "@components"; +import {REPO_NAME, GITHUB_URL} from "@lib/github/constants"; +import {TAG, CONTENT_PATH} from "@lib/docs/config"; +import {StyledImg} from "@primitives"; +import {darkTheme} from "@theme/shared"; +import {appears} from "@utils/animations"; + +import Footer from "./footer"; +import Navbar from "./navbar"; export interface Props { routes: Route[]; @@ -34,7 +35,7 @@ const DocsLayout: React.FC<React.PropsWithChildren<Props>> = ({ currentRoute, tag, slug, - meta + meta, }) => { const [headings, setHeadings] = useState<Heading[]>([]); @@ -48,70 +49,70 @@ const DocsLayout: React.FC<React.PropsWithChildren<Props>> = ({ <div id="app-container"> <Navbar routes={routes} /> <Container - lg={true} as="main" - id="main-container" className="docs__container" + css={{position: "relative"}} display="flex" - css={{ position: 'relative' }} + id="main-container" + lg={true} > <Header {...meta} /> <Row className="docs__content" - gap={0} css={{ - '@lg': { - pt: '1rem' - } + "@lg": { + pt: "1rem", + }, }} + gap={0} > <Col css={{ - width: '32%', - display: 'none', - '@md': { - display: 'block' - } + width: "32%", + display: "none", + "@md": { + display: "block", + }, }} > <Fixed - offset={92} className="docs__left-sidebar" css={{ - maxHeight: 'calc(100vh - 4rem)', - overflow: 'auto', - zIndex: '$2', - pb: '$28', - '&::-webkit-scrollbar': { - width: '0px' - } + maxHeight: "calc(100vh - 4rem)", + overflow: "auto", + zIndex: "$2", + pb: "$28", + "&::-webkit-scrollbar": { + width: "0px", + }, }} + offset={92} > - <Sidebar routes={routes} tag={tag} slug={slug} /> + <Sidebar routes={routes} slug={slug} tag={tag} /> </Fixed> </Col> <Col className="docs__center" css={{ - zIndex: '$10', - maxWidth: '100%', - overflow: 'auto', - '@xsMax': { - p: 0 - } + zIndex: "$10", + maxWidth: "100%", + overflow: "auto", + "@xsMax": { + p: 0, + }, }} > {children} - <PageNav tag={tag} prevRoute={prevRoute} nextRoute={nextRoute} /> + <PageNav nextRoute={nextRoute} prevRoute={prevRoute} tag={tag} /> <footer> {tag ? ( - <NextLink href={slug || ''}> + <NextLink href={slug || ""}> <Link> <small>Go to the live version of this page</small> </Link> </NextLink> ) : ( - <a href={editUrl} target="_blank" rel="noopener noreferrer"> + <a href={editUrl} rel="noopener noreferrer" target="_blank"> <small>Edit this page on GitHub</small> </a> )} @@ -119,72 +120,72 @@ const DocsLayout: React.FC<React.PropsWithChildren<Props>> = ({ </Col> <Col css={{ - width: '28%', - height: '100%', - display: 'none', - '@lg': { - display: 'block' - } + width: "28%", + height: "100%", + display: "none", + "@lg": { + display: "block", + }, }} > <Fixed - offset={92} className="docs__right-sidebar" css={{ - width: '100%', - zIndex: '$2', - pb: '$20', - '&::-webkit-scrollbar': { - width: '0px' - } + width: "100%", + zIndex: "$2", + pb: "$20", + "&::-webkit-scrollbar": { + width: "0px", + }, }} + offset={92} > <TableOfContent headings={headings} /> </Fixed> </Col> <StyledImg - className="docs__gradient-blue" - src="/gradient-left-dark.svg" alt="gradient blue background" + className="docs__gradient-blue" css={{ - display: 'none', + display: "none", opacity: 0, - position: 'fixed', - zIndex: '$1', - bottom: '-50%', - left: '-10%', - right: '-50%', + position: "fixed", + zIndex: "$1", + bottom: "-50%", + left: "-10%", + right: "-50%", animation: `${appears} 200ms 100ms ease forwards`, [`.${darkTheme} &`]: { - display: 'block' - } + display: "block", + }, }} + src="/gradient-left-dark.svg" /> <StyledImg - className="docs__gradient-violet" - src="/gradient-right-dark.svg" alt="gradient violet background" + className="docs__gradient-violet" css={{ - display: 'none', + display: "none", top: 0, opacity: 0, - position: 'fixed', + position: "fixed", animation: `${appears} 200ms 100ms ease forwards`, - '@lg': { - top: '-50%', - right: '-50%' + "@lg": { + top: "-50%", + right: "-50%", }, - '@mdMax': { - top: '-35%', - right: '-45%' + "@mdMax": { + top: "-35%", + right: "-45%", }, [`.${darkTheme} &`]: { - display: 'block' - } + display: "block", + }, }} + src="/gradient-right-dark.svg" /> </Row> - <Footer css={{ jc: 'flex-end' }} /> + <Footer css={{jc: "flex-end"}} /> </Container> </div> ); diff --git a/apps/docs/src/layouts/footer.tsx b/apps/docs/src/layouts/footer.tsx index 6b3d505b29..031358e649 100644 --- a/apps/docs/src/layouts/footer.tsx +++ b/apps/docs/src/layouts/footer.tsx @@ -1,29 +1,29 @@ -import React from 'react'; -import { Container, Row, Text, Link, CSS } from '@nextui-org/react'; -import { VercelCallout } from '@components'; +import React from "react"; +import {Container, Row, Text, Link, CSS} from "@nextui-org/react"; +import {VercelCallout} from "@components"; export interface Props { css?: CSS; containerCss?: CSS; } -const Footer: React.FC<Props> = ({ css, containerCss }) => { +const Footer: React.FC<Props> = ({css, containerCss}) => { // const year = new Date().getFullYear(); return ( <Container fluid className="footer__container" - gap={2} css={{ - zIndex: '$1', - padding: '$md $sm', - '@xsMax': { - padding: '$sm $xs' + zIndex: "$1", + padding: "$md $sm", + "@xsMax": { + padding: "$sm $xs", }, - ...containerCss + ...containerCss, }} + gap={2} > - <Row justify="center" css={css}> + <Row css={css} justify="center"> {/* <Text span className="footer__copy" @@ -42,11 +42,11 @@ const Footer: React.FC<Props> = ({ css, containerCss }) => { span className="footer__by" css={{ - fontSize: '$xs', - color: '$accents7', - '@mdMax': { - fontSize: '$xs' - } + fontSize: "$xs", + color: "$accents7", + "@mdMax": { + fontSize: "$xs", + }, }} > Created by  @@ -55,7 +55,7 @@ const Footer: React.FC<Props> = ({ css, containerCss }) => { </Link> </Text> </Row> - <Row justify="center" css={css}> + <Row css={css} justify="center"> <VercelCallout /> </Row> </Container> diff --git a/apps/docs/src/layouts/header.tsx b/apps/docs/src/layouts/header.tsx index dd4b372133..a97e9ef18f 100644 --- a/apps/docs/src/layouts/header.tsx +++ b/apps/docs/src/layouts/header.tsx @@ -1,9 +1,9 @@ -import React from 'react'; -import Head from 'next/head'; -import withDefaults from '@utils/with-defaults'; -import { toCapitalize } from '@utils/index'; -import { TWITTER_USER_NAME, SITE_URL } from '@lib/constants'; -import { useTheme } from '@nextui-org/react'; +import React from "react"; +import Head from "next/head"; +import withDefaults from "@utils/with-defaults"; +import {toCapitalize} from "@utils/index"; +import {TWITTER_USER_NAME, SITE_URL} from "@lib/constants"; +import {useTheme} from "@nextui-org/react"; export interface HeaderProps { title?: string; @@ -13,8 +13,8 @@ export interface HeaderProps { } const defaultProps = { - description: 'Make beautiful websites regardless of your design experience.', - image: '/twitter-cards/nextui.jpeg' + description: "Make beautiful websites regardless of your design experience.", + image: "/twitter-cards/nextui.jpeg", }; if (global.document) { @@ -26,71 +26,50 @@ if (global.document) { } } -const Header: React.FC<HeaderProps> = ({ title, description, image, url }) => { - const { theme, isDark } = useTheme(); +const Header: React.FC<HeaderProps> = ({title, description, image, url}) => { + const {theme, isDark} = useTheme(); + + let pageTitle = title ? `${toCapitalize(title)} | ` : ""; + + pageTitle += "NextUI - Beautiful, fast and modern React UI Library"; - let pageTitle = title ? `${toCapitalize(title)} | ` : ''; - pageTitle += 'NextUI - Beautiful, fast and modern React UI Library'; return ( <Head> <title>{pageTitle} - - + + {image && ( )} - - {url && } - - + + {url && } + + - - - - - + + + + + ); diff --git a/apps/docs/src/layouts/navbar.tsx b/apps/docs/src/layouts/navbar.tsx index cb53d252da..f4e06dbd61 100644 --- a/apps/docs/src/layouts/navbar.tsx +++ b/apps/docs/src/layouts/navbar.tsx @@ -1,35 +1,20 @@ -import React, { useState, useEffect } from 'react'; -import { - Logo, - MenuToggle, - Badge, - Twitter, - Discord, - Github, - ThemeToggle, - Heart -} from '@components'; -import { Box } from '@primitives'; -import cn from 'classnames'; -import NextLink from 'next/link'; -import dynamic from 'next/dynamic'; -import { - Row, - Col, - Spacer, - Link, - Button, - useBodyScroll -} from '@nextui-org/react'; -import { Route } from '@lib/docs/page'; -import { Container } from '@nextui-org/react'; -import { useRouter } from 'next/router'; -import { useMediaQuery } from '@hooks/use-media-query'; -import { isActive } from '@utils/links'; -import { includes } from 'lodash'; -import { StyledNavContainer, StyledNavMainContainer } from './styles'; -import { darkTheme } from '@theme/shared'; -import { pulse } from '@utils/animations'; +import React, {useState, useEffect} from "react"; +import {Logo, MenuToggle, Badge, Twitter, Discord, Github, ThemeToggle, Heart} from "@components"; +import {Box} from "@primitives"; +import cn from "classnames"; +import NextLink from "next/link"; +import dynamic from "next/dynamic"; +import {Row, Col, Spacer, Link, Button, useBodyScroll} from "@nextui-org/react"; +import {Route} from "@lib/docs/page"; +import {Container} from "@nextui-org/react"; +import {useRouter} from "next/router"; +import {useMediaQuery} from "@hooks/use-media-query"; +import {isActive} from "@utils/links"; +import {includes} from "lodash"; +import {darkTheme} from "@theme/shared"; +import {pulse} from "@utils/animations"; + +import {StyledNavContainer, StyledNavMainContainer} from "./styles"; export interface Props { routes?: Route[]; @@ -37,36 +22,29 @@ export interface Props { isHome?: boolean; } -const MobileNavigation = dynamic( - () => import('../components/mobile-navigation'), - { - ssr: false - } -); +const MobileNavigation = dynamic(() => import("../components/mobile-navigation"), { + ssr: false, +}); -const SearchInput = dynamic( - () => import('../components/search/instant-search'), - { - ssr: true - } -); +const SearchInput = dynamic(() => import("../components/search/instant-search"), { + ssr: true, +}); -const Navbar: React.FC = ({ isHome, hasNotify, routes }) => { +const Navbar: React.FC = ({isHome, hasNotify, routes}) => { const [expanded, setExpanded] = useState(false); const router = useRouter(); const isMobile = useMediaQuery(960); - const [, setBodyHidden] = useBodyScroll(null, { scrollLayer: true }); + const [, setBodyHidden] = useBodyScroll(null, {scrollLayer: true}); const [scrollPosition, setScrollPosition] = useState(0); const detached = hasNotify ? scrollPosition > 30 : scrollPosition > 0; useEffect(() => { - setScrollPosition( - (typeof window !== 'undefined' && window.pageYOffset) || 0 - ); - window.addEventListener('scroll', onScroll.bind(this)); + setScrollPosition((typeof window !== "undefined" && window.pageYOffset) || 0); + window.addEventListener("scroll", onScroll.bind(this)); + return () => { - window.removeEventListener('scroll', onScroll.bind(this)); + window.removeEventListener("scroll", onScroll.bind(this)); }; }, []); @@ -93,30 +71,24 @@ const Navbar: React.FC = ({ isHome, hasNotify, routes }) => { return ( - + - + @@ -125,10 +97,10 @@ const Navbar: React.FC = ({ isHome, hasNotify, routes }) => { @@ -136,27 +108,24 @@ const Navbar: React.FC = ({ isHome, hasNotify, routes }) => { - - + + Docs @@ -165,17 +134,17 @@ const Navbar: React.FC = ({ isHome, hasNotify, routes }) => { Components @@ -183,13 +152,13 @@ const Navbar: React.FC = ({ isHome, hasNotify, routes }) => { Feedback @@ -197,97 +166,97 @@ const Navbar: React.FC = ({ isHome, hasNotify, routes }) => { @@ -296,39 +265,36 @@ const Navbar: React.FC = ({ isHome, hasNotify, routes }) => { @@ -337,38 +303,35 @@ const Navbar: React.FC = ({ isHome, hasNotify, routes }) => { - + { setExpanded(false); setBodyHidden(false); diff --git a/apps/docs/src/layouts/styles.ts b/apps/docs/src/layouts/styles.ts index dfb5e867a7..7be8afdb4c 100644 --- a/apps/docs/src/layouts/styles.ts +++ b/apps/docs/src/layouts/styles.ts @@ -1,40 +1,39 @@ -import { styled } from '@nextui-org/react'; +import {styled} from "@nextui-org/react"; -export const StyledNavMainContainer = styled('nav', { +export const StyledNavMainContainer = styled("nav", { top: 0, - height: '76px', - position: 'sticky', - background: 'transparent', - zIndex: '$max' + height: "76px", + position: "sticky", + background: "transparent", + zIndex: "$max", }); -export const StyledNavContainer = styled('div', { - display: 'flex', - alignItems: 'center', - size: '100%', - '& .navbar__social-icon': { - fill: '$colors$accents6' +export const StyledNavContainer = styled("div", { + display: "flex", + alignItems: "center", + size: "100%", + "& .navbar__social-icon": { + fill: "$colors$accents6", }, variants: { showBlur: { true: { - background: '$background', - '@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none))': - { - background: '$headerBackground' - } - } + background: "$background", + "@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none))": { + background: "$headerBackground", + }, + }, }, detached: { true: { - backdropFilter: 'saturate(180%) blur(10px)', - boxShadow: '0px 5px 20px -5px rgba(2, 1, 1, 0.1)' + backdropFilter: "saturate(180%) blur(10px)", + boxShadow: "0px 5px 20px -5px rgba(2, 1, 1, 0.1)", }, false: { - backdropFilter: 'none', - boxShadow: 'none', - background: 'transparent' - } - } - } + backdropFilter: "none", + boxShadow: "none", + background: "transparent", + }, + }, + }, }); diff --git a/apps/docs/src/lib/constants.ts b/apps/docs/src/lib/constants.ts index b99a54f9a8..2a19fa6882 100644 --- a/apps/docs/src/lib/constants.ts +++ b/apps/docs/src/lib/constants.ts @@ -1,2 +1,2 @@ -export const TWITTER_USER_NAME = 'getnextui'; -export const SITE_URL = 'https://nextui.org'; +export const TWITTER_USER_NAME = "getnextui"; +export const SITE_URL = "https://nextui.org"; diff --git a/apps/docs/src/lib/docs/config.ts b/apps/docs/src/lib/docs/config.ts index 388caaae0a..c6984c911d 100644 --- a/apps/docs/src/lib/docs/config.ts +++ b/apps/docs/src/lib/docs/config.ts @@ -1,9 +1,9 @@ // Tag to use if FORCE_TAG is enabled (only for production build) -export const TAG = 'main'; // Github branch +export const TAG = "main"; // Github branch -export const CONTENT_PATH = '/apps/docs/content'; +export const CONTENT_PATH = "/apps/docs/content"; -export const ASSETS_PATH = '/apps/docs/public'; +export const ASSETS_PATH = "/apps/docs/public"; // If a version different from the latest release is required, update TAG with the wanted // version and set this to `true` diff --git a/apps/docs/src/lib/docs/page.ts b/apps/docs/src/lib/docs/page.ts index a6e0af9342..a3f7667f4d 100644 --- a/apps/docs/src/lib/docs/page.ts +++ b/apps/docs/src/lib/docs/page.ts @@ -1,8 +1,9 @@ -import { TAG, FORCE_TAG, CONTENT_PATH, ASSETS_PATH } from './config'; -import { getLatestTag } from '@lib/github/api'; -import { getRawFileFromRepo, getRawAssetFromRepo } from '@lib/github/raw'; -import { isProd, removeFromLast } from '@utils/index'; -import localManifest from '@content/docs/manifest.json'; +import {getLatestTag} from "@lib/github/api"; +import {getRawFileFromRepo, getRawAssetFromRepo} from "@lib/github/raw"; +import {isProd, removeFromLast} from "@utils/index"; +import localManifest from "@content/docs/manifest.json"; + +import {TAG, FORCE_TAG, CONTENT_PATH, ASSETS_PATH} from "./config"; export interface Route { title: string; @@ -27,17 +28,18 @@ export interface RouteContext { } export interface Carry { - params: { slug: any }; + params: {slug: any}; } export async function getCurrentTag(tag?: string) { if (tag) return tag; if (FORCE_TAG) return TAG; + return getLatestTag(); } export function addTagToSlug(slug: string, tag?: string) { - return tag ? slug.replace('/docs', `/docs/tag/${tag}`) : slug; + return tag ? slug.replace("/docs", `/docs/tag/${tag}`) : slug; } export async function fetchRawDoc(doc: string, tag: string) { @@ -47,10 +49,8 @@ export async function fetchRawDoc(doc: string, tag: string) { export async function fetchDocsManifest(tag: string) { if (!isProd) return localManifest; - const res = await getRawFileFromRepo( - `${CONTENT_PATH}/docs/manifest.json`, - tag - ); + const res = await getRawFileFromRepo(`${CONTENT_PATH}/docs/manifest.json`, tag); + return JSON.parse(res); } @@ -58,29 +58,24 @@ export function getRawAsset(doc: string, tag: string) { return getRawAssetFromRepo(`${ASSETS_PATH}${doc}`, tag); } -export function findRouteByPath( - path: string, - routes: Route[] -): Route | null | undefined { +export function findRouteByPath(path: string, routes: Route[]): Route | null | undefined { for (const route of routes) { - if (route.path && removeFromLast(route.path, '.') === path) { + if (route.path && removeFromLast(route.path, ".") === path) { return route; } const childPath = route.routes ? findRouteByPath(path, route.routes) : null; + if (childPath) return childPath; } } -export function getPaths( - nextRoutes: Route[], - carry: Carry[] = [{ params: { slug: [] } }] -) { +export function getPaths(nextRoutes: Route[], carry: Carry[] = [{params: {slug: []}}]) { nextRoutes.forEach((route: Route) => { if (route.comingSoon) { return; } if (route.path) { - carry.push(removeFromLast(route.path, '.') as Carry); + carry.push(removeFromLast(route.path, ".") as Carry); } else if (route.routes) { getPaths(route.routes, carry); } diff --git a/apps/docs/src/lib/docs/utils.ts b/apps/docs/src/lib/docs/utils.ts index b4566a08e6..da40db9a0e 100644 --- a/apps/docs/src/lib/docs/utils.ts +++ b/apps/docs/src/lib/docs/utils.ts @@ -1,4 +1,4 @@ -import { ParsedUrlQuery } from 'querystring'; +import {ParsedUrlQuery} from "querystring"; export type SlugParams = ParsedUrlQuery | undefined; @@ -9,18 +9,19 @@ export interface SlugResponse { // Handle optional catch all route for `/docs` function getDocsSlug(slug: any): any { - return slug?.length ? slug : ['getting-started']; + return slug?.length ? slug : ["getting-started"]; } export function getSlug(params: SlugParams): SlugResponse { // Handle optional catch all route for `/docs` const slug = getDocsSlug(params?.slug); - if (slug[0] === 'tag') { + + if (slug[0] === "tag") { return { - slug: `/docs/${getDocsSlug(slug.slice(2)).join('/')}`, + slug: `/docs/${getDocsSlug(slug.slice(2)).join("/")}`, tag: slug[1], }; } - return { slug: `/docs/${slug.join('/')}` }; + return {slug: `/docs/${slug.join("/")}`}; } diff --git a/apps/docs/src/lib/get-algolia.ts b/apps/docs/src/lib/get-algolia.ts index 671580878c..0e3fe3a27f 100644 --- a/apps/docs/src/lib/get-algolia.ts +++ b/apps/docs/src/lib/get-algolia.ts @@ -1,8 +1,8 @@ -import algoliasearch from 'algoliasearch/lite'; -import { SearchOptions, MultipleQueriesQuery } from '@algolia/client-search'; +import algoliasearch from "algoliasearch/lite"; +import {SearchOptions, MultipleQueriesQuery} from "@algolia/client-search"; -const appId = process.env.NEXT_PUBLIC_ALGOLIA_APP_ID || ''; -const apiKey = process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY || ''; +const appId = process.env.NEXT_PUBLIC_ALGOLIA_APP_ID || ""; +const apiKey = process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY || ""; interface Request { params: SearchOptions; @@ -15,7 +15,7 @@ export default function getAlgoliaClient() { return { async search(requests: SearchRequest[]) { - if (requests.every(({ params: { query } }) => Boolean(query) === false)) { + if (requests.every(({params: {query}}) => Boolean(query) === false)) { return { results: requests.map(() => { return { diff --git a/apps/docs/src/lib/github/api.ts b/apps/docs/src/lib/github/api.ts index 4dd4986ac6..3656a4a3ea 100644 --- a/apps/docs/src/lib/github/api.ts +++ b/apps/docs/src/lib/github/api.ts @@ -1,16 +1,17 @@ -import { GITHUB_API_URL, REPO_NAME } from './constants'; -import { getError } from './utils'; +import {GITHUB_API_URL, REPO_NAME} from "./constants"; +import {getError} from "./utils"; export async function getLatestTag() { let lastestTag: string; - const res = await fetch( - `${GITHUB_API_URL}/repos/${REPO_NAME}/releases/latest` - ); + const res = await fetch(`${GITHUB_API_URL}/repos/${REPO_NAME}/releases/latest`); + if (res.ok) { const data = await res.json(); + lastestTag = data.tag_name; } else { - throw await getError('GitHub latest tag fetch failed', res); + throw await getError("GitHub latest tag fetch failed", res); } + return lastestTag; } diff --git a/apps/docs/src/lib/github/constants.ts b/apps/docs/src/lib/github/constants.ts index ee1c9dfc75..0536a72f20 100644 --- a/apps/docs/src/lib/github/constants.ts +++ b/apps/docs/src/lib/github/constants.ts @@ -1,9 +1,9 @@ -export const GITHUB_URL = 'https://github.com'; +export const GITHUB_URL = "https://github.com"; -export const GITHUB_API_URL = 'https://api.github.com'; +export const GITHUB_API_URL = "https://api.github.com"; -export const RAW_GITHUB_URL = 'https://raw.githubusercontent.com'; +export const RAW_GITHUB_URL = "https://raw.githubusercontent.com"; -export const REPO_NAME = 'nextui-org/nextui'; +export const REPO_NAME = "nextui-org/nextui"; export const ISSUE_REPORT_URL = `${GITHUB_URL}/${REPO_NAME}/issues/new?assignees=&labels=bug&template=bug_report.yml&title=%5BBUG%5D+-+`; diff --git a/apps/docs/src/lib/github/raw.ts b/apps/docs/src/lib/github/raw.ts index 6e50dc540a..adbd0dc205 100644 --- a/apps/docs/src/lib/github/raw.ts +++ b/apps/docs/src/lib/github/raw.ts @@ -1,11 +1,11 @@ -import { RAW_GITHUB_URL, REPO_NAME } from './constants'; -import { getError } from './utils'; +import {RAW_GITHUB_URL, REPO_NAME} from "./constants"; +import {getError} from "./utils"; export async function getRawFileFromGitHub(path: string) { const res = await fetch(RAW_GITHUB_URL + path); if (res.ok) return res.text(); - throw await getError('GitHub raw download error', res); + throw await getError("GitHub raw download error", res); } export function getRawFileFromRepo(path: string, tag: string) { diff --git a/apps/docs/src/lib/github/utils.ts b/apps/docs/src/lib/github/utils.ts index 8198c6caf1..e0674d04cb 100644 --- a/apps/docs/src/lib/github/utils.ts +++ b/apps/docs/src/lib/github/utils.ts @@ -1,7 +1,7 @@ export interface GithubError extends Error { url: string; status: number; - headers: Response['headers']; + headers: Response["headers"]; } function getErrorText(res: Response) { @@ -14,9 +14,7 @@ function getErrorText(res: Response) { export async function getError(msg: string, res: Response) { const errorText = await getErrorText(res); - const error = new Error( - `${msg} (${res.status}): ${errorText}` - ) as GithubError; + const error = new Error(`${msg} (${res.status}): ${errorText}`) as GithubError; error.url = res.url; error.status = res.status; diff --git a/apps/docs/src/lib/kbar-actions.ts b/apps/docs/src/lib/kbar-actions.ts index 0d7ff4e4c0..2d4afc0b06 100644 --- a/apps/docs/src/lib/kbar-actions.ts +++ b/apps/docs/src/lib/kbar-actions.ts @@ -1,32 +1,30 @@ -import { Action } from 'kbar'; -import { NextRouter } from 'next/router'; -import { Route } from '@lib/docs/page'; -import { getId } from '../utils/collections'; -import { removeFromLast } from '@utils/index'; -import { ThemeType, changeTheme } from '@nextui-org/react'; +import {Action} from "kbar"; +import {NextRouter} from "next/router"; +import {Route} from "@lib/docs/page"; +import {removeFromLast} from "@utils/index"; +import {ThemeType, changeTheme} from "@nextui-org/react"; + +import {getId} from "../utils/collections"; // data imported from manifest -import docsManifest from '../../content/docs/manifest.json'; +import docsManifest from "../../content/docs/manifest.json"; const docsActions: Action[] = []; -const buildDocsActions = ( - router: NextRouter, - routes: Route[], - parent?: string -) => { +const buildDocsActions = (router: NextRouter, routes: Route[], parent?: string) => { routes.forEach((route: Route) => { const routeId = getId(); - const routePath: any = route.path ? removeFromLast(route.path, '.') : null; + const routePath: any = route.path ? removeFromLast(route.path, ".") : null; const action: Action = { id: routeId, name: route.title, - section: route.section || '', + section: route.section || "", parent: parent, shortcut: [], children: [], - keywords: route.keywords || '', - subtitle: route.subtitle || '' + keywords: route.keywords || "", + subtitle: route.subtitle || "", }; + if (routePath) { action.perform = () => { router.push(routePath); @@ -50,10 +48,10 @@ const buildDocsActions = ( }; const handleExternalLink = (href: string) => { - Object.assign(document.createElement('a'), { - target: '_blank', - rel: 'noopener noreferrer', - href + Object.assign(document.createElement("a"), { + target: "_blank", + rel: "noopener noreferrer", + href, }).click(); }; @@ -63,67 +61,67 @@ const handleChangeTheme = (theme: ThemeType) => { const getActions = (router: NextRouter): Action[] => { const routes = docsManifest.routes; + buildDocsActions(router, routes); const staticActions: Action[] = [ { - id: 'twitter', - name: 'Twitter', - subtitle: '@getnextui', - section: 'Social', + id: "twitter", + name: "Twitter", + subtitle: "@getnextui", + section: "Social", shortcut: [], - keywords: 'dm, twitter, contact', - icon: 'twitter', - perform: () => handleExternalLink('https://twitter.com/getnextui') + keywords: "dm, twitter, contact", + icon: "twitter", + perform: () => handleExternalLink("https://twitter.com/getnextui"), }, { - id: 'discord', - name: 'Discord', - subtitle: 'Join us!', - section: 'Social', + id: "discord", + name: "Discord", + subtitle: "Join us!", + section: "Social", shortcut: [], - keywords: 'chat, community, join', - icon: 'discord', - perform: () => handleExternalLink('https://discord.gg/9b6yyZKmH4') + keywords: "chat, community, join", + icon: "discord", + perform: () => handleExternalLink("https://discord.gg/9b6yyZKmH4"), }, { - id: 'github', - name: 'Github', - subtitle: 'nextui-org', - section: 'Social', + id: "github", + name: "Github", + subtitle: "nextui-org", + section: "Social", shortcut: [], - keywords: 'github, source code, open, code', - icon: 'github', - perform: () => handleExternalLink('https://github.com/nextui-org/nextui') + keywords: "github, source code, open, code", + icon: "github", + perform: () => handleExternalLink("https://github.com/nextui-org/nextui"), }, { - id: 'changeTheme', - name: 'Change Theme', - section: 'General', + id: "changeTheme", + name: "Change Theme", + section: "General", shortcut: [], - keywords: - 'background, change color, color, change theme, theme, dark, light', - icon: 'palette', - children: ['darkTheme', 'lightTheme'] + keywords: "background, change color, color, change theme, theme, dark, light", + icon: "palette", + children: ["darkTheme", "lightTheme"], }, { - id: 'darkTheme', - name: 'Dark', - parent: 'changeTheme', - keywords: 'dark', - icon: 'moon', + id: "darkTheme", + name: "Dark", + parent: "changeTheme", + keywords: "dark", + icon: "moon", shortcut: [], - perform: () => handleChangeTheme('dark') + perform: () => handleChangeTheme("dark"), }, { - id: 'lightTheme', - name: 'Light', - parent: 'changeTheme', - keywords: 'light', + id: "lightTheme", + name: "Light", + parent: "changeTheme", + keywords: "light", shortcut: [], - icon: 'sun', - perform: () => handleChangeTheme('light') - } + icon: "sun", + perform: () => handleChangeTheme("light"), + }, ]; return [...docsActions, ...staticActions]; diff --git a/apps/docs/src/lib/rehype-highlight-line.js b/apps/docs/src/lib/rehype-highlight-line.js index d4d271d902..9d58a8f210 100644 --- a/apps/docs/src/lib/rehype-highlight-line.js +++ b/apps/docs/src/lib/rehype-highlight-line.js @@ -1,60 +1,67 @@ // Inspired by https://github.dev/modulz/stitches-site -const hastToHtml = require('hast-util-to-html'); -const unified = require('unified'); -const parse = require('rehype-parse'); +const hastToHtml = require("hast-util-to-html"); +const unified = require("unified"); +const parse = require("rehype-parse"); const lineNumberify = function lineNumberify(ast, lineNum = 1) { let lineNumber = lineNum; + return ast.reduce( (result, node) => { - if (node.type === 'text') { - if (node.value.indexOf('\n') === -1) { + if (node.type === "text") { + if (node.value.indexOf("\n") === -1) { node.lineNumber = lineNumber; result.nodes.push(node); + return result; } - const lines = node.value.split('\n'); + const lines = node.value.split("\n"); + for (let i = 0; i < lines.length; i++) { // eslint-disable-next-line no-plusplus if (i !== 0) ++lineNumber; if (i === lines.length - 1 && lines[i].length === 0) continue; result.nodes.push({ - type: 'text', + type: "text", value: i === lines.length - 1 ? lines[i] : `${lines[i]}\n`, - lineNumber: lineNumber + lineNumber: lineNumber, }); } result.lineNumber = lineNumber; + return result; } if (node.children) { node.lineNumber = lineNumber; const processed = lineNumberify(node.children, lineNumber); + node.children = processed.nodes; result.lineNumber = processed.lineNumber; result.nodes.push(node); + return result; } result.nodes.push(node); + return result; }, - { nodes: [], lineNumber: lineNumber } + {nodes: [], lineNumber: lineNumber}, ); }; const wrapLines = function wrapLines(ast, linesToHighlight) { - const highlightAll = - linesToHighlight.length === 1 && linesToHighlight[0] === 0; + const highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0; const allLines = Array.from(new Set(ast.map((x) => x.lineNumber))); let i = 0; const wrapped = allLines.reduce((nodes, marker) => { const line = marker; const children = []; + for (; i < ast.length; i++) { if (ast[i].lineNumber < line) { nodes.push(ast[i]); @@ -72,16 +79,15 @@ const wrapLines = function wrapLines(ast, linesToHighlight) { } nodes.push({ - type: 'element', - tagName: 'div', + type: "element", + tagName: "div", properties: { dataLine: line, - className: 'highlight-line', - dataHighlighted: - linesToHighlight.includes(line) || highlightAll ? 'true' : 'false' + className: "highlight-line", + dataHighlighted: linesToHighlight.includes(line) || highlightAll ? "true" : "false", }, children: children, - lineNumber: line + lineNumber: line, }); return nodes; @@ -91,8 +97,7 @@ const wrapLines = function wrapLines(ast, linesToHighlight) { }; // https://github.com/gatsbyjs/gatsby/pull/26161/files -const MULTILINE_TOKEN_SPAN = - /[^<]*\n[^<]*<\/span>/g; +const MULTILINE_TOKEN_SPAN = /[^<]*\n[^<]*<\/span>/g; const applyMultilineFix = function (ast) { // AST to HTML @@ -100,13 +105,11 @@ const applyMultilineFix = function (ast) { // Fix JSX issue html = html.replace(MULTILINE_TOKEN_SPAN, (match, token) => - match.replace(/\n/g, `\n`) + match.replace(/\n/g, `\n`), ); // HTML to AST - const hast = unified() - .use(parse, { emitParseErrors: true, fragment: true }) - .parse(html); + const hast = unified().use(parse, {emitParseErrors: true, fragment: true}).parse(html); return hast.children; }; diff --git a/apps/docs/src/lib/rehype-highlight-word.js b/apps/docs/src/lib/rehype-highlight-word.js index 55c6c3b8ce..1629b74f8e 100644 --- a/apps/docs/src/lib/rehype-highlight-word.js +++ b/apps/docs/src/lib/rehype-highlight-word.js @@ -1,17 +1,13 @@ -const hastToHtml = require('hast-util-to-html'); -const unified = require('unified'); -const parse = require('rehype-parse'); +const hastToHtml = require("hast-util-to-html"); +const unified = require("unified"); +const parse = require("rehype-parse"); const CALLOUT = /__(.*?)__/g; module.exports = (code) => { const html = hastToHtml(code); - const result = html.replace( - CALLOUT, - (_, text) => `${text}` - ); - const hast = unified() - .use(parse, { emitParseErrors: true, fragment: true }) - .parse(result); + const result = html.replace(CALLOUT, (_, text) => `${text}`); + const hast = unified().use(parse, {emitParseErrors: true, fragment: true}).parse(result); + return hast.children; }; diff --git a/apps/docs/src/lib/router-events.js b/apps/docs/src/lib/router-events.js index 26ea814a62..06183b94ab 100644 --- a/apps/docs/src/lib/router-events.js +++ b/apps/docs/src/lib/router-events.js @@ -1,17 +1,18 @@ -import mitt from 'mitt'; -import Router from 'next/router'; +import mitt from "mitt"; +import Router from "next/router"; const emitter = mitt(); + export default emitter; Router.onRouteChangeStart = (url) => { - emitter.emit('routeChangeStart', url); + emitter.emit("routeChangeStart", url); }; Router.onRouteChangeComplete = (...args) => { - emitter.emit('routeChangeComplete', ...args); + emitter.emit("routeChangeComplete", ...args); }; Router.onRouteChangeError = (...args) => { - emitter.emit('routeChangeError', ...args); + emitter.emit("routeChangeError", ...args); }; diff --git a/apps/docs/src/lib/types.ts b/apps/docs/src/lib/types.ts index 4a283d869a..9065994190 100644 --- a/apps/docs/src/lib/types.ts +++ b/apps/docs/src/lib/types.ts @@ -1,15 +1,11 @@ -import * as React from 'react'; -import { NextComponentType, NextPageContext } from 'next'; +import * as React from "react"; +import {NextComponentType, NextPageContext} from "next"; export type ComponentLayout

        = React.NamedExoticComponent

        & { Layout: React.FC; }; -export type NextComponent

        = NextComponentType< - NextPageContext, - unknown, - P -> & +export type NextComponent

        = NextComponentType & ComponentLayout; export type ReactFCLayout

        = React.FC

        & { diff --git a/apps/docs/src/pages/_app.tsx b/apps/docs/src/pages/_app.tsx index 03dbbb8f02..f96e6e8cbe 100644 --- a/apps/docs/src/pages/_app.tsx +++ b/apps/docs/src/pages/_app.tsx @@ -1,26 +1,24 @@ -import React from 'react'; -import { NextPage } from 'next'; -import dynamic from 'next/dynamic'; -import { debounce } from 'lodash'; -import { NextRouter, Router, useRouter } from 'next/router'; -import { NextUIProvider } from '@nextui-org/react'; -import { ThemeProvider as NextThemesProvider } from 'next-themes'; -import NProgress from 'nprogress'; -import PlausibleProvider from 'next-plausible'; -import { AppInitialProps } from 'next/app'; -import { NextComponent } from '@lib/types'; -import generateKbarActions from '@lib/kbar-actions'; -import { KBarProvider } from 'kbar'; -import { lightTheme, darkTheme } from '../theme/shared'; -import { isProd } from '@utils/index'; -import RouterEvents from '@lib/router-events'; -import globalStyles from '../styles/globalStyles'; -import '../styles/sandpack.css'; +import React from "react"; +import {NextPage} from "next"; +import dynamic from "next/dynamic"; +import {debounce} from "lodash"; +import {NextRouter, Router, useRouter} from "next/router"; +import {NextUIProvider} from "@nextui-org/react"; +import {ThemeProvider as NextThemesProvider} from "next-themes"; +import NProgress from "nprogress"; +import PlausibleProvider from "next-plausible"; +import {AppInitialProps} from "next/app"; +import {NextComponent} from "@lib/types"; +import generateKbarActions from "@lib/kbar-actions"; +import {KBarProvider} from "kbar"; +import {isProd} from "@utils/index"; +import RouterEvents from "@lib/router-events"; -type AppPropsType< - R extends NextRouter = NextRouter, - P = {} -> = AppInitialProps & { +import {lightTheme, darkTheme} from "../theme/shared"; +import globalStyles from "../styles/globalStyles"; +import "../styles/sandpack.css"; + +type AppPropsType = AppInitialProps & { Component: NextComponent

        ; router: R; __N_SSG?: boolean; @@ -29,35 +27,38 @@ type AppPropsType< type AppProps

        = AppPropsType; -const KbarComponent = dynamic(() => import('../components/kbar'), { - ssr: false +const KbarComponent = dynamic(() => import("../components/kbar"), { + ssr: false, }); -NProgress.configure({ parent: '#app-container' }); +NProgress.configure({parent: "#app-container"}); const start = debounce(NProgress.start, 100); -RouterEvents.on('routeChangeStart', start); -RouterEvents.on('routeChangeComplete', (url) => { + +RouterEvents.on("routeChangeStart", start); +RouterEvents.on("routeChangeComplete", (url) => { console.log(`Changed to URL: ${url}`); start.cancel(); NProgress.done(); }); -RouterEvents.on('routeChangeError', () => { +RouterEvents.on("routeChangeError", () => { start.cancel(); NProgress.done(); }); -const Application: NextPage> = ({ Component, pageProps }) => { +const Application: NextPage> = ({Component, pageProps}) => { const router = useRouter(); const kbarActions = generateKbarActions(router); + globalStyles(); + return ( @@ -67,8 +68,8 @@ const Application: NextPage> = ({ Component, pageProps }) => { options={{ animations: { enterMs: 250, - exitMs: 100 - } + exitMs: 100, + }, }} > diff --git a/apps/docs/src/pages/_document.tsx b/apps/docs/src/pages/_document.tsx index 3bf8dad163..153285acc2 100644 --- a/apps/docs/src/pages/_document.tsx +++ b/apps/docs/src/pages/_document.tsx @@ -1,13 +1,7 @@ -import React from 'react'; -import Document, { - Html, - Head, - Main, - NextScript, - DocumentContext -} from 'next/document'; -import { CssBaseline } from '@nextui-org/react'; -import flush from 'styled-jsx/server'; +import React from "react"; +import Document, {Html, Head, Main, NextScript, DocumentContext} from "next/document"; +import {CssBaseline} from "@nextui-org/react"; +import flush from "styled-jsx/server"; class MyDocument extends Document { static async getInitialProps(ctx: DocumentContext) { @@ -16,14 +10,14 @@ class MyDocument extends Document { return { ...initialProps, - styles: React.Children.toArray([initialProps.styles, styledJSXStyles]) + styles: React.Children.toArray([initialProps.styles, styledJSXStyles]), }; } render() { return ( {CssBaseline.flush()} - + = ({ routes, currentRoute, source, meta }) => { - const { route, prevRoute, nextRoute } = useDocsRoute(routes, currentRoute); - const { query } = useRouter(); - const { tag, slug } = getSlug(query); +const DocsPage: React.FC = ({routes, currentRoute, source, meta}) => { + const {route, prevRoute, nextRoute} = useDocsRoute(routes, currentRoute); + const {query} = useRouter(); + const {tag, slug} = getSlug(query); // kbar home action const homeAction: Action = React.useMemo(() => { return { id: getId(), - name: 'Go Home', - section: 'Scope', - icon: 'home', + name: "Go Home", + section: "Scope", + icon: "home", shortcut: [], - keywords: 'home, return, back, landing, page, init, initial', + keywords: "home, return, back, landing, page, init, initial", children: [], - perform: () => router.push('/') + perform: () => router.push("/"), }; }, [routes]); useRegisterActions([homeAction].filter(Boolean)); + return ( - {source && ( - - )} + {source && } ); }; @@ -85,11 +85,12 @@ export const getStaticPaths: GetStaticPaths = async () => { const tag = await getCurrentTag(); const manifest = await fetchDocsManifest(tag); const paths = getPaths(manifest.routes); - return { paths, fallback: false }; + + return {paths, fallback: false}; }; -export const getStaticProps: GetStaticProps = async ({ params }) => { - const { tag, slug } = getSlug(params); +export const getStaticProps: GetStaticProps = async ({params}) => { + const {tag, slug} = getSlug(params); const currentTag = await getCurrentTag(tag); const manifest = await fetchDocsManifest(currentTag).catch((error) => { // If a manifest wasn't found for a custom tag, show a 404 instead @@ -101,7 +102,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { if (!route) { return { - props: {} + props: {}, }; } @@ -109,35 +110,35 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { if (isProd) { const rawFileSource = await fetchRawDoc(route.path, currentTag); - const { content, data } = matter(rawFileSource); + const {content, data} = matter(rawFileSource); + doc = content.toString(); meta = data; } else { meta = null; - const folderPath = path.join(process.cwd(), 'content'); + const folderPath = path.join(process.cwd(), "content"); const filePath = path.join(folderPath, `${slug}.mdx`); const rawFileSource = fs.readFileSync(filePath); - const { content, data } = matter(rawFileSource); + const {content, data} = matter(rawFileSource); + doc = content.toString(); meta = data; } const mdxSource = await serialize(doc, { mdxOptions: { - remarkPlugins: [ - require('remark-autolink-headings'), - require('remark-slug') - ], - rehypePlugins: [require('@mapbox/rehype-prism')] - } + remarkPlugins: [require("remark-autolink-headings"), require("remark-slug")], + rehypePlugins: [require("@mapbox/rehype-prism")], + }, }); const routes = manifest.routes.map((route: any) => { if (route.icon) { return { ...route, - icon: getRawAsset(route.icon, currentTag) + icon: getRawAsset(route.icon, currentTag), }; } + return route; }); @@ -146,8 +147,8 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { routes, meta, source: mdxSource, - currentRoute: route - } + currentRoute: route, + }, }; }; diff --git a/apps/docs/src/pages/index.tsx b/apps/docs/src/pages/index.tsx index e84b6fa42b..5634e8f179 100644 --- a/apps/docs/src/pages/index.tsx +++ b/apps/docs/src/pages/index.tsx @@ -1,6 +1,6 @@ -import React from 'react'; -import { GetStaticProps } from 'next'; -import router, { useRouter } from 'next/router'; +import React from "react"; +import {GetStaticProps} from "next"; +import router, {useRouter} from "next/router"; import { FeaturesGrid, Hero, @@ -12,46 +12,41 @@ import { DarkModeSection, CustomizationSection, BuiltInStitchesSection, - LastButNotLeastSection -} from '@components'; -import landingContent from '@content/landing'; -import DefaultLayout from '@layouts/default'; -import { getSlug } from '@lib/docs/utils'; -import { Route, getCurrentTag, fetchDocsManifest } from '@lib/docs/page'; -import { Action, useRegisterActions } from 'kbar'; -import { Spacer } from '@nextui-org/react'; -import { getId } from '@utils/collections'; + LastButNotLeastSection, +} from "@components"; +import landingContent from "@content/landing"; +import DefaultLayout from "@layouts/default"; +import {getSlug} from "@lib/docs/utils"; +import {Route, getCurrentTag, fetchDocsManifest} from "@lib/docs/page"; +import {Action, useRegisterActions} from "kbar"; +import {Spacer} from "@nextui-org/react"; +import {getId} from "@utils/collections"; interface Props { routes: Route[]; currentRoute: Route; } -const IndexPage: React.FC = ({ routes, currentRoute }) => { - const { query } = useRouter(); - const { tag, slug } = getSlug(query); +const IndexPage: React.FC = ({routes, currentRoute}) => { + const {query} = useRouter(); + const {tag, slug} = getSlug(query); // kbar home action const homeAction: Action = React.useMemo(() => { return { id: getId(), - name: 'Getting started', - section: 'Scope', + name: "Getting started", + section: "Scope", shortcut: [], - keywords: 'help, docs, go, started, getting started, nextui', - perform: () => router.push('/docs/guide/getting-started') + keywords: "help, docs, go, started, getting started, nextui", + perform: () => router.push("/docs/guide/getting-started"), }; }, [routes]); useRegisterActions([homeAction]); return ( - + {/* Hero */} {/* Main features */} @@ -65,8 +60,8 @@ const IndexPage: React.FC = ({ routes, currentRoute }) => { {/* Installation banner */} -

        - +
        +
        @@ -81,10 +76,11 @@ const IndexPage: React.FC = ({ routes, currentRoute }) => { export const getStaticProps: GetStaticProps = async () => { const tag = await getCurrentTag(); const manifest = await fetchDocsManifest(tag); + return { props: { - routes: manifest.routes - } + routes: manifest.routes, + }, }; }; diff --git a/apps/docs/src/styles/globalStyles.ts b/apps/docs/src/styles/globalStyles.ts index 23b64afb29..1b10fe0051 100644 --- a/apps/docs/src/styles/globalStyles.ts +++ b/apps/docs/src/styles/globalStyles.ts @@ -1,66 +1,65 @@ -import { globalCss } from '@nextui-org/react'; +import {globalCss} from "@nextui-org/react"; export default globalCss({ html: { - scrollPaddingTop: '80px' + scrollPaddingTop: "80px", }, // css baseline overrides blockquote: { - mb: '$14 !important', - '& p': { - fontSize: '1rem !important' - } + mb: "$14 !important", + "& p": { + fontSize: "1rem !important", + }, }, // home sections - '.inview-section': { - zIndex: '$2', - width: '100%' + ".inview-section": { + zIndex: "$2", + width: "100%", }, // sandpack-react - '.sp-highlight': { - background: '$codeHighlight', - borderLeft: '2px solid $gray400' + ".sp-highlight": { + background: "$codeHighlight", + borderLeft: "2px solid $gray400", }, - '.sp-tabs': { - border: 'none !important', - borderRadius: 'inherit', + ".sp-tabs": { + border: "none !important", + borderRadius: "inherit", button: { - cursor: 'pointer' - } + cursor: "pointer", + }, }, - '.sp-layout': { - border: 'none !important', - overflow: 'visible !important', - WebkitMaskImage: 'none !important', - background: 'transparent !important' + ".sp-layout": { + border: "none !important", + overflow: "visible !important", + WebkitMaskImage: "none !important", + background: "transparent !important", }, - '.sp-pre-placeholder': { - background: 'transparent !important', - borderRadius: '0 !important' + ".sp-pre-placeholder": { + background: "transparent !important", + borderRadius: "0 !important", }, - '#nprogress': { - pointerEvents: 'none' + "#nprogress": { + pointerEvents: "none", }, - '#nprogress .bar': { - background: 'var(--nextui-colors-secondary)', - position: 'fixed', - zIndex: '999999', + "#nprogress .bar": { + background: "var(--nextui-colors-secondary)", + position: "fixed", + zIndex: "999999", top: 0, left: 0, - width: '100%', - height: '3px' + width: "100%", + height: "3px", }, /* Fancy blur effect */ - ' #nprogress .peg': { - display: 'block', - position: 'absolute', - right: '0px', - width: '100px', - height: '100%', - boxShadow: - '0 0 10px var(--nextui-colors-secondary), 0 0 5px var(--nextui-colors-secondary)', + " #nprogress .peg": { + display: "block", + position: "absolute", + right: "0px", + width: "100px", + height: "100%", + boxShadow: "0 0 10px var(--nextui-colors-secondary), 0 0 5px var(--nextui-colors-secondary)", opacity: 1, - WebkitTransform: 'rotate(3deg) translate(0px, -4px)', - transform: 'rotate(3deg) translate(0px, -4px)' - } + WebkitTransform: "rotate(3deg) translate(0px, -4px)", + transform: "rotate(3deg) translate(0px, -4px)", + }, }); diff --git a/apps/docs/src/theme/shared.ts b/apps/docs/src/theme/shared.ts index 61892b4387..d405f4d25e 100644 --- a/apps/docs/src/theme/shared.ts +++ b/apps/docs/src/theme/shared.ts @@ -1,50 +1,50 @@ -import { createTheme } from '@nextui-org/react'; +import {createTheme} from "@nextui-org/react"; const fonts = { sans: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif', - mono: 'Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace' + mono: "Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace", }; export const lightTheme = createTheme({ - type: 'light', - className: 'nextui-docs-light', + type: "light", + className: "nextui-docs-light", theme: { fonts, colors: { - headerBackground: 'hsla(0,0%,100%,0.8)', - menuBackground: 'rgba(255, 255, 255, 0.5)', - headerIconColor: '$accents4', - codeBackground: '#363449', - codeComment: '$accents7', - codeCopyIconColor: '$accents2', - cardBackground: '$white', - codeHighlight: 'hsl(243, 16%, 30%)', - backgroundBlur: 'rgba(255, 255, 255, 0.3)', - blockLinkColor: '#FF1CF7', - blockLinkBackground: '$accents1', - blockLinkHoverBackground: '#FFD1ED' - } - } + headerBackground: "hsla(0,0%,100%,0.8)", + menuBackground: "rgba(255, 255, 255, 0.5)", + headerIconColor: "$accents4", + codeBackground: "#363449", + codeComment: "$accents7", + codeCopyIconColor: "$accents2", + cardBackground: "$white", + codeHighlight: "hsl(243, 16%, 30%)", + backgroundBlur: "rgba(255, 255, 255, 0.3)", + blockLinkColor: "#FF1CF7", + blockLinkBackground: "$accents1", + blockLinkHoverBackground: "#FFD1ED", + }, + }, }); export const darkTheme = createTheme({ - type: 'dark', - className: 'nextui-docs-dark', + type: "dark", + className: "nextui-docs-dark", theme: { fonts, colors: { - menuBackground: 'rgba(0,0,0,0.8)', - headerBackground: 'rgba(0,0,0,0.5)', - headerIconColor: '$accents8', - codeBackground: '#111111', - codeComment: '$accents6', - codeCopyIconColor: '$accents7', - codeHighlight: 'hsl(0, 0%, 15%)', - cardBackground: '$accents0', - backgroundBlur: 'rgba(255, 255, 255, 0.1)', - blockLinkColor: '#FFA4E3', - blockLinkBackground: '$accents1', - blockLinkHoverBackground: '#55057A' - } - } + menuBackground: "rgba(0,0,0,0.8)", + headerBackground: "rgba(0,0,0,0.5)", + headerIconColor: "$accents8", + codeBackground: "#111111", + codeComment: "$accents6", + codeCopyIconColor: "$accents7", + codeHighlight: "hsl(0, 0%, 15%)", + cardBackground: "$accents0", + backgroundBlur: "rgba(255, 255, 255, 0.1)", + blockLinkColor: "#FFA4E3", + blockLinkBackground: "$accents1", + blockLinkHoverBackground: "#55057A", + }, + }, }); diff --git a/apps/docs/src/utils/animations.ts b/apps/docs/src/utils/animations.ts index 953fed9569..d9625f1157 100644 --- a/apps/docs/src/utils/animations.ts +++ b/apps/docs/src/utils/animations.ts @@ -1,40 +1,40 @@ -import { keyframes } from '@nextui-org/react'; +import {keyframes} from "@nextui-org/react"; export const levitating = keyframes({ - '0%': { - transform: 'translateY(0)' + "0%": { + transform: "translateY(0)", }, - '30%': { - transform: 'translateY(-10px)' + "30%": { + transform: "translateY(-10px)", }, - '50%': { - transform: 'translateY(4px)' + "50%": { + transform: "translateY(4px)", }, - '70%': { - transform: 'translateY(-15px)' + "70%": { + transform: "translateY(-15px)", + }, + "100%": { + transform: "translateY(0)", }, - '100%': { - transform: 'translateY(0)' - } }); export const appears = keyframes({ from: { - opacity: 0 + opacity: 0, }, to: { - opacity: 1 - } + opacity: 1, + }, }); export const pulse = keyframes({ - '0%': { - transform: 'scale(1)' + "0%": { + transform: "scale(1)", + }, + "50%": { + transform: "scale(1.2)", }, - '50%': { - transform: 'scale(1.2)' + "100%": { + transform: "scale(1)", }, - '100%': { - transform: 'scale(1)' - } }); diff --git a/apps/docs/src/utils/fs-utils.ts b/apps/docs/src/utils/fs-utils.ts index 556b8a7ccc..989523b6d1 100644 --- a/apps/docs/src/utils/fs-utils.ts +++ b/apps/docs/src/utils/fs-utils.ts @@ -1,5 +1,5 @@ -import fs from 'fs'; -import { promisify } from 'util'; +import fs from "fs"; +import {promisify} from "util"; export const readFile = promisify(fs.readFile); export const writeFile = promisify(fs.writeFile); diff --git a/apps/docs/src/utils/get-headings.ts b/apps/docs/src/utils/get-headings.ts index 7d2d5b2d5b..338bb5c5a9 100644 --- a/apps/docs/src/utils/get-headings.ts +++ b/apps/docs/src/utils/get-headings.ts @@ -4,13 +4,12 @@ export interface Heading { } export function getHeadings(): Heading[] { - const headings = document.getElementsByClassName( - 'linked-heading' - ) as HTMLCollection; + const headings = document.getElementsByClassName("linked-heading") as HTMLCollection; + return Array.from(headings).map((e: HTMLHtmlElement) => { return { id: e.id, - text: e.getAttribute('data-name'), + text: e.getAttribute("data-name"), }; }) as Heading[]; } diff --git a/apps/docs/src/utils/index.ts b/apps/docs/src/utils/index.ts index ede0dc32f8..b5c2c5688d 100644 --- a/apps/docs/src/utils/index.ts +++ b/apps/docs/src/utils/index.ts @@ -1,26 +1,26 @@ -import Router from 'next/router'; +import Router from "next/router"; export const isBrowser = typeof window !== `undefined`; export const getCssVar = (name?: string) => { - if (typeof document !== 'undefined' || !name) { - const property = isCssVar(name) - ? name?.replace('var(', '').replace(')', '') - : `--${name}`; - if (!property) return ''; - return getComputedStyle(document.documentElement).getPropertyValue( - property - ); + if (typeof document !== "undefined" || !name) { + const property = isCssVar(name) ? name?.replace("var(", "").replace(")", "") : `--${name}`; + + if (!property) return ""; + + return getComputedStyle(document.documentElement).getPropertyValue(property); } - return ''; + + return ""; }; export const isCssVar = (property?: string) => { - return property && property?.indexOf('var(') === 0 ? true : false; + return property && property?.indexOf("var(") === 0 ? true : false; }; export const toCapitalize = (name: string) => { const [first, ...rest] = name; - return `${first.toUpperCase()}${rest.join('')}`; + + return `${first.toUpperCase()}${rest.join("")}`; }; export const validateEmail = (value: string) => { @@ -35,47 +35,53 @@ export const validateEmail = (value: string) => { */ export const isHex = (str: string): boolean => { const exp = /#[a-fA-F0-9]{3,6}/g; + return exp.test(str); }; export function removeFromLast(path: string, key: string): string | T { const i = path.lastIndexOf(key); + return i === -1 ? path : path.substring(0, i); } export function isFunction(fn: any): boolean { - return typeof fn === 'function'; + return typeof fn === "function"; } export const isPathActive = (href: string, exact = false): boolean => { if (!isBrowser) return false; if (exact) return Router.pathname === href; + return Router.pathname.startsWith(href); }; export const hexFromString = ( str: string, - defaultColor: string = '', - returnLast = false + defaultColor: string = "", + returnLast = false, ): string | string[] => { const fullReg = /#[a-fA-F0-9]{6}|#[a-fA-F0-9]{3}$/g; const hexCodes = str.match(fullReg); + if (hexCodes && hexCodes.length > 0) { return returnLast ? hexCodes[hexCodes.length - 1] : hexCodes; } + return defaultColor; }; function padZero(str: string, len?: number): string { len = len || 2; - var zeros = new Array(len).join('0'); + var zeros = new Array(len).join("0"); + return (zeros + str).slice(-len); } export const invertHex = (hexProp: string, smooth = true) => { let hex = isCssVar(hexProp) ? getCssVar(hexProp) : hexProp; - if (hex.indexOf('#') === 0) { + if (hex.indexOf("#") === 0) { hex = hex.slice(1); } // convert 3-digit hex to 6-digits. @@ -88,21 +94,18 @@ export const invertHex = (hexProp: string, smooth = true) => { let r = parseInt(hex.slice(0, 2), 16), g = parseInt(hex.slice(2, 4), 16), b = parseInt(hex.slice(4, 6), 16); + if (smooth) { // http://stackoverflow.com/a/3943023/112731 - return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? '#000000' : '#FFFFFF'; + return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? "#000000" : "#FFFFFF"; } // invert color components r = 255 - r; g = 255 - g; b = 255 - b; + // pad each with zeros and return - return ( - '#' + - padZero(r.toString(16)) + - padZero(g.toString(16)) + - padZero(b.toString(16)) - ); + return "#" + padZero(r.toString(16)) + padZero(g.toString(16)) + padZero(b.toString(16)); }; /** @@ -115,65 +118,71 @@ export const hexToRGBA = (hex: string, alpha: number = 1): string => { let r: string | number = 0, g: string | number = 0, b: string | number = 0; + // 3 digits if (hex.length == 4) { - r = '0x' + hex[1] + hex[1]; - g = '0x' + hex[2] + hex[2]; - b = '0x' + hex[3] + hex[3]; + r = "0x" + hex[1] + hex[1]; + g = "0x" + hex[2] + hex[2]; + b = "0x" + hex[3] + hex[3]; // 6 digits } else if (hex.length == 7) { - r = '0x' + hex[1] + hex[2]; - g = '0x' + hex[3] + hex[4]; - b = '0x' + hex[5] + hex[6]; + r = "0x" + hex[1] + hex[2]; + g = "0x" + hex[3] + hex[4]; + b = "0x" + hex[5] + hex[6]; } + return `rgba(${+r}, ${+g},${+b},${alpha})`; }; export const hexToRgb = (color: string): [number, number, number] => { const fullReg = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; - const full = color.replace( - fullReg, - (_, r, g, b) => `${r}${r}${g}${g}${b}${b}` - ); + const full = color.replace(fullReg, (_, r, g, b) => `${r}${r}${g}${g}${b}${b}`); const values = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(full); + if (!values) { throw new Error(`Next UI: Unsupported ${color} color.`); } + return [ Number.parseInt(values[1], 16), Number.parseInt(values[2], 16), - Number.parseInt(values[3], 16) + Number.parseInt(values[3], 16), ]; }; export const colorToRgbValues = (color: string) => { - if (color.charAt(0) === '#') return hexToRgb(color); + if (color.charAt(0) === "#") return hexToRgb(color); - const safeColor = color.replace(/ /g, ''); + const safeColor = color.replace(/ /g, ""); const colorType = color.substr(0, 4); const regArray = safeColor.match(/\((.+)\)/); - if (!colorType.startsWith('rgb') || !regArray) { + + if (!colorType.startsWith("rgb") || !regArray) { throw new Error(`Next UI: Only support ["RGB", "RGBA", "HEX"] color.`); } - return regArray[1].split(',').map((str) => Number.parseFloat(str)); + return regArray[1].split(",").map((str) => Number.parseFloat(str)); }; export const addColorAlpha = (colorProp?: string, alpha?: number) => { if (!colorProp) return colorProp; const color = isCssVar(colorProp) ? getCssVar(colorProp) : colorProp; + if (isHex(color)) { return hexToRGBA(color, alpha); } else if (!/^#|rgb|RGB/.test(color)) { return color; } const [r, g, b] = colorToRgbValues(color); + if (alpha) { const safeAlpha = alpha > 1 ? 1 : alpha < 0 ? 0 : alpha; + return `rgba(${r}, ${g}, ${b}, ${safeAlpha})`; } + return `rgb(${r}, ${g}, ${b})`; }; -export const isProd = process.env.NODE_ENV === 'production'; +export const isProd = process.env.NODE_ENV === "production"; diff --git a/apps/docs/src/utils/links.ts b/apps/docs/src/utils/links.ts index 4ba78b2ab2..c52b24add5 100644 --- a/apps/docs/src/utils/links.ts +++ b/apps/docs/src/utils/links.ts @@ -1,2 +1 @@ -export const isActive = (pathname: string, href: string) => - pathname && pathname.startsWith(href); +export const isActive = (pathname: string, href: string) => pathname && pathname.startsWith(href); diff --git a/apps/docs/src/utils/scripts.ts b/apps/docs/src/utils/scripts.ts index 1cd4dffc55..00472f99af 100644 --- a/apps/docs/src/utils/scripts.ts +++ b/apps/docs/src/utils/scripts.ts @@ -1,14 +1,16 @@ export const loadScript = (src: string, container: HTMLElement | null) => { - const script = document.createElement('script'); - script.setAttribute('async', ''); + const script = document.createElement("script"); + + script.setAttribute("async", ""); script.src = src; container && container.appendChild(script); + return script; }; export const removeScript = ( script: HTMLScriptElement | HTMLElement, - container: HTMLElement | null + container: HTMLElement | null, ) => { if (script.parentNode != container) return; container && container?.removeChild(script); diff --git a/apps/docs/src/utils/types.d.ts b/apps/docs/src/utils/types.d.ts deleted file mode 100644 index 4d4f6790ff..0000000000 --- a/apps/docs/src/utils/types.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type DeepPartial = { - [P in keyof T]?: T[P] extends - Record ? DeepPartial : T[P] - } - \ No newline at end of file diff --git a/apps/docs/src/utils/types.ts b/apps/docs/src/utils/types.ts deleted file mode 100644 index e94e1ae20b..0000000000 --- a/apps/docs/src/utils/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type DeepPartial = { - [P in keyof T]?: T[P] extends Record - ? DeepPartial - : T[P]; -}; diff --git a/apps/docs/src/utils/with-defaults.ts b/apps/docs/src/utils/with-defaults.ts index 3ef56b7b4e..b91d13130c 100644 --- a/apps/docs/src/utils/with-defaults.ts +++ b/apps/docs/src/utils/with-defaults.ts @@ -1,11 +1,9 @@ -import React from 'react'; +import React from "react"; -const withDefaults = ( - component: React.ComponentType

        , - defaultProps: DP -) => { +const withDefaults = (component: React.ComponentType

        , defaultProps: DP) => { type Props = Partial & Omit; component.defaultProps = defaultProps; + return component as React.ComponentType; }; diff --git a/packages/react/src/utils/types.d.ts b/packages/react/src/utils/types.d.ts deleted file mode 100644 index 9c37e34ce2..0000000000 --- a/packages/react/src/utils/types.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type DeepPartial = { - [P in keyof T]?: T[P] extends Record ? DeepPartial : T[P]; -}; From aa9af006cc2173abe8978a0ae0eef98774e25849 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sun, 19 Jun 2022 18:37:36 -0300 Subject: [PATCH 008/106] refactor(docs-content): eslint rules applied --- .../content/components/avatar/bordered.ts | 4 +- apps/docs/content/components/avatar/color.ts | 4 +- .../docs/content/components/avatar/default.ts | 4 +- apps/docs/content/components/avatar/group.ts | 4 +- apps/docs/content/components/avatar/icon.ts | 14 +- apps/docs/content/components/avatar/index.ts | 18 +- apps/docs/content/components/avatar/size.ts | 4 +- .../docs/content/components/avatar/squared.ts | 4 +- apps/docs/content/components/avatar/zoomed.ts | 4 +- .../components/button-group/default.ts | 4 +- .../components/button-group/disabled.ts | 4 +- .../content/components/button-group/index.ts | 14 +- .../components/button-group/loading.ts | 4 +- .../content/components/button-group/sizes.ts | 4 +- .../components/button-group/variants.ts | 4 +- .../components/button-group/vertical.ts | 4 +- .../content/components/button/bordered.ts | 4 +- apps/docs/content/components/button/color.ts | 4 +- .../docs/content/components/button/default.ts | 4 +- .../content/components/button/disabled.ts | 4 +- apps/docs/content/components/button/flat.ts | 4 +- apps/docs/content/components/button/ghost.ts | 4 +- apps/docs/content/components/button/icon.ts | 14 +- apps/docs/content/components/button/light.ts | 4 +- .../docs/content/components/button/loading.ts | 4 +- .../docs/content/components/button/rounded.ts | 4 +- apps/docs/content/components/button/shadow.ts | 4 +- apps/docs/content/components/button/sizes.ts | 4 +- apps/docs/content/components/card/action.ts | 4 +- apps/docs/content/components/card/cover.ts | 14 +- apps/docs/content/components/card/default.ts | 4 +- apps/docs/content/components/card/divider.ts | 4 +- apps/docs/content/components/card/footer.ts | 4 +- .../docs/content/components/card/hoverable.ts | 4 +- apps/docs/content/components/card/index.ts | 18 +- .../docs/content/components/card/pressable.ts | 4 +- apps/docs/content/components/card/variants.ts | 4 +- .../components/checkbox-group/column.ts | 4 +- .../controlled-vs-uncontrolled.ts | 4 +- .../components/checkbox-group/events.ts | 4 +- .../components/checkbox-group/index.ts | 10 +- .../content/components/checkbox-group/row.ts | 4 +- .../docs/content/components/checkbox/color.ts | 4 +- .../checkbox/controlled-vs-uncontrolled.ts | 4 +- .../content/components/checkbox/default.ts | 4 +- .../content/components/checkbox/disabled.ts | 4 +- .../docs/content/components/checkbox/index.ts | 22 +- .../components/checkbox/interminate.ts | 4 +- .../components/checkbox/label-color.ts | 4 +- .../components/checkbox/line-through.ts | 4 +- .../components/checkbox/no-animated.ts | 4 +- .../content/components/checkbox/rounded.ts | 4 +- apps/docs/content/components/checkbox/size.ts | 4 +- .../content/components/collapse/bordered.ts | 4 +- .../components/collapse/content-left.ts | 4 +- .../components/collapse/custom-arrow.ts | 10 +- .../content/components/collapse/default.ts | 4 +- .../content/components/collapse/disabled.ts | 4 +- .../docs/content/components/collapse/index.ts | 26 +- .../components/collapse/initial-expanded.ts | 4 +- .../components/collapse/no-accordion.ts | 4 +- .../components/collapse/no-animated.ts | 4 +- .../content/components/collapse/no-divider.ts | 4 +- .../content/components/collapse/shadow.ts | 4 +- .../content/components/collapse/splitted.ts | 4 +- .../components/collapse/with-subtitle.ts | 4 +- .../components/container/autoLayout.ts | 4 +- .../components/container/breakpoint.ts | 4 +- .../content/components/container/default.ts | 4 +- .../content/components/container/fluid.ts | 4 +- .../content/components/container/index.ts | 10 +- .../content/components/dropdown/command.ts | 4 +- .../components/dropdown/custom-trigger.ts | 4 +- .../components/dropdown/description.ts | 12 +- .../components/dropdown/disable-animation.ts | 12 +- .../components/dropdown/disabled-keys.ts | 4 +- .../content/components/dropdown/dynamic.ts | 4 +- apps/docs/content/components/dropdown/icon.ts | 12 +- .../docs/content/components/dropdown/index.ts | 28 +- .../components/dropdown/multiple-selection.ts | 4 +- .../content/components/dropdown/sections.ts | 12 +- .../components/dropdown/single-selection.ts | 4 +- .../content/components/dropdown/static.ts | 4 +- .../content/components/dropdown/variants.ts | 4 +- .../components/dropdown/with-divider.ts | 4 +- .../docs/content/components/grid/autoWidth.ts | 4 +- apps/docs/content/components/grid/default.ts | 4 +- apps/docs/content/components/grid/fluid.ts | 4 +- .../content/components/grid/hideElement.ts | 6 +- apps/docs/content/components/grid/index.ts | 12 +- .../content/components/grid/responsive.ts | 6 +- apps/docs/content/components/image/default.ts | 4 +- .../content/components/image/objectFit.ts | 4 +- .../content/components/image/showSkeleton.ts | 4 +- apps/docs/content/components/image/size.ts | 4 +- apps/docs/content/components/index.ts | 54 +-- .../docs/content/components/input/LRLabels.ts | 5 +- .../docs/content/components/input/bordered.ts | 5 +- .../content/components/input/clearable.ts | 4 +- apps/docs/content/components/input/content.ts | 10 +- apps/docs/content/components/input/default.ts | 4 +- .../docs/content/components/input/disabled.ts | 4 +- apps/docs/content/components/input/helper.ts | 4 +- apps/docs/content/components/input/label.ts | 4 +- .../components/input/labelPlaceholder.ts | 4 +- .../content/components/input/noAnimated.ts | 5 +- .../docs/content/components/input/password.ts | 8 +- apps/docs/content/components/input/rounded.ts | 5 +- apps/docs/content/components/input/shadow.ts | 5 +- apps/docs/content/components/input/size.ts | 5 +- apps/docs/content/components/input/status.ts | 5 +- apps/docs/content/components/input/types.ts | 5 +- .../content/components/input/underlined.ts | 5 +- apps/docs/content/components/link/block.ts | 4 +- apps/docs/content/components/link/color.ts | 4 +- apps/docs/content/components/link/default.ts | 4 +- apps/docs/content/components/link/icon.ts | 4 +- apps/docs/content/components/link/nextLink.ts | 4 +- .../docs/content/components/link/variation.ts | 4 +- apps/docs/content/components/loading/color.ts | 5 +- .../content/components/loading/default.ts | 4 +- apps/docs/content/components/loading/index.ts | 15 +- apps/docs/content/components/loading/size.ts | 5 +- apps/docs/content/components/loading/text.ts | 5 +- .../content/components/loading/textColor.ts | 5 +- apps/docs/content/components/loading/types.ts | 5 +- .../components/modal/blurBackground.ts | 8 +- apps/docs/content/components/modal/default.ts | 8 +- .../content/components/modal/fullscreen.ts | 5 +- apps/docs/content/components/modal/index.ts | 18 +- .../content/components/modal/largeContent.ts | 5 +- .../content/components/modal/noAnimated.ts | 8 +- .../content/components/modal/preventClose.ts | 8 +- .../components/modal/withoutPadding.ts | 4 +- .../content/components/pagination/bordered.ts | 4 +- .../components/pagination/boundaries.ts | 4 +- .../content/components/pagination/color.ts | 4 +- .../content/components/pagination/default.ts | 5 +- .../content/components/pagination/dots.ts | 4 +- .../content/components/pagination/index.ts | 27 +- .../content/components/pagination/loop.ts | 4 +- .../components/pagination/noAnimation.ts | 4 +- .../content/components/pagination/noCtrl.ts | 4 +- .../content/components/pagination/noMargin.ts | 4 +- .../content/components/pagination/rounded.ts | 4 +- .../content/components/pagination/shadow.ts | 4 +- .../content/components/pagination/sibling.ts | 4 +- .../content/components/pagination/sizes.ts | 4 +- .../content/components/popover/bordered.ts | 4 +- .../popover/controlled-vs-uncontrolled.ts | 4 +- .../components/popover/custom-content.ts | 8 +- .../content/components/popover/default.ts | 4 +- .../components/popover/disable-animation.ts | 4 +- apps/docs/content/components/popover/index.ts | 14 +- .../content/components/popover/placements.ts | 6 +- .../docs/content/components/progress/color.ts | 4 +- .../content/components/progress/default.ts | 4 +- .../components/progress/indeterminated.ts | 4 +- .../docs/content/components/progress/index.ts | 20 +- .../components/progress/noAnimation.ts | 4 +- .../content/components/progress/shadow.ts | 4 +- apps/docs/content/components/progress/size.ts | 4 +- .../content/components/progress/squared.ts | 4 +- .../content/components/progress/status.ts | 4 +- .../content/components/progress/striped.ts | 4 +- apps/docs/content/components/radio/color.ts | 4 +- .../radio/controlled-vs-uncontrolled.ts | 4 +- apps/docs/content/components/radio/default.ts | 4 +- .../content/components/radio/description.ts | 4 +- .../components/radio/disableAnimation.ts | 4 +- .../docs/content/components/radio/disabled.ts | 4 +- apps/docs/content/components/radio/events.ts | 4 +- apps/docs/content/components/radio/index.ts | 26 +- apps/docs/content/components/radio/invalid.ts | 4 +- .../content/components/radio/labelColor.ts | 4 +- apps/docs/content/components/radio/row.ts | 4 +- apps/docs/content/components/radio/size.ts | 4 +- apps/docs/content/components/radio/squared.ts | 4 +- .../content/components/spacer/horizontal.ts | 4 +- apps/docs/content/components/spacer/index.ts | 6 +- .../content/components/spacer/vertical.ts | 4 +- .../content/components/switch/bordered.ts | 4 +- apps/docs/content/components/switch/color.ts | 4 +- .../docs/content/components/switch/default.ts | 4 +- .../content/components/switch/disabled.ts | 4 +- apps/docs/content/components/switch/icon.ts | 24 +- apps/docs/content/components/switch/index.ts | 22 +- .../content/components/switch/initialCheck.ts | 4 +- .../content/components/switch/noAnimated.ts | 8 +- apps/docs/content/components/switch/shadow.ts | 4 +- apps/docs/content/components/switch/size.ts | 4 +- .../docs/content/components/switch/squared.ts | 4 +- .../docs/content/components/table/bordered.ts | 4 +- apps/docs/content/components/table/colors.ts | 4 +- apps/docs/content/components/table/compact.ts | 4 +- .../content/components/table/custom-cells.ts | 26 +- .../content/components/table/disabled-keys.ts | 4 +- .../table/disallow-empty-selection.ts | 4 +- apps/docs/content/components/table/dynamic.ts | 4 +- apps/docs/content/components/table/index.ts | 36 +- .../components/table/infinity-pagination.ts | 4 +- apps/docs/content/components/table/lined.ts | 4 +- .../components/table/multiple-selection.ts | 4 +- .../content/components/table/no-animated.ts | 4 +- .../content/components/table/pagination.ts | 4 +- .../components/table/single-selection.ts | 4 +- .../docs/content/components/table/sortable.ts | 4 +- apps/docs/content/components/table/static.ts | 4 +- apps/docs/content/components/table/sticked.ts | 4 +- apps/docs/content/components/table/striped.ts | 4 +- .../content/components/text/blockquote.ts | 5 +- apps/docs/content/components/text/color.ts | 4 +- apps/docs/content/components/text/compose.ts | 5 +- apps/docs/content/components/text/default.ts | 4 +- apps/docs/content/components/text/gradient.ts | 4 +- apps/docs/content/components/text/index.ts | 16 +- .../docs/content/components/text/paragraph.ts | 4 +- apps/docs/content/components/text/size.ts | 17 +- apps/docs/content/components/text/small.ts | 4 +- .../content/components/textarea/autosize.ts | 4 +- .../textarea/controlledUncontrolled.ts | 4 +- .../content/components/textarea/default.ts | 4 +- .../content/components/textarea/disabled.ts | 4 +- .../content/components/textarea/helper.ts | 4 +- .../docs/content/components/textarea/index.ts | 16 +- .../content/components/textarea/status.ts | 4 +- .../docs/content/components/textarea/types.ts | 4 +- apps/docs/content/components/tooltip/color.ts | 4 +- .../components/tooltip/customContent.ts | 8 +- .../content/components/tooltip/default.ts | 4 +- apps/docs/content/components/tooltip/index.ts | 18 +- .../content/components/tooltip/noArrow.ts | 4 +- .../content/components/tooltip/placement.ts | 4 +- .../content/components/tooltip/rounded.ts | 4 +- .../content/components/tooltip/textColor.ts | 4 +- .../content/components/tooltip/trigger.ts | 4 +- apps/docs/content/components/user/border.ts | 4 +- apps/docs/content/components/user/color.ts | 4 +- apps/docs/content/components/user/default.ts | 4 +- .../content/components/user/description.ts | 4 +- apps/docs/content/components/user/index.ts | 20 +- apps/docs/content/components/user/link.ts | 4 +- apps/docs/content/components/user/pointer.ts | 4 +- apps/docs/content/components/user/size.ts | 4 +- apps/docs/content/components/user/squared.ts | 4 +- apps/docs/content/components/user/zoomed.ts | 4 +- apps/docs/content/docs/manifest.json | 456 +++++++++--------- apps/docs/content/landing/index.tsx | 85 ++-- 248 files changed, 1025 insertions(+), 1060 deletions(-) diff --git a/apps/docs/content/components/avatar/bordered.ts b/apps/docs/content/components/avatar/bordered.ts index a465c02907..ed85af7316 100644 --- a/apps/docs/content/components/avatar/bordered.ts +++ b/apps/docs/content/components/avatar/bordered.ts @@ -56,9 +56,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/avatar/color.ts b/apps/docs/content/components/avatar/color.ts index 1c7c55cb8f..cb5d5e3ad1 100644 --- a/apps/docs/content/components/avatar/color.ts +++ b/apps/docs/content/components/avatar/color.ts @@ -44,9 +44,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/avatar/default.ts b/apps/docs/content/components/avatar/default.ts index 34b99fd0ad..e47a86cd9a 100644 --- a/apps/docs/content/components/avatar/default.ts +++ b/apps/docs/content/components/avatar/default.ts @@ -38,9 +38,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/avatar/group.ts b/apps/docs/content/components/avatar/group.ts index aba2aeeeb1..0e2faf47a8 100644 --- a/apps/docs/content/components/avatar/group.ts +++ b/apps/docs/content/components/avatar/group.ts @@ -38,9 +38,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/avatar/icon.ts b/apps/docs/content/components/avatar/icon.ts index 03685119fe..b39ba13b19 100644 --- a/apps/docs/content/components/avatar/icon.ts +++ b/apps/docs/content/components/avatar/icon.ts @@ -260,14 +260,14 @@ export default function App() { }`; const react = { - '/SunIcon.js': SunIcon, - '/MoonIcon.js': MoonIcon, - '/VideoIcon.js': VideoIcon, - '/VolumeUpIcon.js': VolumeUpIcon, - '/MicrophoneIcon.js': MicrophoneIcon, - '/App.js': AppJs + "/SunIcon.js": SunIcon, + "/MoonIcon.js": MoonIcon, + "/VideoIcon.js": VideoIcon, + "/VolumeUpIcon.js": VolumeUpIcon, + "/MicrophoneIcon.js": MicrophoneIcon, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/avatar/index.ts b/apps/docs/content/components/avatar/index.ts index e098e3bdbf..c43e3f2c0f 100644 --- a/apps/docs/content/components/avatar/index.ts +++ b/apps/docs/content/components/avatar/index.ts @@ -1,11 +1,11 @@ -import default_avatar from './default'; -import size from './size'; -import color from './color'; -import bordered from './bordered'; -import zoomed from './zoomed'; -import squared from './squared'; -import icon from './icon'; -import group from './group'; +import default_avatar from "./default"; +import size from "./size"; +import color from "./color"; +import bordered from "./bordered"; +import zoomed from "./zoomed"; +import squared from "./squared"; +import icon from "./icon"; +import group from "./group"; export default { default_avatar, @@ -15,5 +15,5 @@ export default { zoomed, squared, icon, - group + group, }; diff --git a/apps/docs/content/components/avatar/size.ts b/apps/docs/content/components/avatar/size.ts index 85db8457bc..0f70f95db6 100644 --- a/apps/docs/content/components/avatar/size.ts +++ b/apps/docs/content/components/avatar/size.ts @@ -35,9 +35,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/avatar/squared.ts b/apps/docs/content/components/avatar/squared.ts index 3c8eba4da0..b11d1cda60 100644 --- a/apps/docs/content/components/avatar/squared.ts +++ b/apps/docs/content/components/avatar/squared.ts @@ -62,9 +62,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/avatar/zoomed.ts b/apps/docs/content/components/avatar/zoomed.ts index 8a1b1b85ab..9e82c24778 100644 --- a/apps/docs/content/components/avatar/zoomed.ts +++ b/apps/docs/content/components/avatar/zoomed.ts @@ -57,9 +57,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button-group/default.ts b/apps/docs/content/components/button-group/default.ts index 2d69bb91b7..65df6fef99 100644 --- a/apps/docs/content/components/button-group/default.ts +++ b/apps/docs/content/components/button-group/default.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button-group/disabled.ts b/apps/docs/content/components/button-group/disabled.ts index 3ed363747e..3d4091b857 100644 --- a/apps/docs/content/components/button-group/disabled.ts +++ b/apps/docs/content/components/button-group/disabled.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button-group/index.ts b/apps/docs/content/components/button-group/index.ts index dad9e4d4bf..17d86f5671 100644 --- a/apps/docs/content/components/button-group/index.ts +++ b/apps/docs/content/components/button-group/index.ts @@ -1,9 +1,9 @@ -import defaultButtonGroup from './default'; -import disabledButtonGroup from './disabled'; -import loading from './loading'; -import sizes from './sizes'; -import vertical from './vertical'; -import variants from './variants'; +import defaultButtonGroup from "./default"; +import disabledButtonGroup from "./disabled"; +import loading from "./loading"; +import sizes from "./sizes"; +import vertical from "./vertical"; +import variants from "./variants"; export default { defaultButtonGroup, @@ -11,5 +11,5 @@ export default { loading, sizes, vertical, - variants + variants, }; diff --git a/apps/docs/content/components/button-group/loading.ts b/apps/docs/content/components/button-group/loading.ts index 20f5510942..15a9b01f2f 100644 --- a/apps/docs/content/components/button-group/loading.ts +++ b/apps/docs/content/components/button-group/loading.ts @@ -19,9 +19,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button-group/sizes.ts b/apps/docs/content/components/button-group/sizes.ts index dbb68c4b8d..cca5c1c47e 100644 --- a/apps/docs/content/components/button-group/sizes.ts +++ b/apps/docs/content/components/button-group/sizes.ts @@ -44,9 +44,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button-group/variants.ts b/apps/docs/content/components/button-group/variants.ts index c2b031d502..78b6fcd2f7 100644 --- a/apps/docs/content/components/button-group/variants.ts +++ b/apps/docs/content/components/button-group/variants.ts @@ -44,9 +44,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button-group/vertical.ts b/apps/docs/content/components/button-group/vertical.ts index 4f28deabd5..15299fc540 100644 --- a/apps/docs/content/components/button-group/vertical.ts +++ b/apps/docs/content/components/button-group/vertical.ts @@ -39,9 +39,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/bordered.ts b/apps/docs/content/components/button/bordered.ts index 2facef0c3b..7c43d20bb3 100644 --- a/apps/docs/content/components/button/bordered.ts +++ b/apps/docs/content/components/button/bordered.ts @@ -38,9 +38,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/color.ts b/apps/docs/content/components/button/color.ts index 756574e2bb..52eefedf12 100644 --- a/apps/docs/content/components/button/color.ts +++ b/apps/docs/content/components/button/color.ts @@ -38,9 +38,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/default.ts b/apps/docs/content/components/button/default.ts index 30081d4be5..4d20937cd3 100644 --- a/apps/docs/content/components/button/default.ts +++ b/apps/docs/content/components/button/default.ts @@ -5,9 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/disabled.ts b/apps/docs/content/components/button/disabled.ts index bcd5683614..5cb2a6c7ae 100644 --- a/apps/docs/content/components/button/disabled.ts +++ b/apps/docs/content/components/button/disabled.ts @@ -5,9 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/flat.ts b/apps/docs/content/components/button/flat.ts index 439b7ccd43..27b88a320b 100644 --- a/apps/docs/content/components/button/flat.ts +++ b/apps/docs/content/components/button/flat.ts @@ -33,9 +33,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/ghost.ts b/apps/docs/content/components/button/ghost.ts index a24c308e95..58d82572b4 100644 --- a/apps/docs/content/components/button/ghost.ts +++ b/apps/docs/content/components/button/ghost.ts @@ -38,9 +38,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/icon.ts b/apps/docs/content/components/button/icon.ts index 17c10b11fe..dfc371635b 100644 --- a/apps/docs/content/components/button/icon.ts +++ b/apps/docs/content/components/button/icon.ts @@ -212,14 +212,14 @@ export default function App() { }`; const react = { - '/HeartIcon.js': HeartIcon, - '/CameraIcon.js': CameraIcon, - '/LockIcon.js': LockIcon, - '/NotificationIcon.js': NotificationIcon, - '/UserIcon.js': UserIcon, - '/App.js': AppJs + "/HeartIcon.js": HeartIcon, + "/CameraIcon.js": CameraIcon, + "/LockIcon.js": LockIcon, + "/NotificationIcon.js": NotificationIcon, + "/UserIcon.js": UserIcon, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/light.ts b/apps/docs/content/components/button/light.ts index f0a7f3db25..c4302654ac 100644 --- a/apps/docs/content/components/button/light.ts +++ b/apps/docs/content/components/button/light.ts @@ -33,9 +33,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/loading.ts b/apps/docs/content/components/button/loading.ts index fd9a174ce1..8beca9aef3 100644 --- a/apps/docs/content/components/button/loading.ts +++ b/apps/docs/content/components/button/loading.ts @@ -27,9 +27,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/rounded.ts b/apps/docs/content/components/button/rounded.ts index 5b1e8cfdff..3c878ef90e 100644 --- a/apps/docs/content/components/button/rounded.ts +++ b/apps/docs/content/components/button/rounded.ts @@ -38,9 +38,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/shadow.ts b/apps/docs/content/components/button/shadow.ts index 46af59e0b2..a5a65318be 100644 --- a/apps/docs/content/components/button/shadow.ts +++ b/apps/docs/content/components/button/shadow.ts @@ -38,9 +38,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/button/sizes.ts b/apps/docs/content/components/button/sizes.ts index 083c264800..a2656837bd 100644 --- a/apps/docs/content/components/button/sizes.ts +++ b/apps/docs/content/components/button/sizes.ts @@ -19,9 +19,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/card/action.ts b/apps/docs/content/components/card/action.ts index e87db3db84..0661c90e14 100644 --- a/apps/docs/content/components/card/action.ts +++ b/apps/docs/content/components/card/action.ts @@ -74,9 +74,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/card/cover.ts b/apps/docs/content/components/card/cover.ts index 8903abfb3f..8b11e2828e 100644 --- a/apps/docs/content/components/card/cover.ts +++ b/apps/docs/content/components/card/cover.ts @@ -240,14 +240,14 @@ export default function App() { }`; const react = { - '/Card1.js': Card1, - '/Card2.js': Card2, - '/Card3.js': Card3, - '/Card4.js': Card4, - '/Card5.js': Card5, - '/App.js': App + "/Card1.js": Card1, + "/Card2.js": Card2, + "/Card3.js": Card3, + "/Card4.js": Card4, + "/Card5.js": Card5, + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/card/default.ts b/apps/docs/content/components/card/default.ts index 9e9aca5172..4d48f4a13a 100644 --- a/apps/docs/content/components/card/default.ts +++ b/apps/docs/content/components/card/default.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/card/divider.ts b/apps/docs/content/components/card/divider.ts index b7bef6af12..be6582920a 100644 --- a/apps/docs/content/components/card/divider.ts +++ b/apps/docs/content/components/card/divider.ts @@ -56,9 +56,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/card/footer.ts b/apps/docs/content/components/card/footer.ts index 89ea171c57..a2f497fab9 100644 --- a/apps/docs/content/components/card/footer.ts +++ b/apps/docs/content/components/card/footer.ts @@ -41,9 +41,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/card/hoverable.ts b/apps/docs/content/components/card/hoverable.ts index 209b1196c7..7ed8ab7cc1 100644 --- a/apps/docs/content/components/card/hoverable.ts +++ b/apps/docs/content/components/card/hoverable.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/card/index.ts b/apps/docs/content/components/card/index.ts index 434d216514..f4f0ba7360 100644 --- a/apps/docs/content/components/card/index.ts +++ b/apps/docs/content/components/card/index.ts @@ -1,11 +1,11 @@ -import defaultCard from './default'; -import variants from './variants'; -import hoverable from './hoverable'; -import pressable from './pressable'; -import divider from './divider'; -import cover from './cover'; -import action from './action'; -import footer from './footer'; +import defaultCard from "./default"; +import variants from "./variants"; +import hoverable from "./hoverable"; +import pressable from "./pressable"; +import divider from "./divider"; +import cover from "./cover"; +import action from "./action"; +import footer from "./footer"; export default { defaultCard, @@ -15,5 +15,5 @@ export default { divider, cover, action, - footer + footer, }; diff --git a/apps/docs/content/components/card/pressable.ts b/apps/docs/content/components/card/pressable.ts index 25a81b7cbb..edcc1ed5d2 100644 --- a/apps/docs/content/components/card/pressable.ts +++ b/apps/docs/content/components/card/pressable.ts @@ -16,9 +16,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/card/variants.ts b/apps/docs/content/components/card/variants.ts index 8349d8cdc5..100f02e113 100644 --- a/apps/docs/content/components/card/variants.ts +++ b/apps/docs/content/components/card/variants.ts @@ -29,9 +29,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox-group/column.ts b/apps/docs/content/components/checkbox-group/column.ts index e2177f7d14..394ab7be7f 100644 --- a/apps/docs/content/components/checkbox-group/column.ts +++ b/apps/docs/content/components/checkbox-group/column.ts @@ -16,9 +16,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox-group/controlled-vs-uncontrolled.ts b/apps/docs/content/components/checkbox-group/controlled-vs-uncontrolled.ts index 4fbd60cffa..3a7b19fd3f 100644 --- a/apps/docs/content/components/checkbox-group/controlled-vs-uncontrolled.ts +++ b/apps/docs/content/components/checkbox-group/controlled-vs-uncontrolled.ts @@ -33,9 +33,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox-group/events.ts b/apps/docs/content/components/checkbox-group/events.ts index b92a919cdb..a3eff6bc9c 100644 --- a/apps/docs/content/components/checkbox-group/events.ts +++ b/apps/docs/content/components/checkbox-group/events.ts @@ -22,9 +22,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox-group/index.ts b/apps/docs/content/components/checkbox-group/index.ts index e4b283bbe1..1a0d367a10 100644 --- a/apps/docs/content/components/checkbox-group/index.ts +++ b/apps/docs/content/components/checkbox-group/index.ts @@ -1,11 +1,11 @@ -import column from './column'; -import row from './row'; -import controlledVsUncontrolled from './controlled-vs-uncontrolled'; -import events from './events'; +import column from "./column"; +import row from "./row"; +import controlledVsUncontrolled from "./controlled-vs-uncontrolled"; +import events from "./events"; export default { column, row, events, - controlledVsUncontrolled + controlledVsUncontrolled, }; diff --git a/apps/docs/content/components/checkbox-group/row.ts b/apps/docs/content/components/checkbox-group/row.ts index df749be58e..98bdd617bb 100644 --- a/apps/docs/content/components/checkbox-group/row.ts +++ b/apps/docs/content/components/checkbox-group/row.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/color.ts b/apps/docs/content/components/checkbox/color.ts index 1d3ee0a59e..078abdbb7b 100644 --- a/apps/docs/content/components/checkbox/color.ts +++ b/apps/docs/content/components/checkbox/color.ts @@ -31,9 +31,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/controlled-vs-uncontrolled.ts b/apps/docs/content/components/checkbox/controlled-vs-uncontrolled.ts index 28c734c99d..c186a0b7c1 100644 --- a/apps/docs/content/components/checkbox/controlled-vs-uncontrolled.ts +++ b/apps/docs/content/components/checkbox/controlled-vs-uncontrolled.ts @@ -16,9 +16,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/default.ts b/apps/docs/content/components/checkbox/default.ts index 918f86904e..337a479f75 100644 --- a/apps/docs/content/components/checkbox/default.ts +++ b/apps/docs/content/components/checkbox/default.ts @@ -5,9 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/disabled.ts b/apps/docs/content/components/checkbox/disabled.ts index 50e821e3e7..c29f338ad7 100644 --- a/apps/docs/content/components/checkbox/disabled.ts +++ b/apps/docs/content/components/checkbox/disabled.ts @@ -9,9 +9,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/index.ts b/apps/docs/content/components/checkbox/index.ts index 4ee58630a8..22029ecb5a 100644 --- a/apps/docs/content/components/checkbox/index.ts +++ b/apps/docs/content/components/checkbox/index.ts @@ -1,13 +1,13 @@ -import default_checkbox from './default'; -import disabled from './disabled'; -import size from './size'; -import color from './color'; -import labelColor from './label-color'; -import rounded from './rounded'; -import interminate from './interminate'; -import noAnimation from './no-animated'; -import lineThrough from './line-through'; -import controlledVsUncontrolled from './controlled-vs-uncontrolled'; +import default_checkbox from "./default"; +import disabled from "./disabled"; +import size from "./size"; +import color from "./color"; +import labelColor from "./label-color"; +import rounded from "./rounded"; +import interminate from "./interminate"; +import noAnimation from "./no-animated"; +import lineThrough from "./line-through"; +import controlledVsUncontrolled from "./controlled-vs-uncontrolled"; export default { default_checkbox, @@ -19,5 +19,5 @@ export default { interminate, noAnimation, lineThrough, - controlledVsUncontrolled + controlledVsUncontrolled, }; diff --git a/apps/docs/content/components/checkbox/interminate.ts b/apps/docs/content/components/checkbox/interminate.ts index bedbd5bf39..6df12e7067 100644 --- a/apps/docs/content/components/checkbox/interminate.ts +++ b/apps/docs/content/components/checkbox/interminate.ts @@ -9,9 +9,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/label-color.ts b/apps/docs/content/components/checkbox/label-color.ts index 4547ecb071..73fbe15a97 100644 --- a/apps/docs/content/components/checkbox/label-color.ts +++ b/apps/docs/content/components/checkbox/label-color.ts @@ -27,9 +27,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/line-through.ts b/apps/docs/content/components/checkbox/line-through.ts index 41f191e766..f43195f46f 100644 --- a/apps/docs/content/components/checkbox/line-through.ts +++ b/apps/docs/content/components/checkbox/line-through.ts @@ -9,9 +9,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/no-animated.ts b/apps/docs/content/components/checkbox/no-animated.ts index 08d99ee4b2..0f14bce90f 100644 --- a/apps/docs/content/components/checkbox/no-animated.ts +++ b/apps/docs/content/components/checkbox/no-animated.ts @@ -9,9 +9,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/rounded.ts b/apps/docs/content/components/checkbox/rounded.ts index 566eb3961b..b62352f2d9 100644 --- a/apps/docs/content/components/checkbox/rounded.ts +++ b/apps/docs/content/components/checkbox/rounded.ts @@ -9,9 +9,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/checkbox/size.ts b/apps/docs/content/components/checkbox/size.ts index d26d33fde0..6a6bad6832 100644 --- a/apps/docs/content/components/checkbox/size.ts +++ b/apps/docs/content/components/checkbox/size.ts @@ -27,9 +27,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/bordered.ts b/apps/docs/content/components/collapse/bordered.ts index e7cb87aadf..cf14e6ae42 100644 --- a/apps/docs/content/components/collapse/bordered.ts +++ b/apps/docs/content/components/collapse/bordered.ts @@ -50,9 +50,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/content-left.ts b/apps/docs/content/components/collapse/content-left.ts index 68044a408b..9aadc3db17 100644 --- a/apps/docs/content/components/collapse/content-left.ts +++ b/apps/docs/content/components/collapse/content-left.ts @@ -76,9 +76,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/custom-arrow.ts b/apps/docs/content/components/collapse/custom-arrow.ts index f7ff62c688..d872f8abd5 100644 --- a/apps/docs/content/components/collapse/custom-arrow.ts +++ b/apps/docs/content/components/collapse/custom-arrow.ts @@ -174,12 +174,12 @@ export default function App() { }`; const react = { - '/SunIcon.js': SunIcon, - '/MoonIcon.js': MoonIcon, - '/AnchorIcon.js': AnchorIcon, - '/App.js': AppJs + "/SunIcon.js": SunIcon, + "/MoonIcon.js": MoonIcon, + "/AnchorIcon.js": AnchorIcon, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/default.ts b/apps/docs/content/components/collapse/default.ts index 368597ccf9..9d168dee84 100644 --- a/apps/docs/content/components/collapse/default.ts +++ b/apps/docs/content/components/collapse/default.ts @@ -32,9 +32,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/disabled.ts b/apps/docs/content/components/collapse/disabled.ts index 362a78340e..41281cee1a 100644 --- a/apps/docs/content/components/collapse/disabled.ts +++ b/apps/docs/content/components/collapse/disabled.ts @@ -36,9 +36,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/index.ts b/apps/docs/content/components/collapse/index.ts index af914d4f99..94221b535e 100644 --- a/apps/docs/content/components/collapse/index.ts +++ b/apps/docs/content/components/collapse/index.ts @@ -1,15 +1,15 @@ -import defaultCollapse from './default'; -import noAccordion from './no-accordion'; -import initialExpanded from './initial-expanded'; -import withSubtitle from './with-subtitle'; -import shadow from './shadow'; -import bordered from './bordered'; -import splitted from './splitted'; -import customArrow from './custom-arrow'; -import contentLeft from './content-left'; -import noDivider from './no-divider'; -import disabled from './disabled'; -import noAnimated from './no-animated'; +import defaultCollapse from "./default"; +import noAccordion from "./no-accordion"; +import initialExpanded from "./initial-expanded"; +import withSubtitle from "./with-subtitle"; +import shadow from "./shadow"; +import bordered from "./bordered"; +import splitted from "./splitted"; +import customArrow from "./custom-arrow"; +import contentLeft from "./content-left"; +import noDivider from "./no-divider"; +import disabled from "./disabled"; +import noAnimated from "./no-animated"; export default { defaultCollapse, @@ -23,5 +23,5 @@ export default { contentLeft, noDivider, disabled, - noAnimated + noAnimated, }; diff --git a/apps/docs/content/components/collapse/initial-expanded.ts b/apps/docs/content/components/collapse/initial-expanded.ts index 251391b7c3..782901ec46 100644 --- a/apps/docs/content/components/collapse/initial-expanded.ts +++ b/apps/docs/content/components/collapse/initial-expanded.ts @@ -32,9 +32,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/no-accordion.ts b/apps/docs/content/components/collapse/no-accordion.ts index 49f66fbb00..36141d0869 100644 --- a/apps/docs/content/components/collapse/no-accordion.ts +++ b/apps/docs/content/components/collapse/no-accordion.ts @@ -32,9 +32,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/no-animated.ts b/apps/docs/content/components/collapse/no-animated.ts index d44748424e..ab01818001 100644 --- a/apps/docs/content/components/collapse/no-animated.ts +++ b/apps/docs/content/components/collapse/no-animated.ts @@ -36,9 +36,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/no-divider.ts b/apps/docs/content/components/collapse/no-divider.ts index d8c1500ac9..2d5b3ed26d 100644 --- a/apps/docs/content/components/collapse/no-divider.ts +++ b/apps/docs/content/components/collapse/no-divider.ts @@ -36,9 +36,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/shadow.ts b/apps/docs/content/components/collapse/shadow.ts index 036e631614..c1697c7f86 100644 --- a/apps/docs/content/components/collapse/shadow.ts +++ b/apps/docs/content/components/collapse/shadow.ts @@ -50,9 +50,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/splitted.ts b/apps/docs/content/components/collapse/splitted.ts index 55b217d1f8..85ff045fa6 100644 --- a/apps/docs/content/components/collapse/splitted.ts +++ b/apps/docs/content/components/collapse/splitted.ts @@ -36,9 +36,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/collapse/with-subtitle.ts b/apps/docs/content/components/collapse/with-subtitle.ts index 187e4ee481..89018fe97a 100644 --- a/apps/docs/content/components/collapse/with-subtitle.ts +++ b/apps/docs/content/components/collapse/with-subtitle.ts @@ -31,9 +31,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/container/autoLayout.ts b/apps/docs/content/components/container/autoLayout.ts index 42700fde6a..ead0d03fa0 100644 --- a/apps/docs/content/components/container/autoLayout.ts +++ b/apps/docs/content/components/container/autoLayout.ts @@ -57,9 +57,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/container/breakpoint.ts b/apps/docs/content/components/container/breakpoint.ts index 28228d8611..4b87f23948 100644 --- a/apps/docs/content/components/container/breakpoint.ts +++ b/apps/docs/content/components/container/breakpoint.ts @@ -19,9 +19,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/container/default.ts b/apps/docs/content/components/container/default.ts index 419b5b6825..d59e0cf31d 100644 --- a/apps/docs/content/components/container/default.ts +++ b/apps/docs/content/components/container/default.ts @@ -19,9 +19,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/container/fluid.ts b/apps/docs/content/components/container/fluid.ts index 9928027cdf..5038f27092 100644 --- a/apps/docs/content/components/container/fluid.ts +++ b/apps/docs/content/components/container/fluid.ts @@ -19,9 +19,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/container/index.ts b/apps/docs/content/components/container/index.ts index b5e9ac0d25..be51e2f849 100644 --- a/apps/docs/content/components/container/index.ts +++ b/apps/docs/content/components/container/index.ts @@ -1,11 +1,11 @@ -import default_container from './default'; -import fluid from './fluid'; -import breakpoint from './breakpoint'; -import autoLayout from './autoLayout'; +import default_container from "./default"; +import fluid from "./fluid"; +import breakpoint from "./breakpoint"; +import autoLayout from "./autoLayout"; export default { default_container, fluid, breakpoint, - autoLayout + autoLayout, }; diff --git a/apps/docs/content/components/dropdown/command.ts b/apps/docs/content/components/dropdown/command.ts index dd567cb22c..e85b2736e2 100644 --- a/apps/docs/content/components/dropdown/command.ts +++ b/apps/docs/content/components/dropdown/command.ts @@ -25,9 +25,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/custom-trigger.ts b/apps/docs/content/components/dropdown/custom-trigger.ts index 5defdf517a..3d7bc6f0c4 100644 --- a/apps/docs/content/components/dropdown/custom-trigger.ts +++ b/apps/docs/content/components/dropdown/custom-trigger.ts @@ -86,9 +86,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/description.ts b/apps/docs/content/components/dropdown/description.ts index da91b5fb56..f36b53eeb8 100644 --- a/apps/docs/content/components/dropdown/description.ts +++ b/apps/docs/content/components/dropdown/description.ts @@ -162,13 +162,13 @@ export default function App() { }`; const react = { - '/AddNoteIcon.js': AddNoteIcon, - '/CopyDocumentIcon.js': CopyDocumentIcon, - '/EditDocumentIcon.js': EditDocumentIcon, - '/DeleteDocumentIcon.js': DeleteDocumentIcon, - '/App.js': App + "/AddNoteIcon.js": AddNoteIcon, + "/CopyDocumentIcon.js": CopyDocumentIcon, + "/EditDocumentIcon.js": EditDocumentIcon, + "/DeleteDocumentIcon.js": DeleteDocumentIcon, + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/disable-animation.ts b/apps/docs/content/components/dropdown/disable-animation.ts index c2b77b9276..61d853f026 100644 --- a/apps/docs/content/components/dropdown/disable-animation.ts +++ b/apps/docs/content/components/dropdown/disable-animation.ts @@ -177,13 +177,13 @@ export default function App() { }`; const react = { - '/AddNoteIcon.js': AddNoteIcon, - '/CopyDocumentIcon.js': CopyDocumentIcon, - '/EditDocumentIcon.js': EditDocumentIcon, - '/DeleteDocumentIcon.js': DeleteDocumentIcon, - '/App.js': App + "/AddNoteIcon.js": AddNoteIcon, + "/CopyDocumentIcon.js": CopyDocumentIcon, + "/EditDocumentIcon.js": EditDocumentIcon, + "/DeleteDocumentIcon.js": DeleteDocumentIcon, + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/disabled-keys.ts b/apps/docs/content/components/dropdown/disabled-keys.ts index 915b20c87c..9a37b34771 100644 --- a/apps/docs/content/components/dropdown/disabled-keys.ts +++ b/apps/docs/content/components/dropdown/disabled-keys.ts @@ -20,9 +20,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/dynamic.ts b/apps/docs/content/components/dropdown/dynamic.ts index d3dfe6bcd6..955c2d10d7 100644 --- a/apps/docs/content/components/dropdown/dynamic.ts +++ b/apps/docs/content/components/dropdown/dynamic.ts @@ -26,9 +26,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/icon.ts b/apps/docs/content/components/dropdown/icon.ts index a49e69e06d..8848dd3aa6 100644 --- a/apps/docs/content/components/dropdown/icon.ts +++ b/apps/docs/content/components/dropdown/icon.ts @@ -158,13 +158,13 @@ export default function App() { }`; const react = { - '/AddNoteIcon.js': AddNoteIcon, - '/CopyDocumentIcon.js': CopyDocumentIcon, - '/EditDocumentIcon.js': EditDocumentIcon, - '/DeleteDocumentIcon.js': DeleteDocumentIcon, - '/App.js': App + "/AddNoteIcon.js": AddNoteIcon, + "/CopyDocumentIcon.js": CopyDocumentIcon, + "/EditDocumentIcon.js": EditDocumentIcon, + "/DeleteDocumentIcon.js": DeleteDocumentIcon, + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/index.ts b/apps/docs/content/components/dropdown/index.ts index 01c5d271df..1d49384ff0 100644 --- a/apps/docs/content/components/dropdown/index.ts +++ b/apps/docs/content/components/dropdown/index.ts @@ -1,16 +1,16 @@ -import staticDropdown from './static'; -import dynamicDropdown from './dynamic'; -import withDivider from './with-divider'; -import disabledKeys from './disabled-keys'; -import variants from './variants'; -import singleSelection from './single-selection'; -import multipleSelection from './multiple-selection'; -import command from './command'; -import icon from './icon'; -import description from './description'; -import sections from './sections'; -import customTrigger from './custom-trigger'; -import disableAnimation from './disable-animation'; +import staticDropdown from "./static"; +import dynamicDropdown from "./dynamic"; +import withDivider from "./with-divider"; +import disabledKeys from "./disabled-keys"; +import variants from "./variants"; +import singleSelection from "./single-selection"; +import multipleSelection from "./multiple-selection"; +import command from "./command"; +import icon from "./icon"; +import description from "./description"; +import sections from "./sections"; +import customTrigger from "./custom-trigger"; +import disableAnimation from "./disable-animation"; export default { staticDropdown, @@ -25,5 +25,5 @@ export default { description, sections, customTrigger, - disableAnimation + disableAnimation, }; diff --git a/apps/docs/content/components/dropdown/multiple-selection.ts b/apps/docs/content/components/dropdown/multiple-selection.ts index acc036b9a7..d48760e463 100644 --- a/apps/docs/content/components/dropdown/multiple-selection.ts +++ b/apps/docs/content/components/dropdown/multiple-selection.ts @@ -33,9 +33,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/sections.ts b/apps/docs/content/components/dropdown/sections.ts index 2c556a6ddb..f80628a63a 100644 --- a/apps/docs/content/components/dropdown/sections.ts +++ b/apps/docs/content/components/dropdown/sections.ts @@ -177,13 +177,13 @@ export default function App() { }`; const react = { - '/AddNoteIcon.js': AddNoteIcon, - '/CopyDocumentIcon.js': CopyDocumentIcon, - '/EditDocumentIcon.js': EditDocumentIcon, - '/DeleteDocumentIcon.js': DeleteDocumentIcon, - '/App.js': App + "/AddNoteIcon.js": AddNoteIcon, + "/CopyDocumentIcon.js": CopyDocumentIcon, + "/EditDocumentIcon.js": EditDocumentIcon, + "/DeleteDocumentIcon.js": DeleteDocumentIcon, + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/single-selection.ts b/apps/docs/content/components/dropdown/single-selection.ts index 2689def82b..51c86ba07d 100644 --- a/apps/docs/content/components/dropdown/single-selection.ts +++ b/apps/docs/content/components/dropdown/single-selection.ts @@ -33,9 +33,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/static.ts b/apps/docs/content/components/dropdown/static.ts index 18b50933d0..fcd2a2a76b 100644 --- a/apps/docs/content/components/dropdown/static.ts +++ b/apps/docs/content/components/dropdown/static.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/variants.ts b/apps/docs/content/components/dropdown/variants.ts index 036ec73eed..4c531dc794 100644 --- a/apps/docs/content/components/dropdown/variants.ts +++ b/apps/docs/content/components/dropdown/variants.ts @@ -110,9 +110,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/dropdown/with-divider.ts b/apps/docs/content/components/dropdown/with-divider.ts index db12fca710..a9b588348e 100644 --- a/apps/docs/content/components/dropdown/with-divider.ts +++ b/apps/docs/content/components/dropdown/with-divider.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/grid/autoWidth.ts b/apps/docs/content/components/grid/autoWidth.ts index 761efc6ed4..d97ede3fe9 100644 --- a/apps/docs/content/components/grid/autoWidth.ts +++ b/apps/docs/content/components/grid/autoWidth.ts @@ -40,9 +40,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/grid/default.ts b/apps/docs/content/components/grid/default.ts index 756ed78a68..f139b1fc64 100644 --- a/apps/docs/content/components/grid/default.ts +++ b/apps/docs/content/components/grid/default.ts @@ -27,9 +27,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/grid/fluid.ts b/apps/docs/content/components/grid/fluid.ts index c25f642151..f53dd00496 100644 --- a/apps/docs/content/components/grid/fluid.ts +++ b/apps/docs/content/components/grid/fluid.ts @@ -55,9 +55,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/grid/hideElement.ts b/apps/docs/content/components/grid/hideElement.ts index 7b386a1236..758f321bbd 100644 --- a/apps/docs/content/components/grid/hideElement.ts +++ b/apps/docs/content/components/grid/hideElement.ts @@ -61,10 +61,10 @@ export default function App() { }`; const react = { - '/useMediaQuery.js': useMediaQuery, - '/App.js': AppJs + "/useMediaQuery.js": useMediaQuery, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/grid/index.ts b/apps/docs/content/components/grid/index.ts index a1a9a6d35c..0a4a0ba0be 100644 --- a/apps/docs/content/components/grid/index.ts +++ b/apps/docs/content/components/grid/index.ts @@ -1,13 +1,13 @@ -import default_grid from './default'; -import autoWidth from './autoWidth'; -import fluid from './fluid'; -import hideElement from './hideElement'; -import responsive from './responsive'; +import default_grid from "./default"; +import autoWidth from "./autoWidth"; +import fluid from "./fluid"; +import hideElement from "./hideElement"; +import responsive from "./responsive"; export default { default_grid, autoWidth, fluid, hideElement, - responsive + responsive, }; diff --git a/apps/docs/content/components/grid/responsive.ts b/apps/docs/content/components/grid/responsive.ts index 1d3dc3fd3d..bcf204af63 100644 --- a/apps/docs/content/components/grid/responsive.ts +++ b/apps/docs/content/components/grid/responsive.ts @@ -63,10 +63,10 @@ export default function App() { }`; const react = { - '/useMediaQuery.js': useMediaQuery, - '/App.js': AppJs + "/useMediaQuery.js": useMediaQuery, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/image/default.ts b/apps/docs/content/components/image/default.ts index 662ca32e4d..2e64d823de 100644 --- a/apps/docs/content/components/image/default.ts +++ b/apps/docs/content/components/image/default.ts @@ -13,9 +13,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/image/objectFit.ts b/apps/docs/content/components/image/objectFit.ts index ec5ed7dfc8..95cf2c0c9a 100644 --- a/apps/docs/content/components/image/objectFit.ts +++ b/apps/docs/content/components/image/objectFit.ts @@ -35,9 +35,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/image/showSkeleton.ts b/apps/docs/content/components/image/showSkeleton.ts index df203c4919..35fd435995 100644 --- a/apps/docs/content/components/image/showSkeleton.ts +++ b/apps/docs/content/components/image/showSkeleton.ts @@ -14,9 +14,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/image/size.ts b/apps/docs/content/components/image/size.ts index f0581a2cb9..698def892e 100644 --- a/apps/docs/content/components/image/size.ts +++ b/apps/docs/content/components/image/size.ts @@ -40,9 +40,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/index.ts b/apps/docs/content/components/index.ts index 6984008889..9795b06b7e 100644 --- a/apps/docs/content/components/index.ts +++ b/apps/docs/content/components/index.ts @@ -1,29 +1,29 @@ -import tableContent from './table'; -import UserContent from './user'; -import imageContent from './image'; -import avatarContent from './avatar'; -import buttonContent from './button'; -import buttonGrpContent from './button-group'; -import cardContent from './card'; -import paginationContent from './pagination'; -import collapseContent from './collapse'; -import inputContent from './input'; -import textareaContent from './textarea'; -import checkboxContent from './checkbox'; -import checkboxGroupContent from './checkbox-group'; -import radioContent from './radio'; -import progressContent from './progress'; -import tooltipContent from './tooltip'; -import modalContent from './modal'; -import loadingContent from './loading'; -import switchContent from './switch'; -import textContent from './text'; -import linkContent from './link'; -import containerContent from './container'; -import gridContent from './grid'; -import spacerContent from './spacer'; -import popoverContent from './popover'; -import dropdownContent from './dropdown'; +import tableContent from "./table"; +import UserContent from "./user"; +import imageContent from "./image"; +import avatarContent from "./avatar"; +import buttonContent from "./button"; +import buttonGrpContent from "./button-group"; +import cardContent from "./card"; +import paginationContent from "./pagination"; +import collapseContent from "./collapse"; +import inputContent from "./input"; +import textareaContent from "./textarea"; +import checkboxContent from "./checkbox"; +import checkboxGroupContent from "./checkbox-group"; +import radioContent from "./radio"; +import progressContent from "./progress"; +import tooltipContent from "./tooltip"; +import modalContent from "./modal"; +import loadingContent from "./loading"; +import switchContent from "./switch"; +import textContent from "./text"; +import linkContent from "./link"; +import containerContent from "./container"; +import gridContent from "./grid"; +import spacerContent from "./spacer"; +import popoverContent from "./popover"; +import dropdownContent from "./dropdown"; export default { tableContent, @@ -51,5 +51,5 @@ export default { gridContent, spacerContent, popoverContent, - dropdownContent + dropdownContent, }; diff --git a/apps/docs/content/components/input/LRLabels.ts b/apps/docs/content/components/input/LRLabels.ts index 2708cba5e2..46924ec371 100644 --- a/apps/docs/content/components/input/LRLabels.ts +++ b/apps/docs/content/components/input/LRLabels.ts @@ -49,10 +49,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/input/bordered.ts b/apps/docs/content/components/input/bordered.ts index 44a49a760d..47bc4957cf 100644 --- a/apps/docs/content/components/input/bordered.ts +++ b/apps/docs/content/components/input/bordered.ts @@ -44,10 +44,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/input/clearable.ts b/apps/docs/content/components/input/clearable.ts index 2d25e934bd..fcb22b9a3b 100644 --- a/apps/docs/content/components/input/clearable.ts +++ b/apps/docs/content/components/input/clearable.ts @@ -18,9 +18,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/input/content.ts b/apps/docs/content/components/input/content.ts index 7fb26e8f17..9e998be2f9 100644 --- a/apps/docs/content/components/input/content.ts +++ b/apps/docs/content/components/input/content.ts @@ -169,12 +169,12 @@ export default function App() { }`; const react = { - '/SunIcon.js': SunIcon, - '/App.js': AppJs, - '/SendButton.js': SendButton, - '/SendIcon.js': SendIcon + "/SunIcon.js": SunIcon, + "/App.js": AppJs, + "/SendButton.js": SendButton, + "/SendIcon.js": SendIcon, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/input/default.ts b/apps/docs/content/components/input/default.ts index f38e1f7ce2..b9c89297ac 100644 --- a/apps/docs/content/components/input/default.ts +++ b/apps/docs/content/components/input/default.ts @@ -5,9 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/input/disabled.ts b/apps/docs/content/components/input/disabled.ts index 3bd3d7b664..303387e1ce 100644 --- a/apps/docs/content/components/input/disabled.ts +++ b/apps/docs/content/components/input/disabled.ts @@ -12,9 +12,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/input/helper.ts b/apps/docs/content/components/input/helper.ts index 4711cab1d7..daef6c9209 100644 --- a/apps/docs/content/components/input/helper.ts +++ b/apps/docs/content/components/input/helper.ts @@ -92,9 +92,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/input/label.ts b/apps/docs/content/components/input/label.ts index d6881e4e32..6435b83b02 100644 --- a/apps/docs/content/components/input/label.ts +++ b/apps/docs/content/components/input/label.ts @@ -6,9 +6,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/input/labelPlaceholder.ts b/apps/docs/content/components/input/labelPlaceholder.ts index f16888903d..020c61448c 100644 --- a/apps/docs/content/components/input/labelPlaceholder.ts +++ b/apps/docs/content/components/input/labelPlaceholder.ts @@ -6,9 +6,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/input/noAnimated.ts b/apps/docs/content/components/input/noAnimated.ts index 0747a2bbfc..36439fad41 100644 --- a/apps/docs/content/components/input/noAnimated.ts +++ b/apps/docs/content/components/input/noAnimated.ts @@ -27,10 +27,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/input/password.ts b/apps/docs/content/components/input/password.ts index c82efcb79b..467246424a 100644 --- a/apps/docs/content/components/input/password.ts +++ b/apps/docs/content/components/input/password.ts @@ -115,11 +115,11 @@ export default function App() { }`; const react = { - '/UnLockIcon.js': UnLockIcon, - '/LockIcon.js': LockIcon, - '/App.js': AppJs + "/UnLockIcon.js": UnLockIcon, + "/LockIcon.js": LockIcon, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/input/rounded.ts b/apps/docs/content/components/input/rounded.ts index deba980d9a..568e9bd556 100644 --- a/apps/docs/content/components/input/rounded.ts +++ b/apps/docs/content/components/input/rounded.ts @@ -62,10 +62,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/input/shadow.ts b/apps/docs/content/components/input/shadow.ts index 5b4d64c8fa..1004ef0f09 100644 --- a/apps/docs/content/components/input/shadow.ts +++ b/apps/docs/content/components/input/shadow.ts @@ -50,10 +50,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/input/size.ts b/apps/docs/content/components/input/size.ts index 270baf42be..7ca043bae9 100644 --- a/apps/docs/content/components/input/size.ts +++ b/apps/docs/content/components/input/size.ts @@ -37,10 +37,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/input/status.ts b/apps/docs/content/components/input/status.ts index ad8fd7a0b8..4289b02ca3 100644 --- a/apps/docs/content/components/input/status.ts +++ b/apps/docs/content/components/input/status.ts @@ -44,10 +44,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/input/types.ts b/apps/docs/content/components/input/types.ts index 108e1cb179..903c479452 100644 --- a/apps/docs/content/components/input/types.ts +++ b/apps/docs/content/components/input/types.ts @@ -52,10 +52,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/input/underlined.ts b/apps/docs/content/components/input/underlined.ts index 1aaf57cc9a..dbd163e027 100644 --- a/apps/docs/content/components/input/underlined.ts +++ b/apps/docs/content/components/input/underlined.ts @@ -50,10 +50,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/link/block.ts b/apps/docs/content/components/link/block.ts index 000a16dbdf..2cb87be437 100644 --- a/apps/docs/content/components/link/block.ts +++ b/apps/docs/content/components/link/block.ts @@ -31,9 +31,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/link/color.ts b/apps/docs/content/components/link/color.ts index 072712f292..8f8a8a4b61 100644 --- a/apps/docs/content/components/link/color.ts +++ b/apps/docs/content/components/link/color.ts @@ -36,9 +36,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/link/default.ts b/apps/docs/content/components/link/default.ts index c345c317b1..3b347640e7 100644 --- a/apps/docs/content/components/link/default.ts +++ b/apps/docs/content/components/link/default.ts @@ -9,9 +9,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/link/icon.ts b/apps/docs/content/components/link/icon.ts index 98ca328144..2110797947 100644 --- a/apps/docs/content/components/link/icon.ts +++ b/apps/docs/content/components/link/icon.ts @@ -15,9 +15,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/link/nextLink.ts b/apps/docs/content/components/link/nextLink.ts index 7410f16132..a84f8aec41 100644 --- a/apps/docs/content/components/link/nextLink.ts +++ b/apps/docs/content/components/link/nextLink.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/link/variation.ts b/apps/docs/content/components/link/variation.ts index bc70ca0059..e23cc60105 100644 --- a/apps/docs/content/components/link/variation.ts +++ b/apps/docs/content/components/link/variation.ts @@ -32,9 +32,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/loading/color.ts b/apps/docs/content/components/loading/color.ts index 576fa58c8b..50e629334e 100644 --- a/apps/docs/content/components/loading/color.ts +++ b/apps/docs/content/components/loading/color.ts @@ -23,10 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/loading/default.ts b/apps/docs/content/components/loading/default.ts index 1fced60941..354e6f3c5c 100644 --- a/apps/docs/content/components/loading/default.ts +++ b/apps/docs/content/components/loading/default.ts @@ -5,9 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/loading/index.ts b/apps/docs/content/components/loading/index.ts index 85216305c6..c43267a9d7 100644 --- a/apps/docs/content/components/loading/index.ts +++ b/apps/docs/content/components/loading/index.ts @@ -1,9 +1,9 @@ -import default_loading from './default'; -import text from './text'; -import size from './size'; -import types from './types'; -import color from './color'; -import textColor from './textColor'; +import default_loading from "./default"; +import text from "./text"; +import size from "./size"; +import types from "./types"; +import color from "./color"; +import textColor from "./textColor"; export default { default_loading, @@ -11,6 +11,5 @@ export default { size, types, color, - textColor + textColor, }; - diff --git a/apps/docs/content/components/loading/size.ts b/apps/docs/content/components/loading/size.ts index 5dda356484..200fb284c5 100644 --- a/apps/docs/content/components/loading/size.ts +++ b/apps/docs/content/components/loading/size.ts @@ -22,10 +22,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/loading/text.ts b/apps/docs/content/components/loading/text.ts index 2b21f1c34b..a95954764f 100644 --- a/apps/docs/content/components/loading/text.ts +++ b/apps/docs/content/components/loading/text.ts @@ -5,10 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/loading/textColor.ts b/apps/docs/content/components/loading/textColor.ts index 378886b761..884fcaec15 100644 --- a/apps/docs/content/components/loading/textColor.ts +++ b/apps/docs/content/components/loading/textColor.ts @@ -33,10 +33,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/loading/types.ts b/apps/docs/content/components/loading/types.ts index 75052c2dd0..a99e348939 100644 --- a/apps/docs/content/components/loading/types.ts +++ b/apps/docs/content/components/loading/types.ts @@ -23,10 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/modal/blurBackground.ts b/apps/docs/content/components/modal/blurBackground.ts index cb0fd3bc7d..78cb0d234d 100644 --- a/apps/docs/content/components/modal/blurBackground.ts +++ b/apps/docs/content/components/modal/blurBackground.ts @@ -108,11 +108,11 @@ export default function App() { }`; const react = { - '/Password.js': Password, - '/Mail.js': Mail, - '/App.js': AppJs + "/Password.js": Password, + "/Mail.js": Mail, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/modal/default.ts b/apps/docs/content/components/modal/default.ts index 3d94e0c7fa..1354623e06 100644 --- a/apps/docs/content/components/modal/default.ts +++ b/apps/docs/content/components/modal/default.ts @@ -109,11 +109,11 @@ export default function App() { }`; const react = { - '/Password.js': Password, - '/Mail.js': Mail, - '/App.js': AppJs + "/Password.js": Password, + "/Mail.js": Mail, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/modal/fullscreen.ts b/apps/docs/content/components/modal/fullscreen.ts index 555594fe1b..2bb336e6e2 100644 --- a/apps/docs/content/components/modal/fullscreen.ts +++ b/apps/docs/content/components/modal/fullscreen.ts @@ -220,10 +220,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/modal/index.ts b/apps/docs/content/components/modal/index.ts index ad6cc60cc4..39a2aad412 100644 --- a/apps/docs/content/components/modal/index.ts +++ b/apps/docs/content/components/modal/index.ts @@ -1,10 +1,10 @@ -import default_modal from './default'; -import largeContent from './largeContent'; -import fullscreen from './fullscreen'; -import withoutPadding from './withoutPadding'; -import blurBackground from './blurBackground'; -import preventClose from './preventClose'; -import noAnimated from './noAnimated'; +import default_modal from "./default"; +import largeContent from "./largeContent"; +import fullscreen from "./fullscreen"; +import withoutPadding from "./withoutPadding"; +import blurBackground from "./blurBackground"; +import preventClose from "./preventClose"; +import noAnimated from "./noAnimated"; export default { default_modal, @@ -13,7 +13,5 @@ export default { withoutPadding, blurBackground, preventClose, - noAnimated - + noAnimated, }; - diff --git a/apps/docs/content/components/modal/largeContent.ts b/apps/docs/content/components/modal/largeContent.ts index 305f6d81fd..3730ab84a7 100644 --- a/apps/docs/content/components/modal/largeContent.ts +++ b/apps/docs/content/components/modal/largeContent.ts @@ -221,10 +221,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/modal/noAnimated.ts b/apps/docs/content/components/modal/noAnimated.ts index 14fa5bd23e..7fabebe17c 100644 --- a/apps/docs/content/components/modal/noAnimated.ts +++ b/apps/docs/content/components/modal/noAnimated.ts @@ -108,11 +108,11 @@ export default function App() { }`; const react = { - '/Password.js': Password, - '/Mail.js': Mail, - '/App.js': AppJs + "/Password.js": Password, + "/Mail.js": Mail, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/modal/preventClose.ts b/apps/docs/content/components/modal/preventClose.ts index b34e14b76b..7e9f9d1eb7 100644 --- a/apps/docs/content/components/modal/preventClose.ts +++ b/apps/docs/content/components/modal/preventClose.ts @@ -108,11 +108,11 @@ export default function App() { }`; const react = { - '/Password.js': Password, - '/Mail.js': Mail, - '/App.js': AppJs + "/Password.js": Password, + "/Mail.js": Mail, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/modal/withoutPadding.ts b/apps/docs/content/components/modal/withoutPadding.ts index 5b21211587..f5db14ae6a 100644 --- a/apps/docs/content/components/modal/withoutPadding.ts +++ b/apps/docs/content/components/modal/withoutPadding.ts @@ -51,9 +51,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/bordered.ts b/apps/docs/content/components/pagination/bordered.ts index 1059103d51..aa19a56270 100644 --- a/apps/docs/content/components/pagination/bordered.ts +++ b/apps/docs/content/components/pagination/bordered.ts @@ -14,9 +14,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/boundaries.ts b/apps/docs/content/components/pagination/boundaries.ts index fbd5c1bc94..1f375f98ba 100644 --- a/apps/docs/content/components/pagination/boundaries.ts +++ b/apps/docs/content/components/pagination/boundaries.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/color.ts b/apps/docs/content/components/pagination/color.ts index d59507a255..637ec50f50 100644 --- a/apps/docs/content/components/pagination/color.ts +++ b/apps/docs/content/components/pagination/color.ts @@ -39,9 +39,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/default.ts b/apps/docs/content/components/pagination/default.ts index e64fe0a885..0d226db016 100644 --- a/apps/docs/content/components/pagination/default.ts +++ b/apps/docs/content/components/pagination/default.ts @@ -5,10 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/pagination/dots.ts b/apps/docs/content/components/pagination/dots.ts index e10bd68ca2..14251f7dcc 100644 --- a/apps/docs/content/components/pagination/dots.ts +++ b/apps/docs/content/components/pagination/dots.ts @@ -32,9 +32,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/index.ts b/apps/docs/content/components/pagination/index.ts index 07ef97912f..2366a03fd2 100644 --- a/apps/docs/content/components/pagination/index.ts +++ b/apps/docs/content/components/pagination/index.ts @@ -1,15 +1,15 @@ -import default_pag from './default'; -import color from './color'; -import sizes from './sizes'; -import rounded from './rounded'; -import shadow from './shadow'; -import dots from './dots'; -import loop from './loop'; -import noMargin from './noMargin'; -import noCtrl from './noCtrl'; -import noAnimation from './noAnimation'; -import sibling from './sibling'; -import boundaries from './boundaries'; +import default_pag from "./default"; +import color from "./color"; +import sizes from "./sizes"; +import rounded from "./rounded"; +import shadow from "./shadow"; +import dots from "./dots"; +import loop from "./loop"; +import noMargin from "./noMargin"; +import noCtrl from "./noCtrl"; +import noAnimation from "./noAnimation"; +import sibling from "./sibling"; +import boundaries from "./boundaries"; export default { default_pag, @@ -23,6 +23,5 @@ export default { noCtrl, noAnimation, sibling, - boundaries + boundaries, }; - diff --git a/apps/docs/content/components/pagination/loop.ts b/apps/docs/content/components/pagination/loop.ts index 21f64f3528..3478cb3a0c 100644 --- a/apps/docs/content/components/pagination/loop.ts +++ b/apps/docs/content/components/pagination/loop.ts @@ -5,9 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/noAnimation.ts b/apps/docs/content/components/pagination/noAnimation.ts index 9b61972c27..c49f160b5e 100644 --- a/apps/docs/content/components/pagination/noAnimation.ts +++ b/apps/docs/content/components/pagination/noAnimation.ts @@ -5,9 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/noCtrl.ts b/apps/docs/content/components/pagination/noCtrl.ts index 99ee14d6c8..125d2b0258 100644 --- a/apps/docs/content/components/pagination/noCtrl.ts +++ b/apps/docs/content/components/pagination/noCtrl.ts @@ -20,9 +20,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/noMargin.ts b/apps/docs/content/components/pagination/noMargin.ts index 86bc60d21b..10cc80ccb2 100644 --- a/apps/docs/content/components/pagination/noMargin.ts +++ b/apps/docs/content/components/pagination/noMargin.ts @@ -5,9 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/rounded.ts b/apps/docs/content/components/pagination/rounded.ts index 3fce6b9c33..70ff18b3f1 100644 --- a/apps/docs/content/components/pagination/rounded.ts +++ b/apps/docs/content/components/pagination/rounded.ts @@ -5,9 +5,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/shadow.ts b/apps/docs/content/components/pagination/shadow.ts index 81f54fb161..002d6b8a79 100644 --- a/apps/docs/content/components/pagination/shadow.ts +++ b/apps/docs/content/components/pagination/shadow.ts @@ -32,9 +32,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/sibling.ts b/apps/docs/content/components/pagination/sibling.ts index 255030e796..57e44732de 100644 --- a/apps/docs/content/components/pagination/sibling.ts +++ b/apps/docs/content/components/pagination/sibling.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/pagination/sizes.ts b/apps/docs/content/components/pagination/sizes.ts index 9881f523e8..6c5ff185b5 100644 --- a/apps/docs/content/components/pagination/sizes.ts +++ b/apps/docs/content/components/pagination/sizes.ts @@ -32,9 +32,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/popover/bordered.ts b/apps/docs/content/components/popover/bordered.ts index e5354c0bf6..b46fa1d0ed 100644 --- a/apps/docs/content/components/popover/bordered.ts +++ b/apps/docs/content/components/popover/bordered.ts @@ -14,9 +14,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/popover/controlled-vs-uncontrolled.ts b/apps/docs/content/components/popover/controlled-vs-uncontrolled.ts index ac36109d4a..5e7ee38cf0 100644 --- a/apps/docs/content/components/popover/controlled-vs-uncontrolled.ts +++ b/apps/docs/content/components/popover/controlled-vs-uncontrolled.ts @@ -31,9 +31,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/popover/custom-content.ts b/apps/docs/content/components/popover/custom-content.ts index ab8093dadb..6a0c80290d 100644 --- a/apps/docs/content/components/popover/custom-content.ts +++ b/apps/docs/content/components/popover/custom-content.ts @@ -159,11 +159,11 @@ export default function App() { }`; const react = { - '/UserTwitterCard.js': UserTwitterCard, - '/DeleteUser.js': DeleteUser, - '/App.js': App + "/UserTwitterCard.js": UserTwitterCard, + "/DeleteUser.js": DeleteUser, + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/popover/default.ts b/apps/docs/content/components/popover/default.ts index adc8d10351..f231ab03f8 100644 --- a/apps/docs/content/components/popover/default.ts +++ b/apps/docs/content/components/popover/default.ts @@ -14,9 +14,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/popover/disable-animation.ts b/apps/docs/content/components/popover/disable-animation.ts index b2808f2d46..5f87225a9d 100644 --- a/apps/docs/content/components/popover/disable-animation.ts +++ b/apps/docs/content/components/popover/disable-animation.ts @@ -14,9 +14,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/popover/index.ts b/apps/docs/content/components/popover/index.ts index 8a77f01e48..b50d27892b 100644 --- a/apps/docs/content/components/popover/index.ts +++ b/apps/docs/content/components/popover/index.ts @@ -1,9 +1,9 @@ -import defaultPopover from './default'; -import placements from './placements'; -import controlledVsUncontrolled from './controlled-vs-uncontrolled'; -import disableAnimation from './disable-animation'; -import customContent from './custom-content'; -import bordered from './bordered'; +import defaultPopover from "./default"; +import placements from "./placements"; +import controlledVsUncontrolled from "./controlled-vs-uncontrolled"; +import disableAnimation from "./disable-animation"; +import customContent from "./custom-content"; +import bordered from "./bordered"; export default { defaultPopover, @@ -11,5 +11,5 @@ export default { controlledVsUncontrolled, customContent, disableAnimation, - bordered + bordered, }; diff --git a/apps/docs/content/components/popover/placements.ts b/apps/docs/content/components/popover/placements.ts index c488549558..f80274c308 100644 --- a/apps/docs/content/components/popover/placements.ts +++ b/apps/docs/content/components/popover/placements.ts @@ -75,14 +75,14 @@ export default function App() { }`; const react = { - '/App.js': AppJs + "/App.js": AppJs, }; const reactTs = { - '/App.tsx': AppTs + "/App.tsx": AppTs, }; export default { ...react, - ...reactTs + ...reactTs, }; diff --git a/apps/docs/content/components/progress/color.ts b/apps/docs/content/components/progress/color.ts index 5a1932f454..ca483dfefc 100644 --- a/apps/docs/content/components/progress/color.ts +++ b/apps/docs/content/components/progress/color.ts @@ -26,9 +26,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/progress/default.ts b/apps/docs/content/components/progress/default.ts index b925466c2e..32b741c359 100644 --- a/apps/docs/content/components/progress/default.ts +++ b/apps/docs/content/components/progress/default.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/progress/indeterminated.ts b/apps/docs/content/components/progress/indeterminated.ts index ade7a7704c..a5ffeeb54c 100644 --- a/apps/docs/content/components/progress/indeterminated.ts +++ b/apps/docs/content/components/progress/indeterminated.ts @@ -16,9 +16,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/progress/index.ts b/apps/docs/content/components/progress/index.ts index 4b4d6d2508..6f527d57da 100644 --- a/apps/docs/content/components/progress/index.ts +++ b/apps/docs/content/components/progress/index.ts @@ -1,12 +1,12 @@ -import default_progress from './default'; -import indeterminated_progress from './indeterminated'; -import color from './color'; -import size from './size'; -import status from './status'; -import shadow from './shadow'; -import striped from './striped'; -import squared from './squared'; -import noAnimation from './noAnimation'; +import default_progress from "./default"; +import indeterminated_progress from "./indeterminated"; +import color from "./color"; +import size from "./size"; +import status from "./status"; +import shadow from "./shadow"; +import striped from "./striped"; +import squared from "./squared"; +import noAnimation from "./noAnimation"; export default { default_progress, @@ -17,5 +17,5 @@ export default { shadow, striped, squared, - noAnimation + noAnimation, }; diff --git a/apps/docs/content/components/progress/noAnimation.ts b/apps/docs/content/components/progress/noAnimation.ts index 32ad31cc11..792330b6a7 100644 --- a/apps/docs/content/components/progress/noAnimation.ts +++ b/apps/docs/content/components/progress/noAnimation.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/progress/shadow.ts b/apps/docs/content/components/progress/shadow.ts index af2d1b4a37..045bab2f6e 100644 --- a/apps/docs/content/components/progress/shadow.ts +++ b/apps/docs/content/components/progress/shadow.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/progress/size.ts b/apps/docs/content/components/progress/size.ts index 2190b1f71f..fb86b5c9e0 100644 --- a/apps/docs/content/components/progress/size.ts +++ b/apps/docs/content/components/progress/size.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/progress/squared.ts b/apps/docs/content/components/progress/squared.ts index 09e9738541..1a746b210c 100644 --- a/apps/docs/content/components/progress/squared.ts +++ b/apps/docs/content/components/progress/squared.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/progress/status.ts b/apps/docs/content/components/progress/status.ts index 2c1320a18c..7cf5a98f11 100644 --- a/apps/docs/content/components/progress/status.ts +++ b/apps/docs/content/components/progress/status.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/progress/striped.ts b/apps/docs/content/components/progress/striped.ts index 0c17165f12..2ead88e360 100644 --- a/apps/docs/content/components/progress/striped.ts +++ b/apps/docs/content/components/progress/striped.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/color.ts b/apps/docs/content/components/radio/color.ts index 55e7f4efe2..b50b7de302 100644 --- a/apps/docs/content/components/radio/color.ts +++ b/apps/docs/content/components/radio/color.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/controlled-vs-uncontrolled.ts b/apps/docs/content/components/radio/controlled-vs-uncontrolled.ts index 9d950850c7..6f8128e741 100644 --- a/apps/docs/content/components/radio/controlled-vs-uncontrolled.ts +++ b/apps/docs/content/components/radio/controlled-vs-uncontrolled.ts @@ -32,9 +32,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/default.ts b/apps/docs/content/components/radio/default.ts index 7ad88ab745..a82b17e481 100644 --- a/apps/docs/content/components/radio/default.ts +++ b/apps/docs/content/components/radio/default.ts @@ -12,9 +12,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/description.ts b/apps/docs/content/components/radio/description.ts index 4b157527fa..077737ccde 100644 --- a/apps/docs/content/components/radio/description.ts +++ b/apps/docs/content/components/radio/description.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/disableAnimation.ts b/apps/docs/content/components/radio/disableAnimation.ts index d5da9a8bad..b53b8fcc58 100644 --- a/apps/docs/content/components/radio/disableAnimation.ts +++ b/apps/docs/content/components/radio/disableAnimation.ts @@ -12,9 +12,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/disabled.ts b/apps/docs/content/components/radio/disabled.ts index bbe112f2e4..08778deaea 100644 --- a/apps/docs/content/components/radio/disabled.ts +++ b/apps/docs/content/components/radio/disabled.ts @@ -16,9 +16,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/events.ts b/apps/docs/content/components/radio/events.ts index 4a2572b43f..9ee5369fc8 100644 --- a/apps/docs/content/components/radio/events.ts +++ b/apps/docs/content/components/radio/events.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/index.ts b/apps/docs/content/components/radio/index.ts index 13275ee346..9a0b9a721a 100644 --- a/apps/docs/content/components/radio/index.ts +++ b/apps/docs/content/components/radio/index.ts @@ -1,15 +1,15 @@ -import default_radio from './default'; -import disabled from './disabled'; -import size from './size'; -import color from './color'; -import labelColor from './labelColor'; -import squared from './squared'; -import description from './description'; -import row from './row'; -import disableAnimation from './disableAnimation'; -import controlledVsUncontrolled from './controlled-vs-uncontrolled'; -import events from './events'; -import invalid from './invalid'; +import default_radio from "./default"; +import disabled from "./disabled"; +import size from "./size"; +import color from "./color"; +import labelColor from "./labelColor"; +import squared from "./squared"; +import description from "./description"; +import row from "./row"; +import disableAnimation from "./disableAnimation"; +import controlledVsUncontrolled from "./controlled-vs-uncontrolled"; +import events from "./events"; +import invalid from "./invalid"; export default { default_radio, @@ -23,5 +23,5 @@ export default { disableAnimation, controlledVsUncontrolled, invalid, - events + events, }; diff --git a/apps/docs/content/components/radio/invalid.ts b/apps/docs/content/components/radio/invalid.ts index 18861c7932..5b30c1ba3d 100644 --- a/apps/docs/content/components/radio/invalid.ts +++ b/apps/docs/content/components/radio/invalid.ts @@ -20,9 +20,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/labelColor.ts b/apps/docs/content/components/radio/labelColor.ts index 5dc97ff6e6..712eea892f 100644 --- a/apps/docs/content/components/radio/labelColor.ts +++ b/apps/docs/content/components/radio/labelColor.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/row.ts b/apps/docs/content/components/radio/row.ts index aed518fc74..b6720c4be4 100644 --- a/apps/docs/content/components/radio/row.ts +++ b/apps/docs/content/components/radio/row.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/size.ts b/apps/docs/content/components/radio/size.ts index e6605393cc..7f8e859285 100644 --- a/apps/docs/content/components/radio/size.ts +++ b/apps/docs/content/components/radio/size.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/radio/squared.ts b/apps/docs/content/components/radio/squared.ts index 8b3961fe8e..3dd2000908 100644 --- a/apps/docs/content/components/radio/squared.ts +++ b/apps/docs/content/components/radio/squared.ts @@ -20,9 +20,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/spacer/horizontal.ts b/apps/docs/content/components/spacer/horizontal.ts index df80a0da58..8b638fced7 100644 --- a/apps/docs/content/components/spacer/horizontal.ts +++ b/apps/docs/content/components/spacer/horizontal.ts @@ -15,9 +15,9 @@ export default function App() { }`; const react = { - '/App.js': AppJs + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/spacer/index.ts b/apps/docs/content/components/spacer/index.ts index 54badd786d..9949fa6c72 100644 --- a/apps/docs/content/components/spacer/index.ts +++ b/apps/docs/content/components/spacer/index.ts @@ -1,7 +1,7 @@ -import vertical from './vertical'; -import horizontal from './horizontal' +import vertical from "./vertical"; +import horizontal from "./horizontal"; export default { vertical, - horizontal + horizontal, }; diff --git a/apps/docs/content/components/spacer/vertical.ts b/apps/docs/content/components/spacer/vertical.ts index 4b8df027c2..a113da7d1a 100644 --- a/apps/docs/content/components/spacer/vertical.ts +++ b/apps/docs/content/components/spacer/vertical.ts @@ -26,9 +26,9 @@ export default function App() { `; const react = { - '/App.js': AppJs + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/switch/bordered.ts b/apps/docs/content/components/switch/bordered.ts index 095d7262c0..57b39cb724 100644 --- a/apps/docs/content/components/switch/bordered.ts +++ b/apps/docs/content/components/switch/bordered.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/switch/color.ts b/apps/docs/content/components/switch/color.ts index d706593fe9..848345bf82 100644 --- a/apps/docs/content/components/switch/color.ts +++ b/apps/docs/content/components/switch/color.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/switch/default.ts b/apps/docs/content/components/switch/default.ts index aa0798ce8b..0171e1913a 100644 --- a/apps/docs/content/components/switch/default.ts +++ b/apps/docs/content/components/switch/default.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/switch/disabled.ts b/apps/docs/content/components/switch/disabled.ts index d61cd2844c..bc0986b1bf 100644 --- a/apps/docs/content/components/switch/disabled.ts +++ b/apps/docs/content/components/switch/disabled.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/switch/icon.ts b/apps/docs/content/components/switch/icon.ts index 88881d13d2..190f1b3e73 100644 --- a/apps/docs/content/components/switch/icon.ts +++ b/apps/docs/content/components/switch/icon.ts @@ -1,4 +1,3 @@ - const SunIcon = `import { React } from '@nextui-org/react';\n export const SunIcon = ({ @@ -61,7 +60,6 @@ export const SunIcon = ({ ); };`; - const MoonIcon = `import { React } from '@nextui-org/react';\n export const MoonIcon = ({ @@ -218,7 +216,7 @@ export const VolumeUpIcon = ({ > ); -};`; +};`; const NotificationIcon = `import { React } from '@nextui-org/react';\n @@ -352,7 +350,6 @@ export const MicrophoneOffIcon = ({ ); };`; - const AppJs = `import { Grid, Switch } from "@nextui-org/react"; import { SunIcon } from './SunIcon'; import { MoonIcon } from './MoonIcon'; @@ -413,18 +410,17 @@ export default function App() { }`; const react = { - '/SunIcon.js': SunIcon, - '/MoonIcon.js': MoonIcon, - '/VideoIcon.js': VideoIcon, - '/VolumeUpIcon.js': VolumeUpIcon, - '/MicrophoneIcon.js': MicrophoneIcon, - '/MicrophoneOffIcon.js': MicrophoneOffIcon, - '/NotificationIcon.js': NotificationIcon, - '/VideoOffIcon.js': VideoOffIcon, - '/App.js': AppJs + "/SunIcon.js": SunIcon, + "/MoonIcon.js": MoonIcon, + "/VideoIcon.js": VideoIcon, + "/VolumeUpIcon.js": VolumeUpIcon, + "/MicrophoneIcon.js": MicrophoneIcon, + "/MicrophoneOffIcon.js": MicrophoneOffIcon, + "/NotificationIcon.js": NotificationIcon, + "/VideoOffIcon.js": VideoOffIcon, + "/App.js": AppJs, }; - export default { ...react, }; diff --git a/apps/docs/content/components/switch/index.ts b/apps/docs/content/components/switch/index.ts index 867a14198a..0515bf0dd5 100644 --- a/apps/docs/content/components/switch/index.ts +++ b/apps/docs/content/components/switch/index.ts @@ -1,13 +1,13 @@ -import default_switch from './default'; -import initialCheck from './initialCheck'; -import disabled from './disabled'; -import size from './size'; -import color from './color'; -import shadow from './shadow'; -import squared from './squared'; -import bordered from './bordered'; -import noAnimated from './noAnimated'; -import icon from './icon'; +import default_switch from "./default"; +import initialCheck from "./initialCheck"; +import disabled from "./disabled"; +import size from "./size"; +import color from "./color"; +import shadow from "./shadow"; +import squared from "./squared"; +import bordered from "./bordered"; +import noAnimated from "./noAnimated"; +import icon from "./icon"; export default { default_switch, @@ -19,5 +19,5 @@ export default { squared, bordered, noAnimated, - icon + icon, }; diff --git a/apps/docs/content/components/switch/initialCheck.ts b/apps/docs/content/components/switch/initialCheck.ts index 2e22e73bbf..86b17f989e 100644 --- a/apps/docs/content/components/switch/initialCheck.ts +++ b/apps/docs/content/components/switch/initialCheck.ts @@ -6,9 +6,9 @@ export default function App() { `; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/switch/noAnimated.ts b/apps/docs/content/components/switch/noAnimated.ts index 3f89ed611b..7cf89d70ab 100644 --- a/apps/docs/content/components/switch/noAnimated.ts +++ b/apps/docs/content/components/switch/noAnimated.ts @@ -11,13 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - - - - diff --git a/apps/docs/content/components/switch/shadow.ts b/apps/docs/content/components/switch/shadow.ts index 17f3cbb44a..343392ad72 100644 --- a/apps/docs/content/components/switch/shadow.ts +++ b/apps/docs/content/components/switch/shadow.ts @@ -23,9 +23,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/switch/size.ts b/apps/docs/content/components/switch/size.ts index 60045347bf..3b08acd124 100644 --- a/apps/docs/content/components/switch/size.ts +++ b/apps/docs/content/components/switch/size.ts @@ -17,9 +17,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/switch/squared.ts b/apps/docs/content/components/switch/squared.ts index a01283e8ea..3e4e552926 100644 --- a/apps/docs/content/components/switch/squared.ts +++ b/apps/docs/content/components/switch/squared.ts @@ -9,9 +9,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/bordered.ts b/apps/docs/content/components/table/bordered.ts index caeedae8db..d344ec33e2 100644 --- a/apps/docs/content/components/table/bordered.ts +++ b/apps/docs/content/components/table/bordered.ts @@ -44,9 +44,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/colors.ts b/apps/docs/content/components/table/colors.ts index c7fdac1780..7f06bcf752 100644 --- a/apps/docs/content/components/table/colors.ts +++ b/apps/docs/content/components/table/colors.ts @@ -94,9 +94,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/compact.ts b/apps/docs/content/components/table/compact.ts index 3ed97e0eaf..1af3373da6 100644 --- a/apps/docs/content/components/table/compact.ts +++ b/apps/docs/content/components/table/compact.ts @@ -43,9 +43,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/custom-cells.ts b/apps/docs/content/components/table/custom-cells.ts index 435493f9d7..27436cf2f0 100644 --- a/apps/docs/content/components/table/custom-cells.ts +++ b/apps/docs/content/components/table/custom-cells.ts @@ -679,24 +679,24 @@ export default function App() { }`; const react = { - '/StyledBadge.js': StyledBadge, - '/IconButton.js': IconButton, - '/EyeIcon.js': EyeIconJs, - '/EditIcon.js': EditIconJs, - '/DeleteIcon.js': DeleteIconJs, - '/App.js': AppJs + "/StyledBadge.js": StyledBadge, + "/IconButton.js": IconButton, + "/EyeIcon.js": EyeIconJs, + "/EditIcon.js": EditIconJs, + "/DeleteIcon.js": DeleteIconJs, + "/App.js": AppJs, }; const reactTs = { - '/StyledBadge.tsx': StyledBadge, - '/IconButton.tsx': IconButton, - '/EyeIcon.tsx': EyeIconTs, - '/EditIcon.tsx': EditIconTs, - '/DeleteIcon.tsx': DeleteIconTs, - '/App.tsx': AppTs + "/StyledBadge.tsx": StyledBadge, + "/IconButton.tsx": IconButton, + "/EyeIcon.tsx": EyeIconTs, + "/EditIcon.tsx": EditIconTs, + "/DeleteIcon.tsx": DeleteIconTs, + "/App.tsx": AppTs, }; export default { ...react, - ...reactTs + ...reactTs, }; diff --git a/apps/docs/content/components/table/disabled-keys.ts b/apps/docs/content/components/table/disabled-keys.ts index e24f89fd06..8260d51018 100644 --- a/apps/docs/content/components/table/disabled-keys.ts +++ b/apps/docs/content/components/table/disabled-keys.ts @@ -43,9 +43,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/disallow-empty-selection.ts b/apps/docs/content/components/table/disallow-empty-selection.ts index eb7e4eb43a..ca04a8b8bb 100644 --- a/apps/docs/content/components/table/disallow-empty-selection.ts +++ b/apps/docs/content/components/table/disallow-empty-selection.ts @@ -45,9 +45,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/dynamic.ts b/apps/docs/content/components/table/dynamic.ts index e730e57a8d..fe2ca76d1a 100644 --- a/apps/docs/content/components/table/dynamic.ts +++ b/apps/docs/content/components/table/dynamic.ts @@ -66,9 +66,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/index.ts b/apps/docs/content/components/table/index.ts index c3da8fbdbe..3695141da8 100644 --- a/apps/docs/content/components/table/index.ts +++ b/apps/docs/content/components/table/index.ts @@ -1,20 +1,20 @@ -import staticTable from './static'; -import dynamicTable from './dynamic'; -import customCellsTable from './custom-cells'; -import singleSelectionTable from './single-selection'; -import multipleSelectionTable from './multiple-selection'; -import colorsTable from './colors'; -import borderedTable from './bordered'; -import linedTable from './lined'; -import stickedTable from './sticked'; -import compactTable from './compact'; -import stripedTable from './striped'; -import paginationTable from './pagination'; -import infinityPaginationTable from './infinity-pagination'; -import sortableTable from './sortable'; -import disabledKeysTable from './disabled-keys'; -import disallowEmptySelectionTable from './disallow-empty-selection'; -import noAnimatedTable from './no-animated'; +import staticTable from "./static"; +import dynamicTable from "./dynamic"; +import customCellsTable from "./custom-cells"; +import singleSelectionTable from "./single-selection"; +import multipleSelectionTable from "./multiple-selection"; +import colorsTable from "./colors"; +import borderedTable from "./bordered"; +import linedTable from "./lined"; +import stickedTable from "./sticked"; +import compactTable from "./compact"; +import stripedTable from "./striped"; +import paginationTable from "./pagination"; +import infinityPaginationTable from "./infinity-pagination"; +import sortableTable from "./sortable"; +import disabledKeysTable from "./disabled-keys"; +import disallowEmptySelectionTable from "./disallow-empty-selection"; +import noAnimatedTable from "./no-animated"; export default { staticTable, @@ -33,5 +33,5 @@ export default { sortableTable, disabledKeysTable, disallowEmptySelectionTable, - noAnimatedTable + noAnimatedTable, }; diff --git a/apps/docs/content/components/table/infinity-pagination.ts b/apps/docs/content/components/table/infinity-pagination.ts index 7b9dd25849..e42f687745 100644 --- a/apps/docs/content/components/table/infinity-pagination.ts +++ b/apps/docs/content/components/table/infinity-pagination.ts @@ -50,9 +50,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/lined.ts b/apps/docs/content/components/table/lined.ts index 3769d68f93..b2e10313b9 100644 --- a/apps/docs/content/components/table/lined.ts +++ b/apps/docs/content/components/table/lined.ts @@ -45,9 +45,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/multiple-selection.ts b/apps/docs/content/components/table/multiple-selection.ts index f56e125cbe..d592b69745 100644 --- a/apps/docs/content/components/table/multiple-selection.ts +++ b/apps/docs/content/components/table/multiple-selection.ts @@ -42,9 +42,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/no-animated.ts b/apps/docs/content/components/table/no-animated.ts index fdedd31980..c0809a4074 100644 --- a/apps/docs/content/components/table/no-animated.ts +++ b/apps/docs/content/components/table/no-animated.ts @@ -44,9 +44,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/pagination.ts b/apps/docs/content/components/table/pagination.ts index 9e08280570..565702b1db 100644 --- a/apps/docs/content/components/table/pagination.ts +++ b/apps/docs/content/components/table/pagination.ts @@ -72,9 +72,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/single-selection.ts b/apps/docs/content/components/table/single-selection.ts index 6f95ed765e..e56d5fddbd 100644 --- a/apps/docs/content/components/table/single-selection.ts +++ b/apps/docs/content/components/table/single-selection.ts @@ -42,9 +42,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/sortable.ts b/apps/docs/content/components/table/sortable.ts index e41254b0cc..432029041c 100644 --- a/apps/docs/content/components/table/sortable.ts +++ b/apps/docs/content/components/table/sortable.ts @@ -58,9 +58,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/static.ts b/apps/docs/content/components/table/static.ts index 590d912c2e..5924d314c2 100644 --- a/apps/docs/content/components/table/static.ts +++ b/apps/docs/content/components/table/static.ts @@ -41,9 +41,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/sticked.ts b/apps/docs/content/components/table/sticked.ts index 838540d0b4..2cb247008a 100644 --- a/apps/docs/content/components/table/sticked.ts +++ b/apps/docs/content/components/table/sticked.ts @@ -43,9 +43,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/table/striped.ts b/apps/docs/content/components/table/striped.ts index 01f4a10ec8..c715dae38d 100644 --- a/apps/docs/content/components/table/striped.ts +++ b/apps/docs/content/components/table/striped.ts @@ -44,9 +44,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/text/blockquote.ts b/apps/docs/content/components/text/blockquote.ts index ac018bb01f..b6639f131a 100644 --- a/apps/docs/content/components/text/blockquote.ts +++ b/apps/docs/content/components/text/blockquote.ts @@ -7,10 +7,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/text/color.ts b/apps/docs/content/components/text/color.ts index 1658599f54..a6afe191d5 100644 --- a/apps/docs/content/components/text/color.ts +++ b/apps/docs/content/components/text/color.ts @@ -26,9 +26,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/text/compose.ts b/apps/docs/content/components/text/compose.ts index dd9d118eee..b18fad436e 100644 --- a/apps/docs/content/components/text/compose.ts +++ b/apps/docs/content/components/text/compose.ts @@ -20,10 +20,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - diff --git a/apps/docs/content/components/text/default.ts b/apps/docs/content/components/text/default.ts index 3ba61e342a..29e7fa257f 100644 --- a/apps/docs/content/components/text/default.ts +++ b/apps/docs/content/components/text/default.ts @@ -15,9 +15,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/text/gradient.ts b/apps/docs/content/components/text/gradient.ts index b2d7b4b1bf..4d285d24ed 100644 --- a/apps/docs/content/components/text/gradient.ts +++ b/apps/docs/content/components/text/gradient.ts @@ -38,9 +38,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/text/index.ts b/apps/docs/content/components/text/index.ts index 33e4a6b463..0e2de6e71a 100644 --- a/apps/docs/content/components/text/index.ts +++ b/apps/docs/content/components/text/index.ts @@ -1,10 +1,10 @@ -import default_text from './default'; -import gradient from './gradient'; -import paragraph from './paragraph'; -import blockquote from './blockquote'; -import color from './color'; -import size from './size'; -import compose from './compose'; +import default_text from "./default"; +import gradient from "./gradient"; +import paragraph from "./paragraph"; +import blockquote from "./blockquote"; +import color from "./color"; +import size from "./size"; +import compose from "./compose"; export default { default_text, @@ -13,5 +13,5 @@ export default { blockquote, color, size, - compose + compose, }; diff --git a/apps/docs/content/components/text/paragraph.ts b/apps/docs/content/components/text/paragraph.ts index 86cd955e78..5039a61e91 100644 --- a/apps/docs/content/components/text/paragraph.ts +++ b/apps/docs/content/components/text/paragraph.ts @@ -12,9 +12,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/text/size.ts b/apps/docs/content/components/text/size.ts index 17be3aaaf1..4301602fee 100644 --- a/apps/docs/content/components/text/size.ts +++ b/apps/docs/content/components/text/size.ts @@ -3,22 +3,19 @@ const App = `import { Text } from "@nextui-org/react"; export default function App() { return ( <> - Font Size: 12px; - Font Size: 14px; - Font Size: 100%; - Font Size: 1.25rem; - Font Size: 2em; + Font Size: xs + Font Size: md (base) + Font Size: xl + Font Size: 2xl + Font Size: 3xl ); }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; - - - diff --git a/apps/docs/content/components/text/small.ts b/apps/docs/content/components/text/small.ts index 71f44e8619..285756d6a6 100644 --- a/apps/docs/content/components/text/small.ts +++ b/apps/docs/content/components/text/small.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/textarea/autosize.ts b/apps/docs/content/components/textarea/autosize.ts index 3b9121653b..ead6d6392a 100644 --- a/apps/docs/content/components/textarea/autosize.ts +++ b/apps/docs/content/components/textarea/autosize.ts @@ -24,9 +24,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/textarea/controlledUncontrolled.ts b/apps/docs/content/components/textarea/controlledUncontrolled.ts index b94a68891a..ca6890fac1 100644 --- a/apps/docs/content/components/textarea/controlledUncontrolled.ts +++ b/apps/docs/content/components/textarea/controlledUncontrolled.ts @@ -63,9 +63,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/textarea/default.ts b/apps/docs/content/components/textarea/default.ts index 866a1ea7da..c87081430c 100644 --- a/apps/docs/content/components/textarea/default.ts +++ b/apps/docs/content/components/textarea/default.ts @@ -10,9 +10,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/textarea/disabled.ts b/apps/docs/content/components/textarea/disabled.ts index 976c9c694f..8b18cd975e 100644 --- a/apps/docs/content/components/textarea/disabled.ts +++ b/apps/docs/content/components/textarea/disabled.ts @@ -15,9 +15,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/textarea/helper.ts b/apps/docs/content/components/textarea/helper.ts index f960fd629b..29d66f90c4 100644 --- a/apps/docs/content/components/textarea/helper.ts +++ b/apps/docs/content/components/textarea/helper.ts @@ -36,9 +36,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/textarea/index.ts b/apps/docs/content/components/textarea/index.ts index bda8e5e29f..9828302c60 100644 --- a/apps/docs/content/components/textarea/index.ts +++ b/apps/docs/content/components/textarea/index.ts @@ -1,10 +1,10 @@ -import default_textArea from './default'; -import disabled from './disabled'; -import autosize from './autosize'; -import types from './types'; -import status from './status'; -import helper from './helper'; -import controlledUncontrolled from './controlledUncontrolled'; +import default_textArea from "./default"; +import disabled from "./disabled"; +import autosize from "./autosize"; +import types from "./types"; +import status from "./status"; +import helper from "./helper"; +import controlledUncontrolled from "./controlledUncontrolled"; export default { default_textArea, @@ -13,5 +13,5 @@ export default { types, status, helper, - controlledUncontrolled + controlledUncontrolled, }; diff --git a/apps/docs/content/components/textarea/status.ts b/apps/docs/content/components/textarea/status.ts index 43d6fd3cbe..5556e7e32c 100644 --- a/apps/docs/content/components/textarea/status.ts +++ b/apps/docs/content/components/textarea/status.ts @@ -26,9 +26,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/textarea/types.ts b/apps/docs/content/components/textarea/types.ts index 30778f52f4..0ece62082a 100644 --- a/apps/docs/content/components/textarea/types.ts +++ b/apps/docs/content/components/textarea/types.ts @@ -25,9 +25,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/tooltip/color.ts b/apps/docs/content/components/tooltip/color.ts index 974fd29124..6ad913cecf 100644 --- a/apps/docs/content/components/tooltip/color.ts +++ b/apps/docs/content/components/tooltip/color.ts @@ -57,9 +57,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/tooltip/customContent.ts b/apps/docs/content/components/tooltip/customContent.ts index 3b167930ec..c2058c3491 100644 --- a/apps/docs/content/components/tooltip/customContent.ts +++ b/apps/docs/content/components/tooltip/customContent.ts @@ -179,11 +179,11 @@ export default function App() { }`; const react = { - '/UserTwitterCard.js': UserTwitterCard, - '/DeleteUser.js': DeleteUser, - '/App.js': AppJs + "/UserTwitterCard.js": UserTwitterCard, + "/DeleteUser.js": DeleteUser, + "/App.js": AppJs, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/tooltip/default.ts b/apps/docs/content/components/tooltip/default.ts index 885b4f35c5..29afd20cea 100644 --- a/apps/docs/content/components/tooltip/default.ts +++ b/apps/docs/content/components/tooltip/default.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/tooltip/index.ts b/apps/docs/content/components/tooltip/index.ts index 7df6e85b80..4745e09374 100644 --- a/apps/docs/content/components/tooltip/index.ts +++ b/apps/docs/content/components/tooltip/index.ts @@ -1,11 +1,11 @@ -import default_tooltip from './default'; -import rounded from './rounded'; -import color from './color'; -import textColor from './textColor'; -import trigger from './trigger'; -import placement from './placement'; -import noArrow from './noArrow'; -import customContent from './customContent'; +import default_tooltip from "./default"; +import rounded from "./rounded"; +import color from "./color"; +import textColor from "./textColor"; +import trigger from "./trigger"; +import placement from "./placement"; +import noArrow from "./noArrow"; +import customContent from "./customContent"; export default { default_tooltip, @@ -15,5 +15,5 @@ export default { trigger, placement, noArrow, - customContent + customContent, }; diff --git a/apps/docs/content/components/tooltip/noArrow.ts b/apps/docs/content/components/tooltip/noArrow.ts index 196d2768a9..a9dfce1cad 100644 --- a/apps/docs/content/components/tooltip/noArrow.ts +++ b/apps/docs/content/components/tooltip/noArrow.ts @@ -15,9 +15,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/tooltip/placement.ts b/apps/docs/content/components/tooltip/placement.ts index bbccb73f0c..7844f7552c 100644 --- a/apps/docs/content/components/tooltip/placement.ts +++ b/apps/docs/content/components/tooltip/placement.ts @@ -143,9 +143,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/tooltip/rounded.ts b/apps/docs/content/components/tooltip/rounded.ts index 8e8ef18c6b..50fea4241b 100644 --- a/apps/docs/content/components/tooltip/rounded.ts +++ b/apps/docs/content/components/tooltip/rounded.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/tooltip/textColor.ts b/apps/docs/content/components/tooltip/textColor.ts index d522bbfc28..8cbad65f52 100644 --- a/apps/docs/content/components/tooltip/textColor.ts +++ b/apps/docs/content/components/tooltip/textColor.ts @@ -70,9 +70,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/tooltip/trigger.ts b/apps/docs/content/components/tooltip/trigger.ts index ba0a775189..047a8ba96b 100644 --- a/apps/docs/content/components/tooltip/trigger.ts +++ b/apps/docs/content/components/tooltip/trigger.ts @@ -30,9 +30,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/user/border.ts b/apps/docs/content/components/user/border.ts index 0bf092f71f..9c5229766f 100644 --- a/apps/docs/content/components/user/border.ts +++ b/apps/docs/content/components/user/border.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/user/color.ts b/apps/docs/content/components/user/color.ts index ea8650edea..60c178d5e4 100644 --- a/apps/docs/content/components/user/color.ts +++ b/apps/docs/content/components/user/color.ts @@ -50,9 +50,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/user/default.ts b/apps/docs/content/components/user/default.ts index 30bcbc8ef5..897cae76b2 100644 --- a/apps/docs/content/components/user/default.ts +++ b/apps/docs/content/components/user/default.ts @@ -10,9 +10,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/user/description.ts b/apps/docs/content/components/user/description.ts index a2c706b4bf..e008dec5aa 100644 --- a/apps/docs/content/components/user/description.ts +++ b/apps/docs/content/components/user/description.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/user/index.ts b/apps/docs/content/components/user/index.ts index 3aacdae493..7ecb76f7cb 100644 --- a/apps/docs/content/components/user/index.ts +++ b/apps/docs/content/components/user/index.ts @@ -1,12 +1,12 @@ -import default_user from './default'; -import size from './size'; -import color from './color'; -import border from './border'; -import zoomed from './zoomed'; -import pointer from './pointer'; -import squared from './squared'; -import description from './description'; -import link from './link'; +import default_user from "./default"; +import size from "./size"; +import color from "./color"; +import border from "./border"; +import zoomed from "./zoomed"; +import pointer from "./pointer"; +import squared from "./squared"; +import description from "./description"; +import link from "./link"; export default { default_user, @@ -17,5 +17,5 @@ export default { pointer, squared, description, - link + link, }; diff --git a/apps/docs/content/components/user/link.ts b/apps/docs/content/components/user/link.ts index 65551cb52a..75d515c3a4 100644 --- a/apps/docs/content/components/user/link.ts +++ b/apps/docs/content/components/user/link.ts @@ -12,9 +12,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/user/pointer.ts b/apps/docs/content/components/user/pointer.ts index 07e21b82fb..b508895515 100644 --- a/apps/docs/content/components/user/pointer.ts +++ b/apps/docs/content/components/user/pointer.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/user/size.ts b/apps/docs/content/components/user/size.ts index c349c187e5..57a44f7fd6 100644 --- a/apps/docs/content/components/user/size.ts +++ b/apps/docs/content/components/user/size.ts @@ -37,9 +37,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/user/squared.ts b/apps/docs/content/components/user/squared.ts index 60e1d36525..290c809156 100644 --- a/apps/docs/content/components/user/squared.ts +++ b/apps/docs/content/components/user/squared.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/components/user/zoomed.ts b/apps/docs/content/components/user/zoomed.ts index 90e31a5961..c74f007072 100644 --- a/apps/docs/content/components/user/zoomed.ts +++ b/apps/docs/content/components/user/zoomed.ts @@ -11,9 +11,9 @@ export default function App() { }`; const react = { - '/App.js': App + "/App.js": App, }; export default { - ...react + ...react, }; diff --git a/apps/docs/content/docs/manifest.json b/apps/docs/content/docs/manifest.json index ebabfb21df..f86899211e 100644 --- a/apps/docs/content/docs/manifest.json +++ b/apps/docs/content/docs/manifest.json @@ -1,231 +1,231 @@ { - "routes": [ + "routes": [ + { + "title": "Documentation", + "keywords": "docs, doc, documentation, getting started, nextui", + "subtitle": "For an advanced search please use the search input", + "icon": "note", + "section": "Scope", + "heading": true, + "routes": [ { - "title": "Documentation", - "keywords": "docs, doc, documentation, getting started, nextui", - "subtitle": "For an advanced search please use the search input", - "icon": "note", - "section": "Scope", - "heading": true, - "routes": [ - { - "title": "Guide", - "open": true, - "keywords": "guide, getting started, start, nextui", - "icon": "/paper.svg", - "routes": [ - { - "title": "Getting Started", - "keywords": "getting started, start, nextui", - "path": "/docs/guide/getting-started.mdx" - }, - { - "title": "NextUI + Next.js", - "keywords": "next, nextjs, nextui", - "path": "/docs/guide/nextui-plus-nextjs.mdx" - } - ] - }, - { - "title": "Theme", - "keywords": "themeable, theme, customize, palette", - "icon": "/category.svg", - "open": true, - "routes": [ - { - "title": "Default theme", - "updated": true, - "path": "/docs/theme/default-theme.mdx" - }, - { - "title": "Customize theme", - "path": "/docs/theme/customize-theme.mdx" - }, - { - "title": "Dark mode", - "path": "/docs/theme/dark-mode.mdx" - }, - { - "title": "Override styles", - "path": "/docs/theme/override-styles.mdx" - }, - { - "title": "Typescript", - "path": "/docs/theme/typescript.mdx" - }, - { - "title": "Utilities", - "path": "/docs/theme/utilities.mdx" - }, - { - "title": "Media", - "path": "/docs/theme/media.mdx" - } - ] - }, - { - "title": "Layout", - "icon": "/layout.svg", - "keywords": "layout, container, grid, spacer, flex", - "open": true, - "routes": [ - { - "title": "Container", - "keywords": "cont, container, flex, media query", - "path": "/docs/layout/container.mdx" - }, - { - "title": "Grid", - "keywords": "grid, container, media query", - "path": "/docs/layout/grid.mdx" - }, - { - "title": "Spacer", - "keywords": "space, spacer, gap", - "path": "/docs/layout/spacer.mdx" - } - ] - }, - { - "title": "Components", - "keywords": "components, btn, button, input, modal", - "icon": "/components.svg", - "open": true, - "routes": [ - { - "title": "Avatar", - "keywords": "avatar, avatar group, group", - "path": "/docs/components/avatar.mdx" - }, - { - "title": "Button", - "keywords": "button, btn, buttons, action", - "path": "/docs/components/button.mdx" - }, - { - "title": "Button Group", - "keywords": "btn, button, btn group, button group, group", - "path": "/docs/components/button-group.mdx" - }, - { - "title": "Card", - "keywords": "card, content, action, media", - "path": "/docs/components/card.mdx", - "updated": true - }, - { - "title": "Pagination", - "keywords": "pagination, paginate, table pagination, pages, navigate", - "path": "/docs/components/pagination.mdx" - }, - { - "title": "Table", - "keywords":"table, data table, grid, data grid", - "path": "/docs/components/table.mdx" - }, - { - "title": "Collapse", - "keywords": "collapse, accordion, expand, reveal", - "path": "/docs/components/collapse.mdx" - }, - { - "title": "Input", - "keywords": "text input, input, textarea", - "path": "/docs/components/input.mdx" - }, - { - "title": "Autocomplete", - "comingSoon": true - }, - { - "title": "Textarea", - "keywords": "textarea, input, text input, large text input", - "path": "/docs/components/textarea.mdx" - }, - { - "title": "Checkbox", - "keywords": "check, radio, selectable, checkbox, box", - "path": "/docs/components/checkbox.mdx" - }, - { - "title": "Checkbox Group", - "keywords": "check, radio, selectable, checkbox, box, group, items", - "path": "/docs/components/checkbox-group.mdx" - }, - { - "title": "Radio", - "updated": true, - "keywords": "check, radio, select", - "path": "/docs/components/radio.mdx" - }, - { - "title": "Popover", - "keywords": "popover, tooltip, tooltip, popover, popover", - "path": "/docs/components/popover.mdx", - "updated": true - }, - { - "title": "Tooltip", - "keywords": "tool, popover, tooltip, hoverable", - "path": "/docs/components/tooltip.mdx" - }, - { - "title": "Dropdown", - "keywords": "dropdown, select, selectable, menu", - "path": "/docs/components/dropdown.mdx", - "newPost": true - }, - { - "title": "Progress", - "keywords": "progress, bar, task, display, activity", - "path": "/docs/components/progress.mdx" - }, - { - "title": "Select", - "comingSoon": true - }, - { - "title": "Modal", - "keywords": "modal, dialog, backdrop", - "path": "/docs/components/modal.mdx" - }, - { - "title": "Loading", - "keywords": "loading, spinner, loadable, progress", - "path": "/docs/components/loading.mdx" - }, - { - "title": "Navbar", - "comingSoon": true - }, - { - "title": "Switch", - "keywords": "toggle, switch", - "path": "/docs/components/switch.mdx" - }, - { - "title": "Text", - "keywords": "text, txt, paragraph", - "path": "/docs/components/text.mdx" - }, - { - "title": "Link", - "keywords": "link, navigation, href, next link", - "path": "/docs/components/link.mdx" - }, - { - "title": "User", - "keywords": "User, avatar, name, initials", - "path": "/docs/components/user.mdx" - }, - { - "title": "Image", - "keywords": "Image, Next.js Image, image component", - "path": "/docs/components/image.mdx" - } - ] - } - ] + "title": "Guide", + "open": true, + "keywords": "guide, getting started, start, nextui", + "icon": "/paper.svg", + "routes": [ + { + "title": "Getting Started", + "keywords": "getting started, start, nextui", + "path": "/docs/guide/getting-started.mdx" + }, + { + "title": "NextUI + Next.js", + "keywords": "next, nextjs, nextui", + "path": "/docs/guide/nextui-plus-nextjs.mdx" + } + ] + }, + { + "title": "Theme", + "keywords": "themeable, theme, customize, palette", + "icon": "/category.svg", + "open": true, + "routes": [ + { + "title": "Default theme", + "updated": true, + "path": "/docs/theme/default-theme.mdx" + }, + { + "title": "Customize theme", + "path": "/docs/theme/customize-theme.mdx" + }, + { + "title": "Dark mode", + "path": "/docs/theme/dark-mode.mdx" + }, + { + "title": "Override styles", + "path": "/docs/theme/override-styles.mdx" + }, + { + "title": "Typescript", + "path": "/docs/theme/typescript.mdx" + }, + { + "title": "Utilities", + "path": "/docs/theme/utilities.mdx" + }, + { + "title": "Media", + "path": "/docs/theme/media.mdx" + } + ] + }, + { + "title": "Layout", + "icon": "/layout.svg", + "keywords": "layout, container, grid, spacer, flex", + "open": true, + "routes": [ + { + "title": "Container", + "keywords": "cont, container, flex, media query", + "path": "/docs/layout/container.mdx" + }, + { + "title": "Grid", + "keywords": "grid, container, media query", + "path": "/docs/layout/grid.mdx" + }, + { + "title": "Spacer", + "keywords": "space, spacer, gap", + "path": "/docs/layout/spacer.mdx" + } + ] + }, + { + "title": "Components", + "keywords": "components, btn, button, input, modal", + "icon": "/components.svg", + "open": true, + "routes": [ + { + "title": "Avatar", + "keywords": "avatar, avatar group, group", + "path": "/docs/components/avatar.mdx" + }, + { + "title": "Button", + "keywords": "button, btn, buttons, action", + "path": "/docs/components/button.mdx" + }, + { + "title": "Button Group", + "keywords": "btn, button, btn group, button group, group", + "path": "/docs/components/button-group.mdx" + }, + { + "title": "Card", + "keywords": "card, content, action, media", + "path": "/docs/components/card.mdx", + "updated": true + }, + { + "title": "Pagination", + "keywords": "pagination, paginate, table pagination, pages, navigate", + "path": "/docs/components/pagination.mdx" + }, + { + "title": "Table", + "keywords": "table, data table, grid, data grid", + "path": "/docs/components/table.mdx" + }, + { + "title": "Collapse", + "keywords": "collapse, accordion, expand, reveal", + "path": "/docs/components/collapse.mdx" + }, + { + "title": "Input", + "keywords": "text input, input, textarea", + "path": "/docs/components/input.mdx" + }, + { + "title": "Autocomplete", + "comingSoon": true + }, + { + "title": "Textarea", + "keywords": "textarea, input, text input, large text input", + "path": "/docs/components/textarea.mdx" + }, + { + "title": "Checkbox", + "keywords": "check, radio, selectable, checkbox, box", + "path": "/docs/components/checkbox.mdx" + }, + { + "title": "Checkbox Group", + "keywords": "check, radio, selectable, checkbox, box, group, items", + "path": "/docs/components/checkbox-group.mdx" + }, + { + "title": "Radio", + "updated": true, + "keywords": "check, radio, select", + "path": "/docs/components/radio.mdx" + }, + { + "title": "Popover", + "keywords": "popover, tooltip, tooltip, popover, popover", + "path": "/docs/components/popover.mdx", + "updated": true + }, + { + "title": "Tooltip", + "keywords": "tool, popover, tooltip, hoverable", + "path": "/docs/components/tooltip.mdx" + }, + { + "title": "Dropdown", + "keywords": "dropdown, select, selectable, menu", + "path": "/docs/components/dropdown.mdx", + "newPost": true + }, + { + "title": "Progress", + "keywords": "progress, bar, task, display, activity", + "path": "/docs/components/progress.mdx" + }, + { + "title": "Select", + "comingSoon": true + }, + { + "title": "Modal", + "keywords": "modal, dialog, backdrop", + "path": "/docs/components/modal.mdx" + }, + { + "title": "Loading", + "keywords": "loading, spinner, loadable, progress", + "path": "/docs/components/loading.mdx" + }, + { + "title": "Navbar", + "comingSoon": true + }, + { + "title": "Switch", + "keywords": "toggle, switch", + "path": "/docs/components/switch.mdx" + }, + { + "title": "Text", + "keywords": "text, txt, paragraph", + "path": "/docs/components/text.mdx" + }, + { + "title": "Link", + "keywords": "link, navigation, href, next link", + "path": "/docs/components/link.mdx" + }, + { + "title": "User", + "keywords": "User, avatar, name, initials", + "path": "/docs/components/user.mdx" + }, + { + "title": "Image", + "keywords": "Image, Next.js Image, image component", + "path": "/docs/components/image.mdx" + } + ] } - ] -} \ No newline at end of file + ] + } + ] +} diff --git a/apps/docs/content/landing/index.tsx b/apps/docs/content/landing/index.tsx index 5df8b5fd6f..b4c34181c8 100644 --- a/apps/docs/content/landing/index.tsx +++ b/apps/docs/content/landing/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React from "react"; import { Moon, Magic, @@ -9,85 +9,84 @@ import { RoundPointer, Maximize, CodeDocument, - HtmlLogo -} from '@components'; + HtmlLogo, +} from "@components"; export default { topFeatures: [ { - title: 'Themeable', + title: "Themeable", description: - 'Provides a simple way to customize default themes, you can change the colors, fonts, breakpoints and everything you need.', - icon: + "Provides a simple way to customize default themes, you can change the colors, fonts, breakpoints and everything you need.", + icon: , }, { - title: 'Fast', + title: "Fast", description: - 'Avoids unnecessary styles props at runtime, making it more performant than other UI libraries.', - icon: + "Avoids unnecessary styles props at runtime, making it more performant than other UI libraries.", + icon: , }, { - title: 'Light & Dark UI', + title: "Light & Dark UI", description: - 'Automatic dark mode recognition, NextUI automatically changes the theme when detects HTML theme prop changes.', - icon: + "Automatic dark mode recognition, NextUI automatically changes the theme when detects HTML theme prop changes.", + icon: , }, { - title: 'Unique DX', + title: "Unique DX", description: - 'NextUI is fully-typed to minimize the learning curve, and provide the best possible developer experience.', - icon: - } + "NextUI is fully-typed to minimize the learning curve, and provide the best possible developer experience.", + icon: , + }, ], fullFeatures: [ { - title: 'Server side render (SSR)', + title: "Server side render (SSR)", description: - 'All NextUI components support cross-browser server-side rendering and provides a simple way to implement it in your project.', - icon: + "All NextUI components support cross-browser server-side rendering and provides a simple way to implement it in your project.", + icon: , }, { - title: 'Accessible components', + title: "Accessible components", description: - 'NextUI components follow the WAI-ARIA guidelines, provide keyboard support and sensible focus management.', - icon: + "NextUI components follow the WAI-ARIA guidelines, provide keyboard support and sensible focus management.", + icon: , }, { - title: 'Focus interactions', + title: "Focus interactions", description: - 'Focus ring will appear only when user navigates with keyboard or screen reader.', - icon: + "Focus ring will appear only when user navigates with keyboard or screen reader.", + icon: , }, { - title: 'Built-in media queries', + title: "Built-in media queries", description: - 'NextUI provides a set of common media queries that, along with Stitches breakpoints allow you create responsive layouts faster.', - icon: + "NextUI provides a set of common media queries that, along with Stitches breakpoints allow you create responsive layouts faster.", + icon: , }, { - title: 'TypeScript based', + title: "TypeScript based", description: - 'Build type safe applications, NextUI has a fully-typed API to minimize the learning curve, and help you build applications.', - icon: + "Build type safe applications, NextUI has a fully-typed API to minimize the learning curve, and help you build applications.", + icon: , }, { - title: 'Override components tags', - description: - 'A polymorphic `as` prop is included in all NextUI components.', - icon: + title: "Override components tags", + description: "A polymorphic `as` prop is included in all NextUI components.", + icon: , }, { - title: 'Critical Path CSS', + title: "Critical Path CSS", description: "Since NextUI is based on Stitches, it only injects the styles which are actually used, so your users don't download unnecessary CSS.", - icon: + icon: , }, { - title: 'Beautifully designed', + title: "Beautifully designed", description: - 'NextUI components are unique and are not tied to any visual trend or design rule, which makes us unique and of course your projects as well.', - icon: - } + "NextUI components are unique and are not tied to any visual trend or design rule, which makes us unique and of course your projects as well.", + icon: , + }, ], themingCode: `import { createTheme } from '@nextui-org/react'; @@ -283,7 +282,7 @@ const MyComponent = () => { ); }; -export default MyComponent;` +export default MyComponent;`, }, darkModeCode: `// 1. Import createTheme import { createTheme, NextUIProvider } from "@nextui-org/react" @@ -408,5 +407,5 @@ export default CustomButton; backgroundClip: value }), -}` +}`, }; From a2008f32c6cac0ce106b1065e167363c91d822ca Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sun, 19 Jun 2022 18:38:09 -0300 Subject: [PATCH 009/106] feat(react-text): now users can use any of the fontSizes theme tokens on the size prop --- apps/docs/content/docs/components/text.mdx | 2 + packages/react/src/text/child.tsx | 47 ++++++++++++++------- packages/react/src/text/text.stories.tsx | 10 ++--- packages/react/src/theme/stitches.config.ts | 29 +++++++------ 4 files changed, 53 insertions(+), 35 deletions(-) diff --git a/apps/docs/content/docs/components/text.mdx b/apps/docs/content/docs/components/text.mdx index 509f65b8c0..df7547d11d 100644 --- a/apps/docs/content/docs/components/text.mdx +++ b/apps/docs/content/docs/components/text.mdx @@ -53,6 +53,8 @@ import { Text } from '@nextui-org/react'; files={textContent.size} /> +> **Note:** You can use any of the [theme font sizes](http://localhost:3000/docs/theme/default-theme#2.-font-sizes) included your own [custom font sizes](http://localhost:3000/docs/theme/customize-theme) (if you have). + ; -type FontSize = number | string | keyof FontSizes; +type FontSize = CSS["fontSize"]; export interface Props { tag: keyof JSX.IntrinsicElements; children?: ReactNode; color?: SimpleColors | string; + /** + * The **`font-size`** CSS property sets the size of the font. Changing the font size also updates the sizes of the font size-relative `` units, such as `em`, `ex`, and so forth. + * + * **Syntax**: ` | | ` + * + * **Initial value**: `medium` + * + */ size?: FontSize; - transform?: TextTransforms; + /** + * The **`text-transform`** CSS property specifies how to capitalize an element's text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized. It also can help improve legibility for ruby. + * + * **Syntax**: `none | capitalize | uppercase | lowercase | full-width | full-size-kana` + * + * **Initial value**: `none` + * + */ + transform?: CSS["textTransform"]; css?: CSS; as?: As; } @@ -27,20 +44,18 @@ type NativeAttrs = Omit, keyof Props>; export type TextChildProps = Props & NativeAttrs & TextVariantsProps; export const TextChild = React.forwardRef((props: TextChildProps, ref: ReactRef) => { - const {children, tag, color: userColor = "default", transform, size, css, ...otherProps} = props; + const { + children, + tag, + color: userColor = "default", + transform, + size: fontSize, + css, + ...otherProps + } = props; const domRef = useDOMRef(ref); - const fontSize = useMemo(() => { - if (!size) return "inherit"; - if (typeof size === "number") return `${size}px`; - if (baseTheme.theme.fontSizes?.[size as keyof FontSizes]) { - return `$${size}`; - } - - return size; - }, [size]); - const color = useMemo(() => { if (isNormalColor(userColor)) { switch (userColor) { @@ -60,7 +75,7 @@ export const TextChild = React.forwardRef((props: TextChildProps, ref: ReactRef< as={tag} css={{ color, - fontSize: size ? fontSize : "", + fontSize, tt: transform, ...(css as any), }} diff --git a/packages/react/src/text/text.stories.tsx b/packages/react/src/text/text.stories.tsx index c59635edb8..fb9770bb61 100644 --- a/packages/react/src/text/text.stories.tsx +++ b/packages/react/src/text/text.stories.tsx @@ -100,11 +100,11 @@ export const Blockquote = () => ( export const Sizes = () => ( <> - Font Size: 12px; - Font Size: 14px; - Font Size: 100%; - Font Size: 1.25rem; - Font Size: 2em; + Font Size: xs; + Font Size: md (base); + Font Size: xl; + Font Size: 2xl; + Font Size: 3xl; ); diff --git a/packages/react/src/theme/stitches.config.ts b/packages/react/src/theme/stitches.config.ts index 021101b428..d78a4d4ff5 100644 --- a/packages/react/src/theme/stitches.config.ts +++ b/packages/react/src/theme/stitches.config.ts @@ -38,7 +38,6 @@ export const keyframes = stitches.keyframes; export const getCssText = stitches.getCssText; export const theme = stitches.theme; export const config = stitches.config; -export const baseTheme = commonTheme; export const createTheme = ({type, theme, className}: Theme) => { if (!type) { @@ -52,22 +51,24 @@ export const createTheme = ({type, theme, className}: Theme) => { }; // stitches types +export type StitchesConfig = typeof config; export type VariantProps = Stitches.VariantProps; export type PropertyValue = Stitches.PropertyValue; +export type ScaleValue = Stitches.ScaleValue; export type CSSProperties = Stitches.CSSProperties; -export type CSS = Stitches.CSS; +export type CSS = Stitches.CSS; export type StitchesTheme = typeof theme; // common theme types -export type Spaces = typeof commonTheme.theme["space"]; -export type FontSizes = typeof commonTheme.theme["fontSizes"]; -export type Fonts = typeof commonTheme.theme["fonts"]; -export type FontWeights = typeof commonTheme.theme["fontWeights"]; -export type LineHeights = typeof commonTheme.theme["lineHeights"]; -export type LetterSpacings = typeof commonTheme.theme["letterSpacings"]; -export type Colors = typeof commonTheme.theme["colors"]; -export type Radii = typeof commonTheme.theme["radii"]; -export type zIndices = typeof commonTheme.theme["zIndices"]; -export type BorderWeights = typeof commonTheme.theme["borderWeights"]; -export type Tranistions = typeof commonTheme.theme["transitions"]; -export type Breakpoints = typeof commonTheme.theme["breakpoints"]; +export type Spaces = StitchesConfig["theme"]["space"]; +export type FontSizes = StitchesConfig["theme"]["fontSizes"]; +export type Fonts = StitchesConfig["theme"]["fonts"]; +export type FontWeights = StitchesConfig["theme"]["fontWeights"]; +export type LineHeights = StitchesConfig["theme"]["lineHeights"]; +export type LetterSpacings = StitchesConfig["theme"]["letterSpacings"]; +export type Colors = StitchesConfig["theme"]["colors"]; +export type Radii = StitchesConfig["theme"]["radii"]; +export type zIndices = StitchesConfig["theme"]["zIndices"]; +export type BorderWeights = StitchesConfig["theme"]["borderWeights"]; +export type Tranistions = StitchesConfig["theme"]["transitions"]; +export type Breakpoints = StitchesConfig["theme"]["breakpoints"]; From 0efbee975ee7de4b296698b71679e48928c81964 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sun, 19 Jun 2022 18:42:06 -0300 Subject: [PATCH 010/106] fix(react-config): 'React' is declared but its value is never read" --- packages/react/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index cd893e099b..07870c8d9b 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "baseUrl": ".", - "jsx": "preserve", + "jsx": "react", "skipLibCheck": true, "moduleResolution": "node", "allowJs": true, From 4401e4512b71f9f1cd17cfbc7f57ae9c6c1df712 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sun, 19 Jun 2022 20:56:53 -0300 Subject: [PATCH 011/106] feat(docs-text): font size updated --- apps/docs/content/docs/components/text.mdx | 73 +++++++++++----------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/apps/docs/content/docs/components/text.mdx b/apps/docs/content/docs/components/text.mdx index df7547d11d..34b8ddd8f3 100644 --- a/apps/docs/content/docs/components/text.mdx +++ b/apps/docs/content/docs/components/text.mdx @@ -1,6 +1,6 @@ --- -title: 'Text' -description: 'Text component is the used to render text and paragraphs within an interface using well-defined typographic styles.' +title: "Text" +description: "Text component is the used to render text and paragraphs within an interface using well-defined typographic styles." url: https://nextui.org/docs/components/text --- @@ -10,7 +10,7 @@ Text component is the used to render text and paragraphs within an interface usi It renders a `

        ` tag by default. ```jsx -import { Text } from '@nextui-org/react'; +import { Text } from "@nextui-org/react"; ``` @@ -53,7 +53,7 @@ import { Text } from '@nextui-org/react'; files={textContent.size} /> -> **Note:** You can use any of the [theme font sizes](http://localhost:3000/docs/theme/default-theme#2.-font-sizes) included your own [custom font sizes](http://localhost:3000/docs/theme/customize-theme) (if you have). +> **Note:** You can use any of the [theme font sizes](/docs/theme/default-theme#2.-font-sizes) included your own [custom font sizes](http://localhost:3000/docs/theme/customize-theme) (if you have). @@ -98,29 +97,29 @@ import { Text } from '@nextui-org/react'; ```ts type TextTransforms = /* Keyword values */ - | 'none' - | 'capitalize' - | 'uppercase' - | 'lowercase' - | 'full-width' - | 'full-size-kana' + | "none" + | "capitalize" + | "uppercase" + | "lowercase" + | "full-width" + | "full-size-kana" /* Global values */ - | 'inherit' - | 'initial' - | 'revert' - | 'unset'; + | "inherit" + | "initial" + | "revert" + | "unset"; ``` #### Simple Colors ```ts type SimpleColors = - | 'default' - | 'primary' - | 'secondary' - | 'success' - | 'warning' - | 'error'; + | "default" + | "primary" + | "secondary" + | "success" + | "warning" + | "error"; ``` #### Text Weights From eb60d77b5fdc4610722f6a6e9ba232555ead1707 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sun, 19 Jun 2022 21:02:40 -0300 Subject: [PATCH 012/106] chore(react-root): test passing --- .../__snapshots__/index.test.tsx.snap | 24 +-- .../__snapshots__/group.test.tsx.snap | 16 +- .../__snapshots__/icon.test.tsx.snap | 12 +- .../__snapshots__/group.test.tsx.snap | 128 ++++++++-------- .../__snapshots__/index.test.tsx.snap | 144 +++++++++--------- .../__snapshots__/index.test.tsx.snap | 16 +- .../__snapshots__/password.test.tsx.snap | 4 +- .../__snapshots__/index.test.tsx.snap | 4 +- .../__snapshots__/index.test.tsx.snap | 20 +-- .../__snapshots__/pagination.test.tsx.snap | 4 +- .../__snapshots__/index.test.tsx.snap | 20 +-- .../__snapshots__/index.test.tsx.snap | 28 +--- .../__snapshots__/index.test.tsx.snap | 8 +- .../__snapshots__/index.test.tsx.snap | 28 +--- .../__snapshots__/index.test.tsx.snap | 8 +- 15 files changed, 184 insertions(+), 280 deletions(-) diff --git a/packages/react/src/avatar/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/avatar/__tests__/__snapshots__/index.test.tsx.snap index d194501ed3..a7c7208078 100644 --- a/packages/react/src/avatar/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/avatar/__tests__/__snapshots__/index.test.tsx.snap @@ -136,9 +136,7 @@ LoadedCheerio { } `; -exports[ - `Avatar should render correctly with an icon 1` -] = `""`; +exports[`Avatar should render correctly with an icon 1`] = `""`; exports[`Avatar should render text element 1`] = ` LoadedCheerio { @@ -480,22 +478,12 @@ LoadedCheerio { } `; -exports[ - `Avatar should work correctly with different sizes 1` -] = `"

        "`; +exports[`Avatar should work correctly with different sizes 1`] = `"
        "`; -exports[ - `Avatar should work with a gradient color 1` -] = `""`; +exports[`Avatar should work with a gradient color 1`] = `""`; -exports[ - `Avatar should work with different colors 1` -] = `"
        "`; +exports[`Avatar should work with different colors 1`] = `"
        "`; -exports[ - `Avatar should work with pointer 1` -] = `""`; +exports[`Avatar should work with pointer 1`] = `""`; -exports[ - `Avatar should work with zoomed 1` -] = `""`; +exports[`Avatar should work with zoomed 1`] = `""`; diff --git a/packages/react/src/button/__tests__/__snapshots__/group.test.tsx.snap b/packages/react/src/button/__tests__/__snapshots__/group.test.tsx.snap index 8d0a39b7b1..1ca3d7b48b 100644 --- a/packages/react/src/button/__tests__/__snapshots__/group.test.tsx.snap +++ b/packages/react/src/button/__tests__/__snapshots__/group.test.tsx.snap @@ -1,20 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `ButtonGroup buttons should be displayed vertically 1` -] = `"
        "`; +exports[`ButtonGroup buttons should be displayed vertically 1`] = `"
        "`; -exports[ - `ButtonGroup props should be passed to each button 1` -] = `"
        "`; +exports[`ButtonGroup props should be passed to each button 1`] = `"
        "`; -exports[ - `ButtonGroup props should be passed to each button 2` -] = `"
        "`; +exports[`ButtonGroup props should be passed to each button 2`] = `"
        "`; -exports[ - `ButtonGroup should render correctly 1` -] = `"
        "`; +exports[`ButtonGroup should render correctly 1`] = `"
        "`; exports[`ButtonGroup should render different variants 1`] = `ReactWrapper {}`; diff --git a/packages/react/src/button/__tests__/__snapshots__/icon.test.tsx.snap b/packages/react/src/button/__tests__/__snapshots__/icon.test.tsx.snap index 894b9f6bd7..f921608f67 100644 --- a/packages/react/src/button/__tests__/__snapshots__/icon.test.tsx.snap +++ b/packages/react/src/button/__tests__/__snapshots__/icon.test.tsx.snap @@ -1,13 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `ButtonIcon should render correctly 1` -] = `""`; +exports[`ButtonIcon should render correctly 1`] = `""`; -exports[ - `ButtonIcon should work with right 1` -] = `""`; +exports[`ButtonIcon should work with right 1`] = `""`; -exports[ - `ButtonIcon should work without text 1` -] = `""`; +exports[`ButtonIcon should work without text 1`] = `""`; diff --git a/packages/react/src/collapse/__tests__/__snapshots__/group.test.tsx.snap b/packages/react/src/collapse/__tests__/__snapshots__/group.test.tsx.snap index ab34acbd24..ffb670b986 100644 --- a/packages/react/src/collapse/__tests__/__snapshots__/group.test.tsx.snap +++ b/packages/react/src/collapse/__tests__/__snapshots__/group.test.tsx.snap @@ -20,12 +20,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria3846599965-10", + "aria-controls": "react-aria7113542553-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-9", + "id": "react-aria7113542553-9", "role": "button", "tabindex": "0", }, @@ -324,9 +324,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-9", + "aria-labelledby": "react-aria7113542553-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-10", + "id": "react-aria7113542553-10", "role": "region", "tabindex": "-1", }, @@ -424,9 +424,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-9", + "aria-labelledby": "react-aria7113542553-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-10", + "id": "react-aria7113542553-10", "role": "region", "tabindex": "-1", }, @@ -481,12 +481,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria3846599965-10", + "aria-controls": "react-aria7113542553-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-9", + "id": "react-aria7113542553-9", "role": "button", "tabindex": "0", }, @@ -818,12 +818,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria3846599965-12", + "aria-controls": "react-aria7113542553-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-11", + "id": "react-aria7113542553-11", "role": "button", "tabindex": "0", }, @@ -1122,9 +1122,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-11", + "aria-labelledby": "react-aria7113542553-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-12", + "id": "react-aria7113542553-12", "role": "region", "tabindex": "-1", }, @@ -1222,9 +1222,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-11", + "aria-labelledby": "react-aria7113542553-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-12", + "id": "react-aria7113542553-12", "role": "region", "tabindex": "-1", }, @@ -1279,12 +1279,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria3846599965-12", + "aria-controls": "react-aria7113542553-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-11", + "id": "react-aria7113542553-11", "role": "button", "tabindex": "0", }, @@ -1645,12 +1645,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria3846599965-12", + "aria-controls": "react-aria7113542553-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-11", + "id": "react-aria7113542553-11", "role": "button", "tabindex": "0", }, @@ -1949,9 +1949,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-11", + "aria-labelledby": "react-aria7113542553-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-12", + "id": "react-aria7113542553-12", "role": "region", "tabindex": "-1", }, @@ -2049,9 +2049,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-11", + "aria-labelledby": "react-aria7113542553-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-12", + "id": "react-aria7113542553-12", "role": "region", "tabindex": "-1", }, @@ -2106,12 +2106,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria3846599965-12", + "aria-controls": "react-aria7113542553-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-11", + "id": "react-aria7113542553-11", "role": "button", "tabindex": "0", }, @@ -2445,12 +2445,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria3846599965-10", + "aria-controls": "react-aria7113542553-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-9", + "id": "react-aria7113542553-9", "role": "button", "tabindex": "0", }, @@ -2749,9 +2749,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-9", + "aria-labelledby": "react-aria7113542553-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-10", + "id": "react-aria7113542553-10", "role": "region", "tabindex": "-1", }, @@ -2849,9 +2849,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-9", + "aria-labelledby": "react-aria7113542553-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-10", + "id": "react-aria7113542553-10", "role": "region", "tabindex": "-1", }, @@ -2906,12 +2906,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria3846599965-10", + "aria-controls": "react-aria7113542553-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-9", + "id": "react-aria7113542553-9", "role": "button", "tabindex": "0", }, @@ -3385,12 +3385,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria3846599965-6", + "aria-controls": "react-aria7113542553-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-5", + "id": "react-aria7113542553-5", "role": "button", "tabindex": "0", }, @@ -3689,9 +3689,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-5", + "aria-labelledby": "react-aria7113542553-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-6", + "id": "react-aria7113542553-6", "role": "region", "tabindex": "-1", }, @@ -3789,9 +3789,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-5", + "aria-labelledby": "react-aria7113542553-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-6", + "id": "react-aria7113542553-6", "role": "region", "tabindex": "-1", }, @@ -3846,12 +3846,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria3846599965-6", + "aria-controls": "react-aria7113542553-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-5", + "id": "react-aria7113542553-5", "role": "button", "tabindex": "0", }, @@ -4183,12 +4183,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria3846599965-8", + "aria-controls": "react-aria7113542553-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-7", + "id": "react-aria7113542553-7", "role": "button", "tabindex": "0", }, @@ -4487,9 +4487,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-7", + "aria-labelledby": "react-aria7113542553-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-8", + "id": "react-aria7113542553-8", "role": "region", "tabindex": "-1", }, @@ -4587,9 +4587,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-7", + "aria-labelledby": "react-aria7113542553-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-8", + "id": "react-aria7113542553-8", "role": "region", "tabindex": "-1", }, @@ -4644,12 +4644,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria3846599965-8", + "aria-controls": "react-aria7113542553-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-7", + "id": "react-aria7113542553-7", "role": "button", "tabindex": "0", }, @@ -5010,12 +5010,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria3846599965-8", + "aria-controls": "react-aria7113542553-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-7", + "id": "react-aria7113542553-7", "role": "button", "tabindex": "0", }, @@ -5314,9 +5314,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-7", + "aria-labelledby": "react-aria7113542553-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-8", + "id": "react-aria7113542553-8", "role": "region", "tabindex": "-1", }, @@ -5414,9 +5414,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-7", + "aria-labelledby": "react-aria7113542553-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-8", + "id": "react-aria7113542553-8", "role": "region", "tabindex": "-1", }, @@ -5471,12 +5471,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria3846599965-8", + "aria-controls": "react-aria7113542553-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-7", + "id": "react-aria7113542553-7", "role": "button", "tabindex": "0", }, @@ -5810,12 +5810,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria3846599965-6", + "aria-controls": "react-aria7113542553-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-5", + "id": "react-aria7113542553-5", "role": "button", "tabindex": "0", }, @@ -6114,9 +6114,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-5", + "aria-labelledby": "react-aria7113542553-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-6", + "id": "react-aria7113542553-6", "role": "region", "tabindex": "-1", }, @@ -6214,9 +6214,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria3846599965-5", + "aria-labelledby": "react-aria7113542553-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria3846599965-6", + "id": "react-aria7113542553-6", "role": "region", "tabindex": "-1", }, @@ -6271,12 +6271,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria3846599965-6", + "aria-controls": "react-aria7113542553-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria3846599965-5", + "id": "react-aria7113542553-5", "role": "button", "tabindex": "0", }, diff --git a/packages/react/src/collapse/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/collapse/__tests__/__snapshots__/index.test.tsx.snap index e418a94d09..75ad5bc94f 100644 --- a/packages/react/src/collapse/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/collapse/__tests__/__snapshots__/index.test.tsx.snap @@ -20,12 +20,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria6517797861-10", + "aria-controls": "react-aria7352880336-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-9", + "id": "react-aria7352880336-9", "role": "button", "tabindex": "0", }, @@ -476,9 +476,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-9", + "aria-labelledby": "react-aria7352880336-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-10", + "id": "react-aria7352880336-10", "role": "region", "tabindex": "-1", }, @@ -576,9 +576,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-9", + "aria-labelledby": "react-aria7352880336-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-10", + "id": "react-aria7352880336-10", "role": "region", "tabindex": "-1", }, @@ -633,12 +633,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria6517797861-10", + "aria-controls": "react-aria7352880336-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-9", + "id": "react-aria7352880336-9", "role": "button", "tabindex": "0", }, @@ -1122,12 +1122,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria6517797861-12", + "aria-controls": "react-aria7352880336-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-11", + "id": "react-aria7352880336-11", "role": "button", "tabindex": "0", }, @@ -1630,9 +1630,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-11", + "aria-labelledby": "react-aria7352880336-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-12", + "id": "react-aria7352880336-12", "role": "region", "tabindex": "-1", }, @@ -1730,9 +1730,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-11", + "aria-labelledby": "react-aria7352880336-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-12", + "id": "react-aria7352880336-12", "role": "region", "tabindex": "-1", }, @@ -1787,12 +1787,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria6517797861-12", + "aria-controls": "react-aria7352880336-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-11", + "id": "react-aria7352880336-11", "role": "button", "tabindex": "0", }, @@ -2357,12 +2357,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria6517797861-12", + "aria-controls": "react-aria7352880336-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-11", + "id": "react-aria7352880336-11", "role": "button", "tabindex": "0", }, @@ -2865,9 +2865,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-11", + "aria-labelledby": "react-aria7352880336-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-12", + "id": "react-aria7352880336-12", "role": "region", "tabindex": "-1", }, @@ -2965,9 +2965,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-11", + "aria-labelledby": "react-aria7352880336-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-12", + "id": "react-aria7352880336-12", "role": "region", "tabindex": "-1", }, @@ -3022,12 +3022,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria6517797861-12", + "aria-controls": "react-aria7352880336-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-11", + "id": "react-aria7352880336-11", "role": "button", "tabindex": "0", }, @@ -3565,12 +3565,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria6517797861-10", + "aria-controls": "react-aria7352880336-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-9", + "id": "react-aria7352880336-9", "role": "button", "tabindex": "0", }, @@ -4021,9 +4021,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-9", + "aria-labelledby": "react-aria7352880336-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-10", + "id": "react-aria7352880336-10", "role": "region", "tabindex": "-1", }, @@ -4121,9 +4121,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-9", + "aria-labelledby": "react-aria7352880336-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-10", + "id": "react-aria7352880336-10", "role": "region", "tabindex": "-1", }, @@ -4178,12 +4178,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria6517797861-10", + "aria-controls": "react-aria7352880336-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-9", + "id": "react-aria7352880336-9", "role": "button", "tabindex": "0", }, @@ -4803,12 +4803,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria6517797861-4", + "aria-controls": "react-aria7352880336-4", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-3", + "id": "react-aria7352880336-3", "role": "button", "tabindex": "0", }, @@ -5259,9 +5259,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-3", + "aria-labelledby": "react-aria7352880336-3", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-4", + "id": "react-aria7352880336-4", "role": "region", "tabindex": "-1", }, @@ -5359,9 +5359,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-3", + "aria-labelledby": "react-aria7352880336-3", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-4", + "id": "react-aria7352880336-4", "role": "region", "tabindex": "-1", }, @@ -5416,12 +5416,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria6517797861-4", + "aria-controls": "react-aria7352880336-4", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-3", + "id": "react-aria7352880336-3", "role": "button", "tabindex": "0", }, @@ -5905,12 +5905,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria6517797861-6", + "aria-controls": "react-aria7352880336-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-5", + "id": "react-aria7352880336-5", "role": "button", "tabindex": "0", }, @@ -6337,9 +6337,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-5", + "aria-labelledby": "react-aria7352880336-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-6", + "id": "react-aria7352880336-6", "role": "region", "tabindex": "-1", }, @@ -6437,9 +6437,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-5", + "aria-labelledby": "react-aria7352880336-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-6", + "id": "react-aria7352880336-6", "role": "region", "tabindex": "-1", }, @@ -6494,12 +6494,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria6517797861-6", + "aria-controls": "react-aria7352880336-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-5", + "id": "react-aria7352880336-5", "role": "button", "tabindex": "0", }, @@ -6988,12 +6988,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria6517797861-6", + "aria-controls": "react-aria7352880336-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-5", + "id": "react-aria7352880336-5", "role": "button", "tabindex": "0", }, @@ -7420,9 +7420,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-5", + "aria-labelledby": "react-aria7352880336-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-6", + "id": "react-aria7352880336-6", "role": "region", "tabindex": "-1", }, @@ -7520,9 +7520,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-5", + "aria-labelledby": "react-aria7352880336-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-6", + "id": "react-aria7352880336-6", "role": "region", "tabindex": "-1", }, @@ -7577,12 +7577,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria6517797861-6", + "aria-controls": "react-aria7352880336-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-5", + "id": "react-aria7352880336-5", "role": "button", "tabindex": "0", }, @@ -8044,12 +8044,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria6517797861-4", + "aria-controls": "react-aria7352880336-4", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-3", + "id": "react-aria7352880336-3", "role": "button", "tabindex": "0", }, @@ -8500,9 +8500,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-3", + "aria-labelledby": "react-aria7352880336-3", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-4", + "id": "react-aria7352880336-4", "role": "region", "tabindex": "-1", }, @@ -8600,9 +8600,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-3", + "aria-labelledby": "react-aria7352880336-3", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-4", + "id": "react-aria7352880336-4", "role": "region", "tabindex": "-1", }, @@ -8657,12 +8657,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria6517797861-4", + "aria-controls": "react-aria7352880336-4", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-3", + "id": "react-aria7352880336-3", "role": "button", "tabindex": "0", }, @@ -13249,12 +13249,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria6517797861-8", + "aria-controls": "react-aria7352880336-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-7", + "id": "react-aria7352880336-7", "role": "button", "tabindex": "0", }, @@ -13553,9 +13553,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-7", + "aria-labelledby": "react-aria7352880336-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-8", + "id": "react-aria7352880336-8", "role": "region", "tabindex": "-1", }, @@ -13653,9 +13653,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria6517797861-7", + "aria-labelledby": "react-aria7352880336-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria6517797861-8", + "id": "react-aria7352880336-8", "role": "region", "tabindex": "-1", }, @@ -13710,12 +13710,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria6517797861-8", + "aria-controls": "react-aria7352880336-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria6517797861-7", + "id": "react-aria7352880336-7", "role": "button", "tabindex": "0", }, diff --git a/packages/react/src/input/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/input/__tests__/__snapshots__/index.test.tsx.snap index 7f806c2124..e012f38790 100644 --- a/packages/react/src/input/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/input/__tests__/__snapshots__/index.test.tsx.snap @@ -1,17 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `Input should be work with content 1` -] = `"
        "`; +exports[`Input should be work with content 1`] = `"
        "`; -exports[ - `Input should be work with label 1` -] = `"
        "`; +exports[`Input should be work with label 1`] = `"
        "`; -exports[ - `Input should work with different sizes 1` -] = `"
        "`; +exports[`Input should work with different sizes 1`] = `"
        "`; -exports[ - `Input should work with different status 1` -] = `"
        "`; +exports[`Input should work with different status 1`] = `"
        "`; diff --git a/packages/react/src/input/__tests__/__snapshots__/password.test.tsx.snap b/packages/react/src/input/__tests__/__snapshots__/password.test.tsx.snap index f2a3c68345..83d610e7c3 100644 --- a/packages/react/src/input/__tests__/__snapshots__/password.test.tsx.snap +++ b/packages/react/src/input/__tests__/__snapshots__/password.test.tsx.snap @@ -1,5 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `InputPassword should render correctly 1` -] = `"
        "`; +exports[`InputPassword should render correctly 1`] = `"
        "`; diff --git a/packages/react/src/link/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/link/__tests__/__snapshots__/index.test.tsx.snap index 2702be444e..88e6c44143 100644 --- a/packages/react/src/link/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/link/__tests__/__snapshots__/index.test.tsx.snap @@ -1,5 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `Link should render correctly 1` -] = `"
        "`; +exports[`Link should render correctly 1`] = `""`; diff --git a/packages/react/src/loading/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/loading/__tests__/__snapshots__/index.test.tsx.snap index 1f88601a1d..bcff71ee3a 100644 --- a/packages/react/src/loading/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/loading/__tests__/__snapshots__/index.test.tsx.snap @@ -1,31 +1,21 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `Loading should render correctly 1` -] = `"
        "`; +exports[`Loading should render correctly 1`] = `"
        "`; exports[`Loading should render correctly 2`] = `[Function]`; -exports[ - `Loading should work with different colors 1` -] = `"
        "`; +exports[`Loading should work with different colors 1`] = `"
        "`; exports[`Loading should work with different colors 2`] = `[Function]`; -exports[ - `Loading should work with different sizes 1` -] = `"
        "`; +exports[`Loading should work with different sizes 1`] = `"
        "`; exports[`Loading should work with different sizes 2`] = `[Function]`; -exports[ - `Loading should work with different text colors 1` -] = `"
        "`; +exports[`Loading should work with different text colors 1`] = `"
        "`; exports[`Loading should work with different text colors 2`] = `[Function]`; -exports[ - `Loading should work with different types 1` -] = `"
        "`; +exports[`Loading should work with different types 1`] = `"
        "`; exports[`Loading should work with different types 2`] = `[Function]`; diff --git a/packages/react/src/pagination/__tests__/__snapshots__/pagination.test.tsx.snap b/packages/react/src/pagination/__tests__/__snapshots__/pagination.test.tsx.snap index 0b229afef4..b5bab73590 100644 --- a/packages/react/src/pagination/__tests__/__snapshots__/pagination.test.tsx.snap +++ b/packages/react/src/pagination/__tests__/__snapshots__/pagination.test.tsx.snap @@ -1,5 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `Pagination should render correctly 1` -] = `""`; +exports[`Pagination should render correctly 1`] = `""`; diff --git a/packages/react/src/snippet/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/snippet/__tests__/__snapshots__/index.test.tsx.snap index e168a9b6ac..7c8692a90e 100644 --- a/packages/react/src/snippet/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/snippet/__tests__/__snapshots__/index.test.tsx.snap @@ -1,21 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `Snippet should render correctly 1` -] = `"
        yarn add @nextui-org/react
        "`; +exports[`Snippet should render correctly 1`] = `"
        yarn add @nextui-org/react
        "`; -exports[ - `Snippet should work with custom symbol 1` -] = `"
        yarn add @nextui-org/react
        "`; +exports[`Snippet should work with custom symbol 1`] = `"
        yarn add @nextui-org/react
        "`; -exports[ - `Snippet should work with custom symbol 2` -] = `"
        yarn add @nextui-org/react
        "`; +exports[`Snippet should work with custom symbol 2`] = `"
        yarn add @nextui-org/react
        "`; -exports[ - `Snippet should work with different styles 1` -] = `"
        yarn add @nextui-org/react
        yarn add @nextui-org/react
        yarn add @nextui-org/react
        yarn add @nextui-org/react
        "`; +exports[`Snippet should work with different styles 1`] = `"
        yarn add @nextui-org/react
        yarn add @nextui-org/react
        yarn add @nextui-org/react
        yarn add @nextui-org/react
        "`; -exports[ - `Snippet should work with multi-line 1` -] = `"
        cd project
        now
        "`; +exports[`Snippet should work with multi-line 1`] = `"
        cd project
        now
        "`; diff --git a/packages/react/src/switch/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/switch/__tests__/__snapshots__/index.test.tsx.snap index 954364219c..3dde1c3adf 100644 --- a/packages/react/src/switch/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/switch/__tests__/__snapshots__/index.test.tsx.snap @@ -1,29 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `Switch should render correctly 1` -] = `""`; +exports[`Switch should render correctly 1`] = `""`; -exports[ - `Switch should render correctly with an icon 1` -] = `""`; +exports[`Switch should render correctly with an icon 1`] = `""`; -exports[ - `Switch should render correctly with an iconOff 1` -] = `""`; +exports[`Switch should render correctly with an iconOff 1`] = `""`; -exports[ - `Switch should render correctly with an iconOn 1` -] = `""`; +exports[`Switch should render correctly with an iconOn 1`] = `""`; -exports[ - `Switch should render correctly with both icons on/off 1` -] = `""`; +exports[`Switch should render correctly with both icons on/off 1`] = `""`; -exports[ - `Switch should work with different colors 1` -] = `"
        "`; +exports[`Switch should work with different colors 1`] = `"
        "`; -exports[ - `Switch should work with different sizes 1` -] = `"
        "`; +exports[`Switch should work with different sizes 1`] = `"
        "`; diff --git a/packages/react/src/table/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/table/__tests__/__snapshots__/index.test.tsx.snap index d18344aa60..8c7159960f 100644 --- a/packages/react/src/table/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/table/__tests__/__snapshots__/index.test.tsx.snap @@ -1,9 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `Table should render a static table correctly with sorting 1` -] = `"
        NAMETYPEDATE MODIFIED
        GamesFile folder6/7/2020
        "`; +exports[`Table should render a static table correctly with sorting 1`] = `"
        NAMETYPEDATE MODIFIED
        GamesFile folder6/7/2020
        "`; -exports[ - `Table should render correctly 1` -] = `"
        NAMETYPEDATE MODIFIED
        GamesFile folder6/7/2020
        "`; +exports[`Table should render correctly 1`] = `"
        NAMETYPEDATE MODIFIED
        GamesFile folder6/7/2020
        "`; diff --git a/packages/react/src/text/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/text/__tests__/__snapshots__/index.test.tsx.snap index 93106276e9..755da8ea65 100644 --- a/packages/react/src/text/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/text/__tests__/__snapshots__/index.test.tsx.snap @@ -1,29 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `Text should be able to specify the size of text 1` -] = `"

        test-value

        "`; +exports[`Text should be able to specify the size of text 1`] = `"

        test-value

        "`; -exports[ - `Text should be able to specify the size of text 2` -] = `"

        test-value

        "`; +exports[`Text should be able to specify the size of text 2`] = `"

        test-value

        "`; -exports[ - `Text should render P element in the default 1` -] = `"

        test-value

        "`; +exports[`Text should render P element in the default 1`] = `"

        test-value

        "`; -exports[ - `Text should render default color when type missing 1` -] = `"

        test-value

        "`; +exports[`Text should render default color when type missing 1`] = `"

        test-value

        "`; -exports[ - `Text should work with different styles 1` -] = `"

        test-value

        test-value

        test-value

        test-value

        "`; +exports[`Text should work with different styles 1`] = `"

        test-value

        test-value

        test-value

        test-value

        "`; -exports[ - `Text the combined style should be rendered 1` -] = `"test-value"`; +exports[`Text the combined style should be rendered 1`] = `"test-value"`; -exports[ - `Text the specified element should be rendered 1` -] = `"

        test-value

        test-value

        test-value

        test-value

        test-value
        test-value

        test-value

        test-valuetest-valuetest-valuetest-valuetest-valuetest-value
        "`; +exports[`Text the specified element should be rendered 1`] = `"

        test-value

        test-value

        test-value

        test-value

        test-value
        test-value

        test-value

        test-valuetest-valuetest-valuetest-valuetest-valuetest-value
        "`; diff --git a/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap index 2aaac37223..99d63a9912 100644 --- a/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap @@ -1,9 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[ - `Textarea should render correctly 1` -] = `"
        "`; +exports[`Textarea should render correctly 1`] = `"
        "`; -exports[ - `Textarea should work with different styles 1` -] = `"
        "`; +exports[`Textarea should work with different styles 1`] = `"
        "`; From b8f4c656fa4e6fed697c526ac6ff2c02d23e2e3a Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sat, 2 Jul 2022 18:33:53 -0300 Subject: [PATCH 013/106] fix(react-card): box shadow applied intead of box shadow filter on safari --- packages/react/src/card/card.stories.tsx | 8 ++++++++ packages/react/src/card/card.styles.ts | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/react/src/card/card.stories.tsx b/packages/react/src/card/card.stories.tsx index 72ab260297..cf937d15c2 100644 --- a/packages/react/src/card/card.stories.tsx +++ b/packages/react/src/card/card.stories.tsx @@ -24,6 +24,14 @@ export const Default = () => ( ); +export const Hoverable = () => ( + + + A basic card + + +); + export const Variants = () => ( diff --git a/packages/react/src/card/card.styles.ts b/packages/react/src/card/card.styles.ts index e79c07a1aa..bc7156c7c9 100644 --- a/packages/react/src/card/card.styles.ts +++ b/packages/react/src/card/card.styles.ts @@ -55,6 +55,10 @@ export const StyledCard = styled( }, shadow: { dropShadow: "$lg", + "@safari": { + boxShadow: "$lg", + dropShadow: "none", + }, }, bordered: { borderStyle: "solid", @@ -99,6 +103,10 @@ export const StyledCard = styled( isHovered: { true: { dropShadow: "$lg", + "@safari": { + boxShadow: "$lg", + dropShadow: "none", + }, }, }, }, @@ -125,6 +133,10 @@ export const StyledCard = styled( variant: "shadow", css: { dropShadow: "$xl", + "@safari": { + boxShadow: "$xl", + dropShadow: "none", + }, }, }, ], From bf8af946c61ef2e4e5ae40ca1909d7635eaed2aa Mon Sep 17 00:00:00 2001 From: Artem Shteltser Date: Sun, 3 Jul 2022 01:16:24 +0300 Subject: [PATCH 014/106] fix zIndex for dropdown item --- packages/react/src/dropdown/dropdown.styles.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react/src/dropdown/dropdown.styles.ts b/packages/react/src/dropdown/dropdown.styles.ts index 8015d45f05..685bf03f83 100644 --- a/packages/react/src/dropdown/dropdown.styles.ts +++ b/packages/react/src/dropdown/dropdown.styles.ts @@ -209,6 +209,7 @@ export const StyledDropdownItem = styled( true: { bg: '$$dropdownItemHoverBackground', color: '$$dropdownItemHoverTextColor', + zIndex: 1, [`& ${StyledDropdownItemKbd}`]: { color: '$$dropdownItemHoverTextColor', borderColor: '$$dropdownItemHoverBorderColor' From 6a77bad19fa586ca837532921da3f95fdec45236 Mon Sep 17 00:00:00 2001 From: danielsimao Date: Fri, 24 Jun 2022 10:30:39 +0100 Subject: [PATCH 015/106] feat(react-container): add forwardRef --- packages/react/src/container/container.tsx | 136 ++++++++++++--------- 1 file changed, 77 insertions(+), 59 deletions(-) diff --git a/packages/react/src/container/container.tsx b/packages/react/src/container/container.tsx index 7d9af72569..3c4b6bddcb 100644 --- a/packages/react/src/container/container.tsx +++ b/packages/react/src/container/container.tsx @@ -1,7 +1,14 @@ -import React, {useMemo} from "react"; +import React, { useMemo } from "react"; -import {CSS} from "../theme/stitches.config"; -import {Wrap, Display, Justify, Direction, AlignItems, AlignContent} from "../utils/prop-types"; +import { CSS } from "../theme/stitches.config"; +import { + Wrap, + Display, + Justify, + Direction, + AlignItems, + AlignContent, +} from "../utils/prop-types"; import StyledContainer from "./container.styles"; @@ -42,62 +49,73 @@ type NativeAttrs = Omit, keyof Props>; export type ContainerProps = Props & typeof defaultProps & NativeAttrs; -const Container: React.FC> = ({ - xs, - sm, - md, - lg, - xl, - wrap, - gap, - as, - display, - justify, - direction, - alignItems, - alignContent, - children, - responsive, - fluid, - css, - ...props -}) => { - const gapUnit = useMemo(() => { - return `calc(${gap} * $space$sm)`; - }, [gap]); - - const getMaxWidth = () => { - if (xs) return "$breakpoints$xs"; - if (sm) return "$breakpoints$sm"; - if (md) return "$breakpoints$md"; - if (lg) return "$breakpoints$lg"; - if (xl) return "$breakpoints$xl"; - - return ""; - }; - - return ( - - {children} - - ); -}; +const Container = React.forwardRef< + HTMLElement, + React.PropsWithChildren +>( + ( + { + xs, + sm, + md, + lg, + xl, + wrap, + gap, + as, + display, + justify, + direction, + alignItems, + alignContent, + children, + responsive, + fluid, + css, + ...props + }, + ref + ) => { + const gapUnit = useMemo(() => { + return `calc(${gap} * $space$sm)`; + }, [gap]); + + const getMaxWidth = () => { + if (xs) return "$breakpoints$xs"; + if (sm) return "$breakpoints$sm"; + if (md) return "$breakpoints$md"; + if (lg) return "$breakpoints$lg"; + if (xl) return "$breakpoints$xl"; + + return ""; + }; + + return ( + + {children} + + ); + } +); + +Container.displayName = "NextUI.Container"; Container.toString = () => ".nextui-container"; From 7ab40ed210c0f6467ef6e2e14f883f310f781f8d Mon Sep 17 00:00:00 2001 From: danielsimao Date: Tue, 28 Jun 2022 21:11:35 +0100 Subject: [PATCH 016/106] fix(react-container): code review --- packages/react/src/container/container.tsx | 124 ++++++++++----------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/packages/react/src/container/container.tsx b/packages/react/src/container/container.tsx index 3c4b6bddcb..7c110fd6c5 100644 --- a/packages/react/src/container/container.tsx +++ b/packages/react/src/container/container.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from "react"; import { CSS } from "../theme/stitches.config"; +import { useDOMRef } from "../utils/dom"; import { Wrap, Display, @@ -52,68 +53,67 @@ export type ContainerProps = Props & typeof defaultProps & NativeAttrs; const Container = React.forwardRef< HTMLElement, React.PropsWithChildren ->( - ( - { - xs, - sm, - md, - lg, - xl, - wrap, - gap, - as, - display, - justify, - direction, - alignItems, - alignContent, - children, - responsive, - fluid, - css, - ...props - }, - ref - ) => { - const gapUnit = useMemo(() => { - return `calc(${gap} * $space$sm)`; - }, [gap]); - - const getMaxWidth = () => { - if (xs) return "$breakpoints$xs"; - if (sm) return "$breakpoints$sm"; - if (md) return "$breakpoints$md"; - if (lg) return "$breakpoints$lg"; - if (xl) return "$breakpoints$xl"; - - return ""; - }; - - return ( - - {children} - - ); - } -); +>((containerProps, ref) => { + const { + xs, + sm, + md, + lg, + xl, + wrap, + gap, + as, + display, + justify, + direction, + alignItems, + alignContent, + children, + responsive, + fluid, + css, + ...otherProps + } = containerProps; + + const domRef = useDOMRef(ref); + + const gapUnit = useMemo(() => { + return `calc(${gap} * $space$sm)`; + }, [gap]); + + const getMaxWidth = () => { + if (xs) return "$breakpoints$xs"; + if (sm) return "$breakpoints$sm"; + if (md) return "$breakpoints$md"; + if (lg) return "$breakpoints$lg"; + if (xl) return "$breakpoints$xl"; + + return ""; + }; + + return ( + + {children} + + ); +}); Container.displayName = "NextUI.Container"; From 4a607057c16314d105aa532ad5bef758e834e06a Mon Sep 17 00:00:00 2001 From: danielsimao Date: Wed, 22 Jun 2022 15:31:25 +0100 Subject: [PATCH 017/106] fix(react-table): react-stately props --- packages/react/src/table/table.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react/src/table/table.tsx b/packages/react/src/table/table.tsx index 10832c294e..ed1a6b0fa2 100644 --- a/packages/react/src/table/table.tsx +++ b/packages/react/src/table/table.tsx @@ -68,6 +68,8 @@ const Table = React.forwardRef( borderWeight, bordered, containerCss, + onSelectionChange, + onSortChange, ...props } = tableProps; @@ -79,6 +81,8 @@ const Table = React.forwardRef( const state = useTableState({ ...tableProps, + onSelectionChange, + onSortChange, children: withoutPaginationChildren, showSelectionCheckboxes: tableProps.showSelectionCheckboxes !== undefined From 77626ef4ad682d8ac2f2e237f1a9f587c8afd485 Mon Sep 17 00:00:00 2001 From: danielsimao Date: Thu, 23 Jun 2022 11:35:40 +0100 Subject: [PATCH 018/106] fix(react-table): code review --- packages/react/src/table/table.tsx | 94 +++++++++++++++----------- packages/react/src/utils/prop-types.ts | 71 +++++++++++-------- 2 files changed, 99 insertions(+), 66 deletions(-) diff --git a/packages/react/src/table/table.tsx b/packages/react/src/table/table.tsx index ed1a6b0fa2..dda1e5bdce 100644 --- a/packages/react/src/table/table.tsx +++ b/packages/react/src/table/table.tsx @@ -1,12 +1,20 @@ -import React, {useImperativeHandle, useRef, RefAttributes, PropsWithoutRef} from "react"; -import {useTable} from "@react-aria/table"; -import {useTableState, TableStateProps} from "@react-stately/table"; -import {SelectionMode, SelectionBehavior, CollectionChildren} from "@react-types/shared"; - -import {Spacer} from "../index"; -import {CSS} from "../theme/stitches.config"; -import {pickSingleChild} from "../utils/collections"; -import {excludedTableProps} from "../utils/prop-types"; +import React, { + useImperativeHandle, + useRef, + RefAttributes, + PropsWithoutRef, +} from "react"; +import { useTable } from "@react-aria/table"; +import { useTableState, TableStateProps } from "@react-stately/table"; +import { + SelectionMode, + SelectionBehavior, + CollectionChildren, +} from "@react-types/shared"; + +import { Spacer } from "../index"; +import { CSS } from "../theme/stitches.config"; +import { pickSingleChild } from "../utils/collections"; import withDefaults from "../utils/with-defaults"; import clsx from "../utils/clsx"; @@ -30,8 +38,8 @@ import { TableVariantsProps, TableContainerVariantsProps, } from "./table.styles"; -import TableContext, {TableConfig} from "./table-context"; -import {isInfinityScroll, hasPaginationChild} from "./utils"; +import TableContext, { TableConfig } from "./table-context"; +import { isInfinityScroll, hasPaginationChild } from "./utils"; interface Props extends TableStateProps { selectionMode?: SelectionMode; @@ -41,12 +49,15 @@ interface Props extends TableStateProps { as?: keyof JSX.IntrinsicElements; } -type NativeAttrs = Omit, keyof Props>; +type NativeAttrs = Omit< + React.TableHTMLAttributes, + keyof Props +>; export type TableProps = Props & NativeAttrs & Omit & - TableContainerVariantsProps & {css?: CSS; containerCss?: CSS}; + TableContainerVariantsProps & { css?: CSS; containerCss?: CSS }; const defaultProps = { animated: true, @@ -58,6 +69,7 @@ const defaultProps = { const Table = React.forwardRef( (tableProps, ref: React.Ref) => { const { + css, selectionMode, selectionBehavior, hideLoading, @@ -67,22 +79,23 @@ const Table = React.forwardRef( animated, borderWeight, bordered, + hoverable, + sticked, containerCss, - onSelectionChange, - onSortChange, - ...props + className, } = tableProps; const [withoutPaginationChildren, paginationChildren] = pickSingleChild< CollectionChildren >(children, TablePagination); - const {hasPagination, rowsPerPage} = hasPaginationChild(children, TablePagination); + const { hasPagination, rowsPerPage } = hasPaginationChild( + children, + TablePagination + ); const state = useTableState({ ...tableProps, - onSelectionChange, - onSortChange, children: withoutPaginationChildren, showSelectionCheckboxes: tableProps.showSelectionCheckboxes !== undefined @@ -90,19 +103,11 @@ const Table = React.forwardRef( : selectionMode === "multiple" && selectionBehavior !== "replace", }); - // clean table props - Object.keys(props).forEach((propNameKey: any) => { - if (excludedTableProps.indexOf(propNameKey) > -1) { - // @ts-ignored - delete props[propNameKey]; - } - }); - const tableRef = useRef(null); useImperativeHandle(ref, () => tableRef?.current); - const {collection} = state; + const { collection } = state; const { gridProps, }: { @@ -124,24 +129,28 @@ const Table = React.forwardRef( borderWeight={borderWeight} bordered={bordered} className="nextui-table-container" - css={{...(containerCss as any)}} + css={{ ...(containerCss as any) }} shadow={shadow} > {collection.headerRows.map((headerRow) => ( - + {[...headerRow.childNodes].map((column) => column?.props?.isSelectionCell ? ( ( column={column} state={state} /> - ), + ) )} ))} - {!props.sticked && } + {!sticked && ( + + )} ( - + {paginationChildren} @@ -187,7 +202,7 @@ const Table = React.forwardRef( ); - }, + } ); type TableComponent = React.ForwardRefExoticComponent< @@ -204,4 +219,7 @@ type TableComponent = React.ForwardRefExoticComponent< Table.displayName = "NextUI.Table"; Table.toString = () => ".nextui-table"; -export default withDefaults(Table, defaultProps) as TableComponent; +export default withDefaults(Table, defaultProps) as TableComponent< + HTMLTableElement, + TableProps +>; diff --git a/packages/react/src/utils/prop-types.ts b/packages/react/src/utils/prop-types.ts index e02d668d44..9e428e8b7d 100644 --- a/packages/react/src/utils/prop-types.ts +++ b/packages/react/src/utils/prop-types.ts @@ -1,4 +1,4 @@ -import {ElementType} from "react"; +import { ElementType } from "react"; export const tuple = (...args: T) => args; @@ -11,10 +11,17 @@ export const normalColors = tuple( "success", "warning", "error", - "gradient", + "gradient" ); -export const simpleColors = tuple("default", "primary", "secondary", "success", "warning", "error"); +export const simpleColors = tuple( + "default", + "primary", + "secondary", + "success", + "warning", + "error" +); export const extendedColors = tuple( "default", @@ -24,7 +31,7 @@ export const extendedColors = tuple( "warning", "error", "invert", - "gradient", + "gradient" ); export const extendedColorsNoGradient = tuple( @@ -34,7 +41,7 @@ export const extendedColorsNoGradient = tuple( "success", "warning", "error", - "invert", + "invert" ); export const extraColors = tuple( @@ -50,12 +57,24 @@ export const extraColors = tuple( "purple", "violet", "gradient", - "cyan", + "cyan" ); -export const normalLoaders = tuple("default", "points", "points-opacity", "gradient", "spinner"); +export const normalLoaders = tuple( + "default", + "points", + "points-opacity", + "gradient", + "spinner" +); -export const normalWeights = tuple("light", "normal", "bold", "extrabold", "black"); +export const normalWeights = tuple( + "light", + "normal", + "bold", + "extrabold", + "black" +); export const textWeights = tuple( /* Keyword values */ @@ -68,7 +87,7 @@ export const textWeights = tuple( "inherit", "initial", "revert", - "unset", + "unset" ); export const textTransforms = tuple( @@ -83,7 +102,7 @@ export const textTransforms = tuple( "inherit", "initial", "revert", - "unset", + "unset" ); const copyTypes = tuple("default", "slient", "prevent"); @@ -102,7 +121,7 @@ const placement = tuple( "bottomEnd", "right", "rightStart", - "rightEnd", + "rightEnd" ); const position = tuple( @@ -115,7 +134,7 @@ const position = tuple( "inherit", "initial", "revert", - "unset", + "unset" ); const objectFit = tuple( @@ -128,7 +147,7 @@ const objectFit = tuple( "inherit", "initial", "revert", - "unset", + "unset" ); const dividerAlign = tuple("start", "center", "end", "left", "right"); @@ -139,10 +158,16 @@ const justify = tuple( "flex-end", "space-between", "space-around", - "space-evenly", + "space-evenly" ); -const alignItems = tuple("flex-start", "flex-end", "center", "stretch", "baseline"); +const alignItems = tuple( + "flex-start", + "flex-end", + "center", + "stretch", + "baseline" +); const alignContent = tuple( "stretch", @@ -150,7 +175,7 @@ const alignContent = tuple( "flex-start", "flex-end", "space-between", - "space-around", + "space-around" ); const direction = tuple("row", "row-reverse", "column", "column-reverse"); @@ -164,7 +189,7 @@ const display = tuple( "inline", "inline-block", "inline-flex", - "inline-grid", + "inline-grid" ); const contentPosition = tuple("left", "right"); @@ -184,17 +209,7 @@ export const excludedInputPropsForTextarea = tuple( "contentRightStyling", "onContentClick", "onClearClick", - "css", -); - -export const excludedTableProps = tuple( - "items", - "disabledKeys", - "allowDuplicateSelectionEvents", - "disallowEmptySelection", - "defaultSelectedKeys", - "sortDescriptor", - "onSortChange", + "css" ); const selectionBehavior = tuple("toggle", "replace"); From c0fa4f5e7b60b604ff7aac3db1652b2814c20613 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sun, 3 Jul 2022 09:52:12 -0300 Subject: [PATCH 019/106] fix(react): apply new format to table file --- packages/react/src/table/table.tsx | 70 ++++++++------------------ packages/react/src/utils/prop-types.ts | 61 +++++++--------------- 2 files changed, 39 insertions(+), 92 deletions(-) diff --git a/packages/react/src/table/table.tsx b/packages/react/src/table/table.tsx index dda1e5bdce..8642b2d5f8 100644 --- a/packages/react/src/table/table.tsx +++ b/packages/react/src/table/table.tsx @@ -1,20 +1,11 @@ -import React, { - useImperativeHandle, - useRef, - RefAttributes, - PropsWithoutRef, -} from "react"; -import { useTable } from "@react-aria/table"; -import { useTableState, TableStateProps } from "@react-stately/table"; -import { - SelectionMode, - SelectionBehavior, - CollectionChildren, -} from "@react-types/shared"; - -import { Spacer } from "../index"; -import { CSS } from "../theme/stitches.config"; -import { pickSingleChild } from "../utils/collections"; +import React, {useImperativeHandle, useRef, RefAttributes, PropsWithoutRef} from "react"; +import {useTable} from "@react-aria/table"; +import {useTableState, TableStateProps} from "@react-stately/table"; +import {SelectionMode, SelectionBehavior, CollectionChildren} from "@react-types/shared"; + +import {Spacer} from "../index"; +import {CSS} from "../theme/stitches.config"; +import {pickSingleChild} from "../utils/collections"; import withDefaults from "../utils/with-defaults"; import clsx from "../utils/clsx"; @@ -38,8 +29,8 @@ import { TableVariantsProps, TableContainerVariantsProps, } from "./table.styles"; -import TableContext, { TableConfig } from "./table-context"; -import { isInfinityScroll, hasPaginationChild } from "./utils"; +import TableContext, {TableConfig} from "./table-context"; +import {isInfinityScroll, hasPaginationChild} from "./utils"; interface Props extends TableStateProps { selectionMode?: SelectionMode; @@ -49,15 +40,12 @@ interface Props extends TableStateProps { as?: keyof JSX.IntrinsicElements; } -type NativeAttrs = Omit< - React.TableHTMLAttributes, - keyof Props ->; +type NativeAttrs = Omit, keyof Props>; export type TableProps = Props & NativeAttrs & Omit & - TableContainerVariantsProps & { css?: CSS; containerCss?: CSS }; + TableContainerVariantsProps & {css?: CSS; containerCss?: CSS}; const defaultProps = { animated: true, @@ -89,10 +77,7 @@ const Table = React.forwardRef( CollectionChildren >(children, TablePagination); - const { hasPagination, rowsPerPage } = hasPaginationChild( - children, - TablePagination - ); + const {hasPagination, rowsPerPage} = hasPaginationChild(children, TablePagination); const state = useTableState({ ...tableProps, @@ -107,7 +92,7 @@ const Table = React.forwardRef( useImperativeHandle(ref, () => tableRef?.current); - const { collection } = state; + const {collection} = state; const { gridProps, }: { @@ -129,7 +114,7 @@ const Table = React.forwardRef( borderWeight={borderWeight} bordered={bordered} className="nextui-table-container" - css={{ ...(containerCss as any) }} + css={{...(containerCss as any)}} shadow={shadow} > ( > {collection.headerRows.map((headerRow) => ( - + {[...headerRow.childNodes].map((column) => column?.props?.isSelectionCell ? ( ( column={column} state={state} /> - ) + ), )} ))} - {!sticked && ( - - )} + {!sticked && } ( - + {paginationChildren} @@ -202,7 +177,7 @@ const Table = React.forwardRef( ); - } + }, ); type TableComponent = React.ForwardRefExoticComponent< @@ -219,7 +194,4 @@ type TableComponent = React.ForwardRefExoticComponent< Table.displayName = "NextUI.Table"; Table.toString = () => ".nextui-table"; -export default withDefaults(Table, defaultProps) as TableComponent< - HTMLTableElement, - TableProps ->; +export default withDefaults(Table, defaultProps) as TableComponent; diff --git a/packages/react/src/utils/prop-types.ts b/packages/react/src/utils/prop-types.ts index 9e428e8b7d..faeb558e03 100644 --- a/packages/react/src/utils/prop-types.ts +++ b/packages/react/src/utils/prop-types.ts @@ -1,4 +1,4 @@ -import { ElementType } from "react"; +import {ElementType} from "react"; export const tuple = (...args: T) => args; @@ -11,17 +11,10 @@ export const normalColors = tuple( "success", "warning", "error", - "gradient" + "gradient", ); -export const simpleColors = tuple( - "default", - "primary", - "secondary", - "success", - "warning", - "error" -); +export const simpleColors = tuple("default", "primary", "secondary", "success", "warning", "error"); export const extendedColors = tuple( "default", @@ -31,7 +24,7 @@ export const extendedColors = tuple( "warning", "error", "invert", - "gradient" + "gradient", ); export const extendedColorsNoGradient = tuple( @@ -41,7 +34,7 @@ export const extendedColorsNoGradient = tuple( "success", "warning", "error", - "invert" + "invert", ); export const extraColors = tuple( @@ -57,24 +50,12 @@ export const extraColors = tuple( "purple", "violet", "gradient", - "cyan" + "cyan", ); -export const normalLoaders = tuple( - "default", - "points", - "points-opacity", - "gradient", - "spinner" -); +export const normalLoaders = tuple("default", "points", "points-opacity", "gradient", "spinner"); -export const normalWeights = tuple( - "light", - "normal", - "bold", - "extrabold", - "black" -); +export const normalWeights = tuple("light", "normal", "bold", "extrabold", "black"); export const textWeights = tuple( /* Keyword values */ @@ -87,7 +68,7 @@ export const textWeights = tuple( "inherit", "initial", "revert", - "unset" + "unset", ); export const textTransforms = tuple( @@ -102,7 +83,7 @@ export const textTransforms = tuple( "inherit", "initial", "revert", - "unset" + "unset", ); const copyTypes = tuple("default", "slient", "prevent"); @@ -121,7 +102,7 @@ const placement = tuple( "bottomEnd", "right", "rightStart", - "rightEnd" + "rightEnd", ); const position = tuple( @@ -134,7 +115,7 @@ const position = tuple( "inherit", "initial", "revert", - "unset" + "unset", ); const objectFit = tuple( @@ -147,7 +128,7 @@ const objectFit = tuple( "inherit", "initial", "revert", - "unset" + "unset", ); const dividerAlign = tuple("start", "center", "end", "left", "right"); @@ -158,16 +139,10 @@ const justify = tuple( "flex-end", "space-between", "space-around", - "space-evenly" + "space-evenly", ); -const alignItems = tuple( - "flex-start", - "flex-end", - "center", - "stretch", - "baseline" -); +const alignItems = tuple("flex-start", "flex-end", "center", "stretch", "baseline"); const alignContent = tuple( "stretch", @@ -175,7 +150,7 @@ const alignContent = tuple( "flex-start", "flex-end", "space-between", - "space-around" + "space-around", ); const direction = tuple("row", "row-reverse", "column", "column-reverse"); @@ -189,7 +164,7 @@ const display = tuple( "inline", "inline-block", "inline-flex", - "inline-grid" + "inline-grid", ); const contentPosition = tuple("left", "right"); @@ -209,7 +184,7 @@ export const excludedInputPropsForTextarea = tuple( "contentRightStyling", "onContentClick", "onClearClick", - "css" + "css", ); const selectionBehavior = tuple("toggle", "replace"); From 9e6361fc68bb6b5b62cf3115e97d23854469e28d Mon Sep 17 00:00:00 2001 From: Artem Shteltser Date: Sun, 3 Jul 2022 17:35:08 +0300 Subject: [PATCH 020/106] change zIndex --- packages/react/src/dropdown/dropdown.styles.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/src/dropdown/dropdown.styles.ts b/packages/react/src/dropdown/dropdown.styles.ts index 685bf03f83..c5ea895d1e 100644 --- a/packages/react/src/dropdown/dropdown.styles.ts +++ b/packages/react/src/dropdown/dropdown.styles.ts @@ -209,7 +209,7 @@ export const StyledDropdownItem = styled( true: { bg: '$$dropdownItemHoverBackground', color: '$$dropdownItemHoverTextColor', - zIndex: 1, + zIndex: '$1', [`& ${StyledDropdownItemKbd}`]: { color: '$$dropdownItemHoverTextColor', borderColor: '$$dropdownItemHoverBorderColor' From 77b09ba70b1d95f5fe8c34ec2d516786645f4a74 Mon Sep 17 00:00:00 2001 From: Artem Shteltser Date: Sun, 3 Jul 2022 17:40:09 +0300 Subject: [PATCH 021/106] fix quotes --- packages/react/src/dropdown/dropdown.styles.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react/src/dropdown/dropdown.styles.ts b/packages/react/src/dropdown/dropdown.styles.ts index b40b068306..0555c01efc 100644 --- a/packages/react/src/dropdown/dropdown.styles.ts +++ b/packages/react/src/dropdown/dropdown.styles.ts @@ -207,9 +207,9 @@ export const StyledDropdownItem = styled( }, isFocused: { true: { - bg: '$$dropdownItemHoverBackground', - color: '$$dropdownItemHoverTextColor', - zIndex: '$1', + bg: "$$dropdownItemHoverBackground", + color: "$$dropdownItemHoverTextColor", + zIndex: "$1", [`& ${StyledDropdownItemKbd}`]: { color: "$$dropdownItemHoverTextColor", borderColor: "$$dropdownItemHoverBorderColor", From 4e5919a3965b295c38b08c6cf76eca4f2c50a090 Mon Sep 17 00:00:00 2001 From: danielsimao Date: Tue, 5 Jul 2022 15:34:16 +0100 Subject: [PATCH 022/106] fix(docs): Kbar change theme --- apps/docs/src/components/index.ts | 1 + .../src/components/kbar-wrapper/index.tsx | 29 +++++++++++++++++++ apps/docs/src/lib/kbar-actions.ts | 19 +++++++----- apps/docs/src/pages/_app.tsx | 23 ++------------- 4 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 apps/docs/src/components/kbar-wrapper/index.tsx diff --git a/apps/docs/src/components/index.ts b/apps/docs/src/components/index.ts index 2517af1ed7..985c097eca 100644 --- a/apps/docs/src/components/index.ts +++ b/apps/docs/src/components/index.ts @@ -28,6 +28,7 @@ export { default as ExampleBlock } from './templates/example-block'; export { default as ThemeToggle } from './theme-toggle'; export { default as ThemeSwitch } from './theme-switch'; export { default as KBar } from './kbar'; +export { default as KBarWrapper } from './kbar-wrapper'; export { default as Blockholder } from './blockholder'; export { default as LooperBG } from './looper-bg'; export { default as FeaturesGrid } from './features-grid'; diff --git a/apps/docs/src/components/kbar-wrapper/index.tsx b/apps/docs/src/components/kbar-wrapper/index.tsx new file mode 100644 index 0000000000..60f5ebc9f1 --- /dev/null +++ b/apps/docs/src/components/kbar-wrapper/index.tsx @@ -0,0 +1,29 @@ +import { KBarProvider } from 'kbar'; +import dynamic from 'next/dynamic'; +import React from 'react'; +import useKbarActions from '@lib/kbar-actions'; + +const KbarComponent = dynamic(() => import('../kbar'), { + ssr: false +}); + +const KBARWrapper: React.FC = ({ children }) => { + const kbarActions = useKbarActions(); + + return ( + + + {children} + + ); +}; + +export default KBARWrapper; diff --git a/apps/docs/src/lib/kbar-actions.ts b/apps/docs/src/lib/kbar-actions.ts index 0d7ff4e4c0..2893554b0f 100644 --- a/apps/docs/src/lib/kbar-actions.ts +++ b/apps/docs/src/lib/kbar-actions.ts @@ -1,9 +1,10 @@ import { Action } from 'kbar'; -import { NextRouter } from 'next/router'; +import { NextRouter, useRouter } from 'next/router'; +import { ThemeType } from '@nextui-org/react'; +import { useTheme as useNextTheme } from 'next-themes'; import { Route } from '@lib/docs/page'; import { getId } from '../utils/collections'; import { removeFromLast } from '@utils/index'; -import { ThemeType, changeTheme } from '@nextui-org/react'; // data imported from manifest import docsManifest from '../../content/docs/manifest.json'; @@ -57,14 +58,16 @@ const handleExternalLink = (href: string) => { }).click(); }; -const handleChangeTheme = (theme: ThemeType) => { - changeTheme(theme); -}; - -const getActions = (router: NextRouter): Action[] => { +const useActions = (): Action[] => { + const router = useRouter(); + const { setTheme } = useNextTheme(); const routes = docsManifest.routes; buildDocsActions(router, routes); + const handleChangeTheme = (theme: ThemeType) => { + setTheme(theme); + }; + const staticActions: Action[] = [ { id: 'twitter', @@ -129,4 +132,4 @@ const getActions = (router: NextRouter): Action[] => { return [...docsActions, ...staticActions]; }; -export default getActions; +export default useActions; diff --git a/apps/docs/src/pages/_app.tsx b/apps/docs/src/pages/_app.tsx index 03dbbb8f02..30ae8a3548 100644 --- a/apps/docs/src/pages/_app.tsx +++ b/apps/docs/src/pages/_app.tsx @@ -1,21 +1,19 @@ import React from 'react'; import { NextPage } from 'next'; -import dynamic from 'next/dynamic'; import { debounce } from 'lodash'; -import { NextRouter, Router, useRouter } from 'next/router'; +import { NextRouter, Router } from 'next/router'; import { NextUIProvider } from '@nextui-org/react'; import { ThemeProvider as NextThemesProvider } from 'next-themes'; import NProgress from 'nprogress'; import PlausibleProvider from 'next-plausible'; import { AppInitialProps } from 'next/app'; import { NextComponent } from '@lib/types'; -import generateKbarActions from '@lib/kbar-actions'; -import { KBarProvider } from 'kbar'; import { lightTheme, darkTheme } from '../theme/shared'; import { isProd } from '@utils/index'; import RouterEvents from '@lib/router-events'; import globalStyles from '../styles/globalStyles'; import '../styles/sandpack.css'; +import { KBarWrapper as KBarProvider } from '@components'; type AppPropsType< R extends NextRouter = NextRouter, @@ -29,10 +27,6 @@ type AppPropsType< type AppProps

        = AppPropsType; -const KbarComponent = dynamic(() => import('../components/kbar'), { - ssr: false -}); - NProgress.configure({ parent: '#app-container' }); const start = debounce(NProgress.start, 100); @@ -48,8 +42,6 @@ RouterEvents.on('routeChangeError', () => { }); const Application: NextPage> = ({ Component, pageProps }) => { - const router = useRouter(); - const kbarActions = generateKbarActions(router); globalStyles(); return ( > = ({ Component, pageProps }) => { > - - + From 4bbc1b4bccfa2266f55a732eea6ad4c942555c85 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Wed, 6 Jul 2022 00:25:06 -0300 Subject: [PATCH 023/106] feat(react-badge): initial structure created, variants and styles --- .../react/src/badge/__tests__/index.test.tsx | 0 packages/react/src/badge/badge.stories.tsx | 271 +++++++++++++++++ packages/react/src/badge/badge.styles.ts | 273 ++++++++++++++++++ packages/react/src/badge/badge.tsx | 68 +++++ packages/react/src/badge/index.ts | 3 + packages/react/src/utils/system.ts | 66 +++++ 6 files changed, 681 insertions(+) create mode 100644 packages/react/src/badge/__tests__/index.test.tsx create mode 100644 packages/react/src/badge/badge.stories.tsx create mode 100644 packages/react/src/badge/badge.styles.ts create mode 100644 packages/react/src/badge/badge.tsx create mode 100644 packages/react/src/badge/index.ts create mode 100644 packages/react/src/utils/system.ts diff --git a/packages/react/src/badge/__tests__/index.test.tsx b/packages/react/src/badge/__tests__/index.test.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/react/src/badge/badge.stories.tsx b/packages/react/src/badge/badge.stories.tsx new file mode 100644 index 0000000000..7798f2d0a3 --- /dev/null +++ b/packages/react/src/badge/badge.stories.tsx @@ -0,0 +1,271 @@ +import React from "react"; +import {Meta} from "@storybook/react"; + +import {Col, Row, Spacer} from "../index"; + +import Badge from "./index"; + +export default { + title: "Display/Badge", + component: Badge, +} as Meta; + +export const Default = () => New; + +export const Sizes = () => ( + + + New (xs) + + + + New (sm) + + + + New (md) + + + + New (lg) + + + + New (xl) + + + +); + +export const Squared = () => ( + + + + New (xs) + + + + + + New (sm) + + + + + + New (md) + + + + + + New (lg) + + + + + + New (xl) + + + + +); + +export const Colors = () => ( + + + Neutral + + + + Primary + + + + Secondary + + + + Success + + + + Warning + + + + Error + + +); + +export const EnableShadow = () => ( + + + Neutral + + + + + Primary + + + + + + Secondary + + + + + + Success + + + + + + Warning + + + + + + Error + + + +); + +export const FlatVariant = () => ( + + + Neutral + + + + + Primary + + + + + + Secondary + + + + + + Success + + + + + + Warning + + + + + + Error + + + +); + +export const BorderedVariant = () => ( + + + Neutral + + + + + Primary + + + + + + Secondary + + + + + + Success + + + + + + Warning + + + + + + Error + + + +); + +export const DotVariant = () => ( + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const PointsVariant = () => ( + + + + + + + + + + + + + + + + + + + + + + + + + +); diff --git a/packages/react/src/badge/badge.styles.ts b/packages/react/src/badge/badge.styles.ts new file mode 100644 index 0000000000..aa27b9bbf8 --- /dev/null +++ b/packages/react/src/badge/badge.styles.ts @@ -0,0 +1,273 @@ +import {styled, keyframes, VariantProps} from "../theme/stitches.config"; + +const pointAnimation = keyframes({ + "0%": { + opacity: 1, + }, + "50%": { + opacity: "0.4", + transform: "scale(0.5)", + }, + "100%": { + opacity: 1, + }, +}); + +export const StyledBadge = styled("span", { + display: "inline-block", + whiteSpace: "nowrap", + verticalAlign: "middle", + bg: "$$badgeBackgroundColor", + color: "$$badgeTextColor", + fontWeight: "$semibold", + fontSize: "$$badgeFontSize", + variants: { + size: { + xs: { + p: "$1 $3", + $$badgeFontSize: "0.65rem", + }, + sm: { + p: "$1 $4", + $$badgeFontSize: "$fontSizes$xs", + }, + md: { + p: "$1 $5", + $$badgeFontSize: "$fontSizes$sm", + }, + lg: { + p: "$1 $6", + $$badgeFontSize: "$fontSizes$lg", + }, + xl: { + p: "$1 $7", + $$badgeFontSize: "$fontSizes$xl", + }, + }, + color: { + neutral: { + $$badgeBackgroundColor: "$colors$neutral", + $$badgeTextColor: "$colors$neutralSolidContrast", + $$badgeShadowColor: "$colors$neutralShadow", + }, + primary: { + $$badgeBackgroundColor: "$colors$primary", + $$badgeTextColor: "$colors$primarySolidContrast", + $$badgeShadowColor: "$colors$primaryShadow", + }, + secondary: { + $$badgeBackgroundColor: "$colors$secondary", + $$badgeTextColor: "$colors$secondarySolidContrast", + $$badgeShadowColor: "$colors$secondaryShadow", + }, + success: { + $$badgeBackgroundColor: "$colors$success", + $$badgeTextColor: "$colors$successSolidContrast", + $$badgeShadowColor: "$colors$successShadow", + }, + warning: { + $$badgeBackgroundColor: "$colors$warning", + $$badgeTextColor: "$colors$warningSolidContrast", + $$badgeShadowColor: "$colors$warningShadow", + }, + error: { + $$badgeBackgroundColor: "$colors$error", + $$badgeTextColor: "$colors$errorSolidContrast", + $$badgeShadowColor: "$colors$errorShadow", + }, + }, + enableShadow: { + true: { + boxShadow: "0 2px 10px 0 $$badgeShadowColor", + }, + }, + isSquared: { + true: { + borderRadius: "calc($$badgeFontSize * 0.45)", + }, + false: { + borderRadius: "$pill", + }, + }, + variant: { + default: {}, + flat: {}, + dot: { + dflex: "center", + minSize: "$$badgeFontSize", + boxSizing: "border-box", + border: "2px solid $colors$background", + p: 0, + }, + points: { + p: "calc($$badgeFontSize * 0.4)", + boxSizing: "border-box", + border: "2px solid $colors$background", + }, + bordered: { + $$badgeBackgroundColor: "$background", + bw: "$$badgeBorderWeight", + borderStyle: "solid", + borderColor: "$$badgeTextColor", + }, + }, + borderWeight: { + light: { + $$badgeBorderWeight: "$borderWeights$light", + }, + normal: { + $$badgeBorderWeight: "$borderWeights$normal", + }, + bold: { + $$badgeBorderWeight: "$borderWeights$bold", + }, + extrabold: { + $$badgeBorderWeight: "$borderWeights$extrabold", + }, + black: { + $$badgeBorderWeight: "$borderWeights$black", + }, + }, + }, + compoundVariants: [ + /*** + * @variant flat + * @color {neutral, primary, secondary, success, warning, error} + */ + // variant=flat && color=neutral + { + variant: "flat", + color: "neutral", + css: { + $$badgeBackgroundColor: "$colors$neutralLight", + $$badgeTextColor: "$colors$neutralLightContrast", + }, + }, + // variant=flat && color=primary + { + variant: "flat", + color: "primary", + css: { + $$badgeBackgroundColor: "$colors$primaryLight", + $$badgeTextColor: "$colors$primaryLightContrast", + }, + }, + // variant=flat && color=secondary + { + variant: "flat", + color: "secondary", + css: { + $$badgeBackgroundColor: "$colors$secondaryLight", + $$badgeTextColor: "$colors$secondaryLightContrast", + }, + }, + // variant=flat && color=success + { + variant: "flat", + color: "success", + css: { + $$badgeBackgroundColor: "$colors$successLight", + $$badgeTextColor: "$colors$successLightContrast", + }, + }, + // variant=flat && color=warning + { + variant: "flat", + color: "warning", + css: { + $$badgeBackgroundColor: "$colors$warningLight", + $$badgeTextColor: "$colors$warningLightContrast", + }, + }, + // variant=flat && color=error + { + variant: "flat", + color: "error", + css: { + $$badgeBackgroundColor: "$colors$errorLight", + $$badgeTextColor: "$colors$errorLightContrast", + }, + }, + /*** + * @variant bordered + * @color {neutral, primary, secondary, success, warning, error} + */ + // variant=bordered && color=neutral + { + variant: "bordered", + color: "neutral", + css: { + $$badgeTextColor: "$colors$neutral", + }, + }, + // variant=bordered && color=primary + { + variant: "bordered", + color: "primary", + css: { + $$badgeTextColor: "$colors$primary", + }, + }, + // variant=bordered && color=secondary + { + variant: "bordered", + color: "secondary", + css: { + $$badgeTextColor: "$colors$secondary", + }, + }, + // variant=bordered && color=success + { + variant: "bordered", + color: "success", + css: { + $$badgeTextColor: "$colors$success", + }, + }, + // variant=bordered && color=warning + { + variant: "bordered", + color: "warning", + css: { + $$badgeTextColor: "$colors$warning", + }, + }, + // variant=bordered && color=error + { + variant: "bordered", + color: "error", + css: { + $$badgeTextColor: "$colors$error", + }, + }, + ], + defaultVariants: { + size: "sm", + color: "neutral", + variant: "default", + borderWeight: "normal", + isSquared: false, + }, +}); + +export const StyledBadgePoints = styled("div", { + position: "relative", + dflex: "center", + "& .nextui-badge-point": { + size: "calc($$badgeFontSize * 0.5)", + background: "$$badgeTextColor", + margin: "0 2px", + borderRadius: "$pill", + "&:nth-child(1)": { + animation: `${pointAnimation} 1.2s ease infinite`, + }, + "&:nth-child(2)": { + animation: `${pointAnimation} 1.2s ease infinite 0.4s`, + }, + "&:nth-child(3)": { + animation: `${pointAnimation} 1.2s ease infinite 0.8s`, + }, + }, +}); + +export type BadgeVariantsProps = VariantProps; diff --git a/packages/react/src/badge/badge.tsx b/packages/react/src/badge/badge.tsx new file mode 100644 index 0000000000..48b5f48600 --- /dev/null +++ b/packages/react/src/badge/badge.tsx @@ -0,0 +1,68 @@ +import * as React from "react"; + +import {HTMLNextUIProps, forwardRef} from "../utils/system"; +import clsx from "../utils/clsx"; +import {useDOMRef} from "../utils/dom"; +import {__DEV__} from "../utils/assertion"; + +import {StyledBadge, StyledBadgePoints, BadgeVariantsProps} from "./badge.styles"; + +export type BadgePlacement = "bottom-left" | "bottom-right" | "top-left" | "top-right"; + +interface Props extends Omit, keyof BadgeVariantsProps> { + placement?: BadgePlacement; + isVisible?: boolean; + content?: string | number | React.ReactNode; + children?: React.ReactNode; +} + +export type BadgeProps = Props & BadgeVariantsProps; + +export const Badge = forwardRef((props, ref) => { + const { + children, + enableShadow = false, + placement = "top-right", + variant = "default", + className, + ...otherProps + } = props; + + const domRef = useDOMRef(ref); + + const badgeChildren = React.useMemo(() => { + if (variant === "dot") { + return null; + } + + if (variant === "points") { + return ( + + + + + + ); + } + + return children; + }, [variant, children]); + + return ( + + {badgeChildren} + + ); +}); + +if (__DEV__) { + Badge.displayName = "NextUI.Badge"; +} + +Badge.toString = () => ".nextui-badge"; diff --git a/packages/react/src/badge/index.ts b/packages/react/src/badge/index.ts new file mode 100644 index 0000000000..b3a505ab7a --- /dev/null +++ b/packages/react/src/badge/index.ts @@ -0,0 +1,3 @@ +import {Badge} from "./badge"; + +export default Badge; diff --git a/packages/react/src/utils/system.ts b/packages/react/src/utils/system.ts new file mode 100644 index 0000000000..100a37b1cc --- /dev/null +++ b/packages/react/src/utils/system.ts @@ -0,0 +1,66 @@ +/** + * Part of this code is taken from @chakra-ui/system + */ + +import {forwardRef as baseForwardRef} from "react"; + +import {CSS} from "../theme/stitches.config"; + +export type As = React.ElementType; + +export type OmitCommonProps = Omit< + Target, + "transition" | "as" | "color" | OmitAdditionalProps +>; + +export type RightJoinProps< + SourceProps extends object = {}, + OverrideProps extends object = {}, +> = OmitCommonProps & OverrideProps; + +export type MergeWithAs< + ComponentProps extends object, + AsProps extends object, + AdditionalProps extends object = {}, + AsComponent extends As = As, +> = RightJoinProps & + RightJoinProps & { + as?: AsComponent; + }; + +export type ComponentWithAs = { + ( + props: MergeWithAs< + React.ComponentProps, + React.ComponentProps, + Props, + AsComponent + >, + ): JSX.Element; + + displayName?: string; + propTypes?: React.WeakValidationMap; + contextTypes?: React.ValidationMap; + defaultProps?: Partial; + id?: string; +}; + +/** + * Extract the props of a React element or component + */ +export type PropsOf = React.ComponentPropsWithoutRef & { + as?: As; +}; + +export type HTMLNextUIProps = Omit, "ref"> & {as?: As; css?: CSS}; + +export function forwardRef( + component: React.ForwardRefRenderFunction< + any, + RightJoinProps, Props> & { + as?: As; + } + >, +) { + return baseForwardRef(component) as unknown as ComponentWithAs; +} From d4b5c3ab675d3039aaaaa06033b6e8f5b40f77be Mon Sep 17 00:00:00 2001 From: danielsimao Date: Wed, 6 Jul 2022 08:42:45 +0100 Subject: [PATCH 024/106] fix(docs): code review --- apps/docs/src/components/kbar-wrapper/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/docs/src/components/kbar-wrapper/index.tsx b/apps/docs/src/components/kbar-wrapper/index.tsx index 60f5ebc9f1..0c24e7ce97 100644 --- a/apps/docs/src/components/kbar-wrapper/index.tsx +++ b/apps/docs/src/components/kbar-wrapper/index.tsx @@ -3,11 +3,15 @@ import dynamic from 'next/dynamic'; import React from 'react'; import useKbarActions from '@lib/kbar-actions'; +type KBARWrapperProps = { + children?: React.ReactNode; +}; + const KbarComponent = dynamic(() => import('../kbar'), { ssr: false }); -const KBARWrapper: React.FC = ({ children }) => { +const KBARWrapper: React.FC = ({ children }) => { const kbarActions = useKbarActions(); return ( From 8341431d923de56ff2f8fa0cdd9f305f197b0ae8 Mon Sep 17 00:00:00 2001 From: Paul Tiedtke Date: Wed, 6 Jul 2022 13:14:33 +0200 Subject: [PATCH 025/106] fix(docs): wrong case in image props --- apps/docs/content/docs/components/image.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/content/docs/components/image.mdx b/apps/docs/content/docs/components/image.mdx index 3f48dd121b..ff7085e2ba 100644 --- a/apps/docs/content/docs/components/image.mdx +++ b/apps/docs/content/docs/components/image.mdx @@ -58,7 +58,7 @@ import { Image } from '@nextui-org/react'; | **height** | `string` | Specifies Image Height | - | | **maxDelay** | `number` | Specifies how long Image Skeleton Renders Animation | `3000` | | **className** | `string` | Give Image A ClasName | - | -| **containerCSS** | `Stitches.CSS` | Override Default Image Contianer Style | - | +| **containerCss** | `Stitches.CSS` | Override Default Image Contianer Style | - | | **css** | `Stitches.CSS` | Override Default CSS style | - | | **as** | `keyof JSX.IntrinsicElements` | Changes which tag component outputs | `img` | | ... | `ImageHTMLAttributes` | Native props | - | From cc98eef053e26c9452eb88b62f8ea2ac012ac63c Mon Sep 17 00:00:00 2001 From: benmneb <62878664+benmneb@users.noreply.github.com> Date: Wed, 6 Jul 2022 13:20:08 +0000 Subject: [PATCH 026/106] Fix typos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 💯 --- apps/docs/content/docs/components/input.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/docs/content/docs/components/input.mdx b/apps/docs/content/docs/components/input.mdx index 886614417d..eeb0e973df 100644 --- a/apps/docs/content/docs/components/input.mdx +++ b/apps/docs/content/docs/components/input.mdx @@ -42,7 +42,7 @@ import { Input } from '@nextui-org/react'; @@ -107,8 +107,8 @@ import { Input } from '@nextui-org/react'; From 4170c3bb271461bc759734875162048d3b30b586 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Wed, 6 Jul 2022 23:54:39 -0300 Subject: [PATCH 027/106] feat(badge): test passing, variants added, styles added --- packages/react/.babelrc.js | 44 ++-- packages/react/.jest.config.js | 23 -- packages/react/jest.config.js | 23 ++ packages/react/package.json | 5 +- .../react/src/badge/__tests__/index.test.tsx | 59 +++++ packages/react/src/badge/badge.animations.ts | 118 +++++++++ packages/react/src/badge/badge.stories.tsx | 216 +++++++++++++++- packages/react/src/badge/badge.styles.ts | 241 ++++++++++++++++-- packages/react/src/badge/badge.tsx | 93 +++++-- .../__snapshots__/group.test.tsx.snap | 128 +++++----- .../__snapshots__/index.test.tsx.snap | 144 +++++------ .../__snapshots__/index.test.tsx.snap | 8 +- .../__snapshots__/password.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 4 +- .../__snapshots__/index.test.tsx.snap | 4 +- packages/react/tests/jest-setup.js | 6 + packages/react/tests/setup.js | 4 - packages/react/tsconfig.json | 51 ++-- yarn.lock | 96 +------ 19 files changed, 903 insertions(+), 366 deletions(-) delete mode 100644 packages/react/.jest.config.js create mode 100644 packages/react/jest.config.js create mode 100644 packages/react/src/badge/badge.animations.ts create mode 100644 packages/react/tests/jest-setup.js delete mode 100644 packages/react/tests/setup.js diff --git a/packages/react/.babelrc.js b/packages/react/.babelrc.js index f44182a996..58e0c32c79 100644 --- a/packages/react/.babelrc.js +++ b/packages/react/.babelrc.js @@ -3,51 +3,49 @@ module.exports = (api) => { let dev = false; let modules; + let plugins; switch (env) { - case 'docs': - case 'test': - case 'dist-dev': - case 'development': + case "docs": + case "test": + case "dist-dev": + case "development": dev = true; modules = false; break; - case 'dist-prod': - case 'esm': + case "dist-prod": + plugins = ["@testing-library/babel-plugin-react"]; + case "production": + plugins = ["@testing-library/babel-plugin-react"]; + case "esm": modules = false; break; - case 'cjs': + case "cjs": default: - modules = 'commonjs'; + modules = "commonjs"; } const presets = - env !== 'test' && env !== 'development' + env !== "test" && env !== "development" ? [ [ - '@react-bootstrap', + "@react-bootstrap", { dev, modules, - removePropTypes: !dev - } + removePropTypes: !dev, + }, ], - '@babel/preset-typescript' + "@babel/preset-typescript", ] - : ['@babel/preset-env', '@babel/react', '@babel/preset-typescript']; - - const plugins = []; + : ["@babel/preset-env", "@babel/react", "@babel/preset-typescript"]; return { presets, plugins, ignore: - env !== 'test' && env !== 'development' - ? [ - /@babel[\\|/]runtime/, - /\.stories\.(js|ts|tsx)$/, - /\.test\.(js|ts|tsx)$/ - ] - : [] + env !== "test" && env !== "development" + ? [/@babel[\\|/]runtime/, /\.stories\.(js|ts|tsx)$/, /\.test\.(js|ts|tsx)$/] + : [], }; }; diff --git a/packages/react/.jest.config.js b/packages/react/.jest.config.js deleted file mode 100644 index d7a65c1df5..0000000000 --- a/packages/react/.jest.config.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - verbose: true, - testEnvironment: 'jsdom', - setupFiles: ['./tests/setup.js'], - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - testPathIgnorePatterns: ['/dist/', '/lib/'], - transform: { - '^.+\\.[jt]sx?$': ['babel-jest', { configFile: './tests/.babelrc.js' }], - }, - testRegex: '.*\\.test\\.(j|t)sx?$', - collectCoverageFrom: [ - 'src/**/*.{ts,tsx}', - '!src/**/styles.{ts,tsx}', - '!src/**/*stories.{ts,tsx}', - '!src/**/*types.{ts,tsx}', - '!src/styles/*', - '!src/index.ts', - ], - moduleNameMapper: { - 'tests/(.*)$': '/tests/$1', - components: './src/index.ts', - }, -}; diff --git a/packages/react/jest.config.js b/packages/react/jest.config.js new file mode 100644 index 0000000000..c16481b3b0 --- /dev/null +++ b/packages/react/jest.config.js @@ -0,0 +1,23 @@ +module.exports = { + verbose: true, + testEnvironment: "jsdom", + setupFiles: ["./tests/jest-setup.js"], + moduleFileExtensions: ["ts", "tsx", "js", "jsx"], + testPathIgnorePatterns: ["/dist/", "/lib/"], + transform: { + "^.+\\.[jt]sx?$": ["babel-jest", {configFile: "./tests/.babelrc.js"}], + }, + testRegex: ".*\\.test\\.(j|t)sx?$", + collectCoverageFrom: [ + "src/**/*.{ts,tsx}", + "!src/**/styles.{ts,tsx}", + "!src/**/*stories.{ts,tsx}", + "!src/**/*types.{ts,tsx}", + "!src/styles/*", + "!src/index.ts", + ], + moduleNameMapper: { + "tests/(.*)$": "/tests/$1", + components: "./src/index.ts", + }, +}; diff --git a/packages/react/package.json b/packages/react/package.json index 19e617ae4e..7026539b6c 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -47,8 +47,8 @@ "build:watch": "node ./scripts/build-watch.js", "dev": "yarn clear && yarn build:dev-types && yarn build:watch", "lint": "eslint \"src/**/*.{js,ts,tsx}\"", - "test": "jest --config .jest.config.js --no-cache", - "test-update": "jest --config .jest.config.js --no-cache --update-snapshot", + "test": "jest --config jest.config.js --no-cache", + "test-update": "jest --config jest.config.js --no-cache --update-snapshot", "coverage": "yarn test --coverage", "coverage-update": "yarn test-update --coverage", "coverage:codecov": "yarn test --coverage && codecov" @@ -101,7 +101,6 @@ "@react-bootstrap/babel-preset": "^2.1.0", "@storybook/react": "^6.5.3", "@testing-library/dom": "^8.1.0", - "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^12.1.2", "@testing-library/react-hooks": "^7.0.0", "@testing-library/user-event": "^13.2.0", diff --git a/packages/react/src/badge/__tests__/index.test.tsx b/packages/react/src/badge/__tests__/index.test.tsx index e69de29bb2..8b58aa8be8 100644 --- a/packages/react/src/badge/__tests__/index.test.tsx +++ b/packages/react/src/badge/__tests__/index.test.tsx @@ -0,0 +1,59 @@ +import React from "react"; +import {render, screen} from "@testing-library/react"; + +import Badge from "../index"; + +describe("Badge", () => { + it("should render correctly", () => { + const wrapper = render(New); + + expect(() => wrapper.unmount()).not.toThrow(); + }); + + it("should render children and content", () => { + const wrapper = render( + }> + new + , + ); + + expect(wrapper.getByTestId("badge-content")).toBeTruthy(); + expect(wrapper.getByTestId("badge-children")).toBeTruthy(); + }); + + it("should not render children if variant is dot", () => { + const wrapper = render( + + new + , + ); + + expect(wrapper.queryAllByTestId("badge-children")).toHaveLength(0); + }); + + it("should not render children if variant is points", () => { + const wrapper = render( + + new + , + ); + + expect(wrapper.queryAllByTestId("badge-children")).toHaveLength(0); + }); + + it("should have 3 points if variant is points", () => { + const wrapper = render(); + + expect(wrapper.getAllByTestId("badge-point")).toHaveLength(3); + }); + + // it("should be invisible if invisible is true", () => { + // const {container} = render( + // } data-testid="badge-root"> + // new + // , + // ); + + // expect(container.querySelectorAll(".nextui-badge")[0]).toHaveClass("nextui-badge--invisible"); + // }); +}); diff --git a/packages/react/src/badge/badge.animations.ts b/packages/react/src/badge/badge.animations.ts new file mode 100644 index 0000000000..e97c23cdf3 --- /dev/null +++ b/packages/react/src/badge/badge.animations.ts @@ -0,0 +1,118 @@ +import {keyframes} from "../theme/stitches.config"; + +export const pointAnimation = keyframes({ + "0%": { + opacity: 1, + }, + "50%": { + opacity: "0.4", + transform: "scale(0.5)", + }, + "100%": { + opacity: 1, + }, +}); + +export const appearanceInTopRight = keyframes({ + "0%": { + opacity: 0, + transform: "scale(0.2) translate(50%, -50%)", + }, + "60%": { + opacity: 0.75, + transform: "scale(1.2) translate(50%, -50%)", + }, + "100%": { + opacity: 1, + transform: "scale(1) translate(50%, -50%)", + }, +}); + +export const appearanceOutTopRight = keyframes({ + "0%": { + opacity: 1, + transform: "scale(1) translate(50%, -50%)", + }, + "100%": { + opacity: 0, + transform: "scale(0.2) translate(50%, -50%)", + }, +}); + +export const appearanceInTopLeft = keyframes({ + "0%": { + opacity: 0, + transform: "scale(0.2) translate(-50%, -50%)", + }, + "60%": { + opacity: 0.75, + transform: "scale(1.2) translate(-50%, -50%)", + }, + "100%": { + opacity: 1, + transform: "scale(1) translate(-50%, -50%)", + }, +}); + +export const appearanceOutTopLeft = keyframes({ + "0%": { + opacity: 1, + transform: "scale(1) translate(-50%, -50%)", + }, + "100%": { + opacity: 0, + transform: "scale(0.2) translate(-50%, -50%)", + }, +}); + +export const appearanceInBottomRight = keyframes({ + "0%": { + opacity: 0, + transform: "scale(0.2) translate(50%, 50%)", + }, + "60%": { + opacity: 0.75, + transform: "scale(1.2) translate(50%, 50%)", + }, + "100%": { + opacity: 1, + transform: "scale(1) translate(50%, 50%)", + }, +}); + +export const appearanceOutBottomRight = keyframes({ + "0%": { + opacity: 1, + transform: "scale(1) translate(50%, 50%)", + }, + "100%": { + opacity: 0, + transform: "scale(0.2) translate(50%, 50%)", + }, +}); + +export const appearanceInBottomLeft = keyframes({ + "0%": { + opacity: 0, + transform: "scale(0.2) translate(-50%, 50%)", + }, + "60%": { + opacity: 0.75, + transform: "scale(1.2) translate(-50%, 50%)", + }, + "100%": { + opacity: 1, + transform: "scale(1) translate(-50%, 50%)", + }, +}); + +export const appearanceOutBottomLeft = keyframes({ + "0%": { + opacity: 1, + transform: "scale(1) translate(-50%, 50%)", + }, + "100%": { + opacity: 0, + transform: "scale(0.2) translate(-50%, 50%)", + }, +}); diff --git a/packages/react/src/badge/badge.stories.tsx b/packages/react/src/badge/badge.stories.tsx index 7798f2d0a3..bb46e48de1 100644 --- a/packages/react/src/badge/badge.stories.tsx +++ b/packages/react/src/badge/badge.stories.tsx @@ -1,7 +1,8 @@ import React from "react"; import {Meta} from "@storybook/react"; -import {Col, Row, Spacer} from "../index"; +import {Col, Row, Spacer, Grid, Avatar, Switch, Text} from "../index"; +import {Notification} from "../utils/icons"; import Badge from "./index"; @@ -12,6 +13,201 @@ export default { export const Default = () => New; +export const WithAvatar = () => ( + + + + + + + + + + + + +); + +export const WithIcon = () => ( + + + +); + +export const WithContentIcon = () => ( + } + css={{p: "$2"}} + horizontalOffset={2} + shape="circle" + > + + +); + +export const ToggleBadge = () => { + const [invisible, setInvisible] = React.useState(false); + + return ( + + + + + + + + + setInvisible(!ev.target.checked)} + /> + Show badge + + + + ); +}; + +export const WithContentPlacements = () => { + return ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + export const Sizes = () => ( @@ -103,35 +299,37 @@ export const Colors = () => ( export const EnableShadow = () => ( - Neutral + + Neutral + - + Primary - + Secondary - + Success - + Warning - + Error @@ -217,7 +415,9 @@ export const BorderedVariant = () => ( export const DotVariant = () => ( - + + new + diff --git a/packages/react/src/badge/badge.styles.ts b/packages/react/src/badge/badge.styles.ts index aa27b9bbf8..ba393eec72 100644 --- a/packages/react/src/badge/badge.styles.ts +++ b/packages/react/src/badge/badge.styles.ts @@ -1,19 +1,28 @@ -import {styled, keyframes, VariantProps} from "../theme/stitches.config"; +import {styled, VariantProps} from "../theme/stitches.config"; -const pointAnimation = keyframes({ - "0%": { - opacity: 1, - }, - "50%": { - opacity: "0.4", - transform: "scale(0.5)", - }, - "100%": { - opacity: 1, - }, +import { + pointAnimation, + appearanceInTopRight, + appearanceOutTopRight, + appearanceInTopLeft, + appearanceOutTopLeft, + appearanceInBottomRight, + appearanceOutBottomRight, + appearanceInBottomLeft, + appearanceOutBottomLeft, +} from "./badge.animations"; + +export const StyledBadgeRoot = styled("span", { + d: "inline-flex", + flexShrink: 0, + verticalAlign: "middle", + position: "relative", + overflow: "visible", }); export const StyledBadge = styled("span", { + $$badgePlacementHOffset: "0%", + $$badgePlacementVOffset: "0%", display: "inline-block", whiteSpace: "nowrap", verticalAlign: "middle", @@ -21,29 +30,55 @@ export const StyledBadge = styled("span", { color: "$$badgeTextColor", fontWeight: "$semibold", fontSize: "$$badgeFontSize", + p: "$1 $$badgeHPadding", + "@motion": { + animation: "none", + transition: "none", + "&.nextui-badge--invisible": { + animation: "none", + transition: "none", + }, + }, variants: { size: { xs: { - p: "$1 $3", + $$badgeHPadding: "$space$3", $$badgeFontSize: "0.65rem", }, sm: { - p: "$1 $4", + $$badgeHPadding: "$space$4", $$badgeFontSize: "$fontSizes$xs", }, md: { - p: "$1 $5", + $$badgeHPadding: "$space$4", $$badgeFontSize: "$fontSizes$sm", }, lg: { - p: "$1 $6", + $$badgeHPadding: "$space$5", $$badgeFontSize: "$fontSizes$lg", }, xl: { - p: "$1 $7", + $$badgeHPadding: "$space$5", $$badgeFontSize: "$fontSizes$xl", }, }, + shape: { + circle: {}, + rectangle: {}, + }, + asChild: { + true: { + zIndex: "$2", + dflex: "center", + position: "absolute", + }, + }, + isOneChar: { + true: { + size: "calc($$badgeFontSize + $$badgeHPadding)", + p: "calc($$badgeHPadding + 1px)", + }, + }, color: { neutral: { $$badgeBackgroundColor: "$colors$neutral", @@ -89,23 +124,53 @@ export const StyledBadge = styled("span", { borderRadius: "$pill", }, }, + placement: { + "top-right": { + animation: `${appearanceInTopRight} 0.25s ease-out`, + "&.nextui-badge--invisible": { + opacity: 0, + animation: `${appearanceOutTopRight} 0.25s ease-in`, + }, + }, + "top-left": { + animation: `${appearanceInTopLeft} 0.25s ease-out`, + "&.nextui-badge--invisible": { + opacity: 0, + animation: `${appearanceOutTopLeft} 0.25s ease-in`, + }, + }, + "bottom-right": { + animation: `${appearanceInBottomRight} 0.25s ease-out`, + "&.nextui-badge--invisible": { + opacity: 0, + animation: `${appearanceOutBottomRight} 0.25s ease-in`, + }, + }, + "bottom-left": { + animation: `${appearanceInBottomLeft} 0.25s ease-out`, + "&.nextui-badge--invisible": { + opacity: 0, + animation: `${appearanceOutBottomLeft} 0.25s ease-in`, + }, + }, + }, variant: { default: {}, flat: {}, dot: { + p: 0, dflex: "center", minSize: "$$badgeFontSize", boxSizing: "border-box", - border: "2px solid $colors$background", - p: 0, }, points: { p: "calc($$badgeFontSize * 0.4)", boxSizing: "border-box", - border: "2px solid $colors$background", + $$badgePlacementHOffset: "calc($$badgeFontSize * 0.8)", }, bordered: { - $$badgeBackgroundColor: "$background", + $$badgeBackgroundColor: "$colors$background", + bg: "$background", bw: "$$badgeBorderWeight", borderStyle: "solid", borderColor: "$$badgeTextColor", @@ -128,6 +193,21 @@ export const StyledBadge = styled("span", { $$badgeBorderWeight: "$borderWeights$black", }, }, + disableOutline: { + false: { + border: "2px solid $colors$background", + }, + }, + disableAnimation: { + true: { + animation: "none", + transition: "none", + "&.nextui-badge--invisible": { + animation: "none", + transition: "none", + }, + }, + }, }, compoundVariants: [ /*** @@ -240,12 +320,129 @@ export const StyledBadge = styled("span", { $$badgeTextColor: "$colors$error", }, }, + /*** + * @asChild true + * @shape {rectangle, circle} + * @placement {top-right, top-left, bottom-right, bottom-left} + */ + // placement=top-right && shape=rectangle + { + asChild: true, + shape: "rectangle", + placement: "top-right", + css: { + top: "calc(5% + $$badgePlacementVOffset)", + right: "calc(5% + $$badgePlacementHOffset)", + transform: "scale(1) translate(50%, -50%)", + transformOrigin: "100% 0%", + }, + }, + // placement=top-left && shape=rectangle + { + asChild: true, + shape: "rectangle", + placement: "top-left", + css: { + top: "calc(5% + $$badgePlacementVOffset)", + left: "calc(5% + $$badgePlacementHOffset)", + transform: "scale(1) translate(-50%, -50%)", + transformOrigin: "0% 0%", + }, + }, + // placement=bottom-right && shape=rectangle + { + asChild: true, + shape: "rectangle", + placement: "bottom-right", + css: { + bottom: "calc(5% + $$badgePlacementVOffset)", + right: "calc(5% + $$badgePlacementHOffset)", + transform: "scale(1) translate(50%, 50%)", + transformOrigin: "100% 100%", + }, + }, + // placement=bottom-left && shape=rectangle + { + asChild: true, + shape: "rectangle", + placement: "bottom-left", + css: { + bottom: "calc(5% + $$badgePlacementVOffset)", + left: "calc(5% + $$badgePlacementHOffset)", + transform: "scale(1) translate(-50%, 50%)", + transformOrigin: "0% 100%", + }, + }, + // placement=top-right && shape=circle + { + asChild: true, + shape: "circle", + placement: "top-right", + css: { + top: "calc(14% + $$badgePlacementVOffset)", + right: "calc(14% + $$badgePlacementHOffset)", + transform: "scale(1) translate(50%, -50%)", + transformOrigin: "100% 0%", + }, + }, + // placement=top-left && shape=circle + { + asChild: true, + shape: "circle", + placement: "top-left", + css: { + top: "calc(14% + $$badgePlacementVOffset)", + left: "calc(14% + $$badgePlacementHOffset)", + transform: "scale(1) translate(-50%, -50%)", + transformOrigin: "0% 0%", + }, + }, + // placement=bottom-right && shape=circle + { + asChild: true, + shape: "circle", + placement: "bottom-right", + css: { + bottom: "calc(14% + $$badgePlacementVOffset)", + right: "calc(14% + $$badgePlacementHOffset)", + transform: "scale(1) translate(50%, 50%)", + transformOrigin: "100% 100%", + }, + }, + // placement=bottom-left && shape=circle + { + asChild: true, + shape: "circle", + placement: "bottom-left", + css: { + bottom: "calc(14% + $$badgePlacementVOffset)", + left: "calc(14% + $$badgePlacementHOffset)", + transform: "scale(1) translate(-50%, 50%)", + transformOrigin: "0% 100%", + }, + }, + /** + * @variant dot + * @shape rectangle + */ + { + variant: "dot", + shape: "rectangle", + css: { + $$badgePlacementHOffset: "calc($$badgeFontSize * 0.2)", + $$badgePlacementVOffset: "calc($$badgeFontSize * 0.1)", + }, + }, ], defaultVariants: { size: "sm", color: "neutral", variant: "default", borderWeight: "normal", + placement: "top-right", + shape: "rectangle", + enableShadow: false, + disableOutline: false, isSquared: false, }, }); @@ -254,7 +451,7 @@ export const StyledBadgePoints = styled("div", { position: "relative", dflex: "center", "& .nextui-badge-point": { - size: "calc($$badgeFontSize * 0.5)", + size: "calc($$badgeFontSize * 0.3)", background: "$$badgeTextColor", margin: "0 2px", borderRadius: "$pill", diff --git a/packages/react/src/badge/badge.tsx b/packages/react/src/badge/badge.tsx index 48b5f48600..a02ab0d14c 100644 --- a/packages/react/src/badge/badge.tsx +++ b/packages/react/src/badge/badge.tsx @@ -5,31 +5,38 @@ import clsx from "../utils/clsx"; import {useDOMRef} from "../utils/dom"; import {__DEV__} from "../utils/assertion"; -import {StyledBadge, StyledBadgePoints, BadgeVariantsProps} from "./badge.styles"; - -export type BadgePlacement = "bottom-left" | "bottom-right" | "top-left" | "top-right"; +import {StyledBadge, StyledBadgePoints, StyledBadgeRoot, BadgeVariantsProps} from "./badge.styles"; interface Props extends Omit, keyof BadgeVariantsProps> { - placement?: BadgePlacement; - isVisible?: boolean; + invisible?: boolean; content?: string | number | React.ReactNode; + verticalOffset?: number; + horizontalOffset?: number; children?: React.ReactNode; } -export type BadgeProps = Props & BadgeVariantsProps; +export type BadgeProps = Props & Omit; export const Badge = forwardRef((props, ref) => { const { + css, children, - enableShadow = false, + content, + invisible = false, + disableOutline, placement = "top-right", variant = "default", + verticalOffset, + horizontalOffset, + disableAnimation = false, className, ...otherProps } = props; const domRef = useDOMRef(ref); + const asChild = content !== undefined && !!children; + const badgeChildren = React.useMemo(() => { if (variant === "dot") { return null; @@ -38,26 +45,70 @@ export const Badge = forwardRef((props, ref) => { if (variant === "points") { return ( - - - + + + ); } - return children; - }, [variant, children]); + return asChild ? content : children; + }, [variant, asChild, content, children]); + + const isOneChar = React.useMemo(() => { + if (asChild && content && variant !== "points" && variant !== "dot") { + return String(content)?.length === 1; + } + if (children && typeof children === "string") { + return children.length === 1; + } + + return false; + }, [asChild, children, variant, content]); + + const badgeCss = React.useMemo(() => { + if (verticalOffset && horizontalOffset) { + return { + $$badgePlacementHOffset: `${horizontalOffset}px`, + $$badgePlacementVOffset: `${verticalOffset}px`, + ...css, + }; + } + if (verticalOffset) { + return { + $$badgePlacementVOffset: `${verticalOffset}px`, + ...css, + }; + } + if (horizontalOffset) { + return { + $$badgePlacementHOffset: `${horizontalOffset}px`, + ...css, + }; + } + + return css; + }, [verticalOffset, horizontalOffset, css]); return ( - - {badgeChildren} - + + {asChild && children} + + {badgeChildren} + + ); }); diff --git a/packages/react/src/collapse/__tests__/__snapshots__/group.test.tsx.snap b/packages/react/src/collapse/__tests__/__snapshots__/group.test.tsx.snap index 8a9a7f7c64..99556bc5be 100644 --- a/packages/react/src/collapse/__tests__/__snapshots__/group.test.tsx.snap +++ b/packages/react/src/collapse/__tests__/__snapshots__/group.test.tsx.snap @@ -20,12 +20,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria4869397505-10", + "aria-controls": "react-aria9350437168-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-9", + "id": "react-aria9350437168-9", "role": "button", "tabindex": "0", }, @@ -324,9 +324,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-9", + "aria-labelledby": "react-aria9350437168-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-10", + "id": "react-aria9350437168-10", "role": "region", "tabindex": "-1", }, @@ -424,9 +424,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-9", + "aria-labelledby": "react-aria9350437168-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-10", + "id": "react-aria9350437168-10", "role": "region", "tabindex": "-1", }, @@ -481,12 +481,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria4869397505-10", + "aria-controls": "react-aria9350437168-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-9", + "id": "react-aria9350437168-9", "role": "button", "tabindex": "0", }, @@ -818,12 +818,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria4869397505-12", + "aria-controls": "react-aria9350437168-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-11", + "id": "react-aria9350437168-11", "role": "button", "tabindex": "0", }, @@ -1122,9 +1122,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-11", + "aria-labelledby": "react-aria9350437168-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-12", + "id": "react-aria9350437168-12", "role": "region", "tabindex": "-1", }, @@ -1222,9 +1222,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-11", + "aria-labelledby": "react-aria9350437168-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-12", + "id": "react-aria9350437168-12", "role": "region", "tabindex": "-1", }, @@ -1279,12 +1279,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria4869397505-12", + "aria-controls": "react-aria9350437168-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-11", + "id": "react-aria9350437168-11", "role": "button", "tabindex": "0", }, @@ -1645,12 +1645,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria4869397505-12", + "aria-controls": "react-aria9350437168-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-11", + "id": "react-aria9350437168-11", "role": "button", "tabindex": "0", }, @@ -1949,9 +1949,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-11", + "aria-labelledby": "react-aria9350437168-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-12", + "id": "react-aria9350437168-12", "role": "region", "tabindex": "-1", }, @@ -2049,9 +2049,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-11", + "aria-labelledby": "react-aria9350437168-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-12", + "id": "react-aria9350437168-12", "role": "region", "tabindex": "-1", }, @@ -2106,12 +2106,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria4869397505-12", + "aria-controls": "react-aria9350437168-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-11", + "id": "react-aria9350437168-11", "role": "button", "tabindex": "0", }, @@ -2445,12 +2445,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria4869397505-10", + "aria-controls": "react-aria9350437168-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-9", + "id": "react-aria9350437168-9", "role": "button", "tabindex": "0", }, @@ -2749,9 +2749,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-9", + "aria-labelledby": "react-aria9350437168-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-10", + "id": "react-aria9350437168-10", "role": "region", "tabindex": "-1", }, @@ -2849,9 +2849,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-9", + "aria-labelledby": "react-aria9350437168-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-10", + "id": "react-aria9350437168-10", "role": "region", "tabindex": "-1", }, @@ -2906,12 +2906,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria4869397505-10", + "aria-controls": "react-aria9350437168-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-9", + "id": "react-aria9350437168-9", "role": "button", "tabindex": "0", }, @@ -3385,12 +3385,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria4869397505-6", + "aria-controls": "react-aria9350437168-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-5", + "id": "react-aria9350437168-5", "role": "button", "tabindex": "0", }, @@ -3689,9 +3689,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-5", + "aria-labelledby": "react-aria9350437168-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-6", + "id": "react-aria9350437168-6", "role": "region", "tabindex": "-1", }, @@ -3789,9 +3789,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-5", + "aria-labelledby": "react-aria9350437168-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-6", + "id": "react-aria9350437168-6", "role": "region", "tabindex": "-1", }, @@ -3846,12 +3846,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria4869397505-6", + "aria-controls": "react-aria9350437168-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-5", + "id": "react-aria9350437168-5", "role": "button", "tabindex": "0", }, @@ -4183,12 +4183,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria4869397505-8", + "aria-controls": "react-aria9350437168-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-7", + "id": "react-aria9350437168-7", "role": "button", "tabindex": "0", }, @@ -4487,9 +4487,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-7", + "aria-labelledby": "react-aria9350437168-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-8", + "id": "react-aria9350437168-8", "role": "region", "tabindex": "-1", }, @@ -4587,9 +4587,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-7", + "aria-labelledby": "react-aria9350437168-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-8", + "id": "react-aria9350437168-8", "role": "region", "tabindex": "-1", }, @@ -4644,12 +4644,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria4869397505-8", + "aria-controls": "react-aria9350437168-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-7", + "id": "react-aria9350437168-7", "role": "button", "tabindex": "0", }, @@ -5010,12 +5010,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria4869397505-8", + "aria-controls": "react-aria9350437168-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-7", + "id": "react-aria9350437168-7", "role": "button", "tabindex": "0", }, @@ -5314,9 +5314,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-7", + "aria-labelledby": "react-aria9350437168-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-8", + "id": "react-aria9350437168-8", "role": "region", "tabindex": "-1", }, @@ -5414,9 +5414,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-7", + "aria-labelledby": "react-aria9350437168-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-8", + "id": "react-aria9350437168-8", "role": "region", "tabindex": "-1", }, @@ -5471,12 +5471,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria4869397505-8", + "aria-controls": "react-aria9350437168-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-7", + "id": "react-aria9350437168-7", "role": "button", "tabindex": "0", }, @@ -5810,12 +5810,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria4869397505-6", + "aria-controls": "react-aria9350437168-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-5", + "id": "react-aria9350437168-5", "role": "button", "tabindex": "0", }, @@ -6114,9 +6114,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-5", + "aria-labelledby": "react-aria9350437168-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-6", + "id": "react-aria9350437168-6", "role": "region", "tabindex": "-1", }, @@ -6214,9 +6214,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria4869397505-5", + "aria-labelledby": "react-aria9350437168-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria4869397505-6", + "id": "react-aria9350437168-6", "role": "region", "tabindex": "-1", }, @@ -6271,12 +6271,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria4869397505-6", + "aria-controls": "react-aria9350437168-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria4869397505-5", + "id": "react-aria9350437168-5", "role": "button", "tabindex": "0", }, diff --git a/packages/react/src/collapse/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/collapse/__tests__/__snapshots__/index.test.tsx.snap index 83f9edcb18..3d6a0a45f4 100644 --- a/packages/react/src/collapse/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/collapse/__tests__/__snapshots__/index.test.tsx.snap @@ -20,12 +20,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria5654713355-10", + "aria-controls": "react-aria7585738573-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-9", + "id": "react-aria7585738573-9", "role": "button", "tabindex": "0", }, @@ -476,9 +476,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-9", + "aria-labelledby": "react-aria7585738573-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-10", + "id": "react-aria7585738573-10", "role": "region", "tabindex": "-1", }, @@ -576,9 +576,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-9", + "aria-labelledby": "react-aria7585738573-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-10", + "id": "react-aria7585738573-10", "role": "region", "tabindex": "-1", }, @@ -633,12 +633,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria5654713355-10", + "aria-controls": "react-aria7585738573-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-9", + "id": "react-aria7585738573-9", "role": "button", "tabindex": "0", }, @@ -1122,12 +1122,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria5654713355-12", + "aria-controls": "react-aria7585738573-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-11", + "id": "react-aria7585738573-11", "role": "button", "tabindex": "0", }, @@ -1630,9 +1630,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-11", + "aria-labelledby": "react-aria7585738573-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-12", + "id": "react-aria7585738573-12", "role": "region", "tabindex": "-1", }, @@ -1730,9 +1730,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-11", + "aria-labelledby": "react-aria7585738573-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-12", + "id": "react-aria7585738573-12", "role": "region", "tabindex": "-1", }, @@ -1787,12 +1787,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria5654713355-12", + "aria-controls": "react-aria7585738573-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-11", + "id": "react-aria7585738573-11", "role": "button", "tabindex": "0", }, @@ -2357,12 +2357,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria5654713355-12", + "aria-controls": "react-aria7585738573-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-11", + "id": "react-aria7585738573-11", "role": "button", "tabindex": "0", }, @@ -2865,9 +2865,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-11", + "aria-labelledby": "react-aria7585738573-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-12", + "id": "react-aria7585738573-12", "role": "region", "tabindex": "-1", }, @@ -2965,9 +2965,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-11", + "aria-labelledby": "react-aria7585738573-11", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-12", + "id": "react-aria7585738573-12", "role": "region", "tabindex": "-1", }, @@ -3022,12 +3022,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria5654713355-12", + "aria-controls": "react-aria7585738573-12", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-11", + "id": "react-aria7585738573-11", "role": "button", "tabindex": "0", }, @@ -3565,12 +3565,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria5654713355-10", + "aria-controls": "react-aria7585738573-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-9", + "id": "react-aria7585738573-9", "role": "button", "tabindex": "0", }, @@ -4021,9 +4021,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-9", + "aria-labelledby": "react-aria7585738573-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-10", + "id": "react-aria7585738573-10", "role": "region", "tabindex": "-1", }, @@ -4121,9 +4121,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-9", + "aria-labelledby": "react-aria7585738573-9", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-10", + "id": "react-aria7585738573-10", "role": "region", "tabindex": "-1", }, @@ -4178,12 +4178,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria5654713355-10", + "aria-controls": "react-aria7585738573-10", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-9", + "id": "react-aria7585738573-9", "role": "button", "tabindex": "0", }, @@ -4803,12 +4803,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria5654713355-4", + "aria-controls": "react-aria7585738573-4", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-3", + "id": "react-aria7585738573-3", "role": "button", "tabindex": "0", }, @@ -5259,9 +5259,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-3", + "aria-labelledby": "react-aria7585738573-3", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-4", + "id": "react-aria7585738573-4", "role": "region", "tabindex": "-1", }, @@ -5359,9 +5359,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-3", + "aria-labelledby": "react-aria7585738573-3", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-4", + "id": "react-aria7585738573-4", "role": "region", "tabindex": "-1", }, @@ -5416,12 +5416,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria5654713355-4", + "aria-controls": "react-aria7585738573-4", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-3", + "id": "react-aria7585738573-3", "role": "button", "tabindex": "0", }, @@ -5905,12 +5905,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria5654713355-6", + "aria-controls": "react-aria7585738573-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-5", + "id": "react-aria7585738573-5", "role": "button", "tabindex": "0", }, @@ -6337,9 +6337,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-5", + "aria-labelledby": "react-aria7585738573-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-6", + "id": "react-aria7585738573-6", "role": "region", "tabindex": "-1", }, @@ -6437,9 +6437,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-5", + "aria-labelledby": "react-aria7585738573-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-6", + "id": "react-aria7585738573-6", "role": "region", "tabindex": "-1", }, @@ -6494,12 +6494,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria5654713355-6", + "aria-controls": "react-aria7585738573-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-5", + "id": "react-aria7585738573-5", "role": "button", "tabindex": "0", }, @@ -6988,12 +6988,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria5654713355-6", + "aria-controls": "react-aria7585738573-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-5", + "id": "react-aria7585738573-5", "role": "button", "tabindex": "0", }, @@ -7420,9 +7420,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-5", + "aria-labelledby": "react-aria7585738573-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-6", + "id": "react-aria7585738573-6", "role": "region", "tabindex": "-1", }, @@ -7520,9 +7520,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-5", + "aria-labelledby": "react-aria7585738573-5", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-6", + "id": "react-aria7585738573-6", "role": "region", "tabindex": "-1", }, @@ -7577,12 +7577,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria5654713355-6", + "aria-controls": "react-aria7585738573-6", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-5", + "id": "react-aria7585738573-5", "role": "button", "tabindex": "0", }, @@ -8044,12 +8044,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria5654713355-4", + "aria-controls": "react-aria7585738573-4", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-3", + "id": "react-aria7585738573-3", "role": "button", "tabindex": "0", }, @@ -8500,9 +8500,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-3", + "aria-labelledby": "react-aria7585738573-3", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-4", + "id": "react-aria7585738573-4", "role": "region", "tabindex": "-1", }, @@ -8600,9 +8600,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-3", + "aria-labelledby": "react-aria7585738573-3", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-4", + "id": "react-aria7585738573-4", "role": "region", "tabindex": "-1", }, @@ -8657,12 +8657,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria5654713355-4", + "aria-controls": "react-aria7585738573-4", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-3", + "id": "react-aria7585738573-3", "role": "button", "tabindex": "0", }, @@ -13249,12 +13249,12 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-controls": "react-aria5654713355-8", + "aria-controls": "react-aria7585738573-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-7", + "id": "react-aria7585738573-7", "role": "button", "tabindex": "0", }, @@ -13553,9 +13553,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-7", + "aria-labelledby": "react-aria7585738573-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-8", + "id": "react-aria7585738573-8", "role": "region", "tabindex": "-1", }, @@ -13653,9 +13653,9 @@ LoadedCheerio { "children": Array [ Node { "attribs": Object { - "aria-labelledby": "react-aria5654713355-7", + "aria-labelledby": "react-aria7585738573-7", "class": "nextui-c-fMAxGR nextui-collapse-content", - "id": "react-aria5654713355-8", + "id": "react-aria7585738573-8", "role": "region", "tabindex": "-1", }, @@ -13710,12 +13710,12 @@ LoadedCheerio { "parent": [Circular], "prev": Node { "attribs": Object { - "aria-controls": "react-aria5654713355-8", + "aria-controls": "react-aria7585738573-8", "aria-disabled": "false", "aria-expanded": "false", "class": "nextui-c-lfcDHB nextui-c-PJLV nextui-c-PJLV-gulvcB-isFocusVisible-false nextui-collapse-view", "data-state": "closed", - "id": "react-aria5654713355-7", + "id": "react-aria7585738573-7", "role": "button", "tabindex": "0", }, diff --git a/packages/react/src/input/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/input/__tests__/__snapshots__/index.test.tsx.snap index 0216291dc6..35f2c9f621 100644 --- a/packages/react/src/input/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/input/__tests__/__snapshots__/index.test.tsx.snap @@ -1,9 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Input should be work with content 1`] = `"

        "`; +exports[`Input should be work with content 1`] = `"
        "`; -exports[`Input should be work with label 1`] = `"
        "`; +exports[`Input should be work with label 1`] = `"
        "`; -exports[`Input should work with different sizes 1`] = `"
        "`; +exports[`Input should work with different sizes 1`] = `"
        "`; -exports[`Input should work with different status 1`] = `"
        "`; +exports[`Input should work with different status 1`] = `"
        "`; diff --git a/packages/react/src/input/__tests__/__snapshots__/password.test.tsx.snap b/packages/react/src/input/__tests__/__snapshots__/password.test.tsx.snap index 68979bda20..2e8b46339c 100644 --- a/packages/react/src/input/__tests__/__snapshots__/password.test.tsx.snap +++ b/packages/react/src/input/__tests__/__snapshots__/password.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`InputPassword should render correctly 1`] = `"
        "`; +exports[`InputPassword should render correctly 1`] = `"
        "`; diff --git a/packages/react/src/table/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/table/__tests__/__snapshots__/index.test.tsx.snap index 8c6dbbe03d..8f7fbb2fe8 100644 --- a/packages/react/src/table/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/table/__tests__/__snapshots__/index.test.tsx.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Table should render a static table correctly with sorting 1`] = `"
        NAMETYPEDATE MODIFIED
        GamesFile folder6/7/2020
        "`; +exports[`Table should render a static table correctly with sorting 1`] = `"
        NAMETYPEDATE MODIFIED
        GamesFile folder6/7/2020
        "`; -exports[`Table should render correctly 1`] = `"
        NAMETYPEDATE MODIFIED
        GamesFile folder6/7/2020
        "`; +exports[`Table should render correctly 1`] = `"
        NAMETYPEDATE MODIFIED
        GamesFile folder6/7/2020
        "`; diff --git a/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap b/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap index e7b4b5e098..0e2309a88f 100644 --- a/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/react/src/textarea/__tests__/__snapshots__/index.test.tsx.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Textarea should render correctly 1`] = `"
        "`; +exports[`Textarea should render correctly 1`] = `"
        "`; -exports[`Textarea should work with different styles 1`] = `"
        "`; +exports[`Textarea should work with different styles 1`] = `"
        "`; diff --git a/packages/react/tests/jest-setup.js b/packages/react/tests/jest-setup.js new file mode 100644 index 0000000000..7b66fe1604 --- /dev/null +++ b/packages/react/tests/jest-setup.js @@ -0,0 +1,6 @@ +// @ts-ignore +const enzyme = require("enzyme"); +const Adapter = require("@wojtekmaj/enzyme-adapter-react-17"); + +enzyme.configure({adapter: new Adapter()}); + diff --git a/packages/react/tests/setup.js b/packages/react/tests/setup.js deleted file mode 100644 index 3c53b62552..0000000000 --- a/packages/react/tests/setup.js +++ /dev/null @@ -1,4 +0,0 @@ -const enzyme = require('enzyme'); -const Adapter = require('@wojtekmaj/enzyme-adapter-react-17'); - -enzyme.configure({ adapter: new Adapter() }); diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index 07870c8d9b..ad5bf117cb 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -1,25 +1,28 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "baseUrl": ".", - "jsx": "react", - "skipLibCheck": true, - "moduleResolution": "node", - "allowJs": true, - "allowSyntheticDefaultImports": true, - "types": ["node", "jest"], - "strict": false, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "resolveJsonModule": true, - "isolatedModules": true, - "target": "es6", - "module": "esnext", - "typeRoots": [ - "../../node_modules/@types", - "./typings" - ] - }, - "include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "next-env.d.ts"], - "exclude": ["node_modules", "storybook-static", "dist", "lib"], -} \ No newline at end of file + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": ".", + "jsx": "react", + "skipLibCheck": true, + "moduleResolution": "node", + "allowJs": true, + "allowSyntheticDefaultImports": true, + "types": ["node", "jest"], + "strict": false, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "resolveJsonModule": true, + "isolatedModules": true, + "target": "es6", + "module": "esnext", + "typeRoots": ["../../node_modules/@types", "./typings"] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + "**/*.js", + "**/*.jsx", + "next-env.d.ts" + ], + "exclude": ["node_modules", "storybook-static", "dist", "lib"] +} diff --git a/yarn.lock b/yarn.lock index 47c2e100b0..309ebe6c9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1274,7 +1274,7 @@ dependencies: regenerator-runtime "^0.13.4" -"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.0", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2": +"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.0", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4": version "7.17.8" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.8.tgz#3e56e4aff81befa55ac3ac6a0967349fd1c5bca2" integrity sha512-dQpEpK0O9o6lj6oPu0gRDbbnk+4LeHlNcBpspf6Olzt3GIX4P1lWF1gS+pHLDFlaJvbR6q7jCfQ08zA4QJBnmA== @@ -5104,21 +5104,6 @@ lz-string "^1.4.4" pretty-format "^27.0.2" -"@testing-library/jest-dom@^5.14.1": - version "5.16.3" - resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.3.tgz#b76851a909586113c20486f1679ffb4d8ec27bfa" - integrity sha512-u5DfKj4wfSt6akfndfu1eG06jsdyA/IUrlX2n3pyq5UXgXMhXY+NJb8eNK/7pqPWAhCKsCGWDdDO0zKMKAYkEA== - dependencies: - "@babel/runtime" "^7.9.2" - "@types/testing-library__jest-dom" "^5.9.1" - aria-query "^5.0.0" - chalk "^3.0.0" - css "^3.0.0" - css.escape "^1.5.1" - dom-accessibility-api "^0.5.6" - lodash "^4.17.15" - redent "^3.0.0" - "@testing-library/react-hooks@^7.0.0": version "7.0.2" resolved "https://registry.yarnpkg.com/@testing-library/react-hooks/-/react-hooks-7.0.2.tgz#3388d07f562d91e7f2431a4a21b5186062ecfee0" @@ -5328,14 +5313,6 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@*": - version "27.4.1" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.4.1.tgz#185cbe2926eaaf9662d340cc02e548ce9e11ab6d" - integrity sha512-23iPJADSmicDVrWk+HT58LMJtzLAnB2AgIzplQuq/bSrGaxCrlvRFjGbXmamnnk/mAmCdLStiGqggu28ocUyiw== - dependencies: - jest-matcher-utils "^27.0.0" - pretty-format "^27.0.0" - "@types/jest@^26.0.22": version "26.0.24" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.24.tgz#943d11976b16739185913a1936e0de0c4a7d595a" @@ -5560,13 +5537,6 @@ resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.8.tgz#b94a4391c85666c7b73299fd3ad79d4faa435310" integrity sha512-ipixuVrh2OdNmauvtT51o3d8z12p6LtFW9in7U79der/kwejjdNchQC5UMn5u/KxNoM7VHHOs/l8KS8uHxhODQ== -"@types/testing-library__jest-dom@^5.9.1": - version "5.14.3" - resolved "https://registry.yarnpkg.com/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.3.tgz#ee6c7ffe9f8595882ee7bda8af33ae7b8789ef17" - integrity sha512-oKZe+Mf4ioWlMuzVBaXQ9WDnEm1+umLx0InILg+yvZVBBDmzV5KfZyLrCvadtWcx8+916jLmHafcmqqffl+iIw== - dependencies: - "@types/jest" "*" - "@types/uglify-js@*": version "3.13.1" resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.13.1.tgz#5e889e9e81e94245c75b6450600e1c5ea2878aea" @@ -7437,14 +7407,6 @@ chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" - integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -8359,20 +8321,6 @@ css-what@^5.0.1, css-what@^5.1.0: resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe" integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw== -css.escape@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/css.escape/-/css.escape-1.5.1.tgz#42e27d4fa04ae32f931a4b4d4191fa9cddee97cb" - integrity sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s= - -css@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/css/-/css-3.0.0.tgz#4447a4d58fdd03367c516ca9f64ae365cee4aa5d" - integrity sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ== - dependencies: - inherits "^2.0.4" - source-map "^0.6.1" - source-map-resolve "^0.6.0" - cssesc@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" @@ -8680,11 +8628,6 @@ diff-sequences@^26.6.2: resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1" integrity sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q== -diff-sequences@^27.5.1: - version "27.5.1" - resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.5.1.tgz#eaecc0d327fd68c8d9672a1e64ab8dccb2ef5327" - integrity sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ== - diff@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" @@ -8737,7 +8680,7 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -dom-accessibility-api@^0.5.6, dom-accessibility-api@^0.5.9: +dom-accessibility-api@^0.5.9: version "0.5.13" resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.13.tgz#102ee5f25eacce09bdf1cfa5a298f86da473be4b" integrity sha512-R305kwb5CcMDIpSHUnLyIAp7SrSPBx6F0VfQFB3M75xVMHhXJJIdePYgbPPh1o57vCHNu5QztokWUPsLjWzFqw== @@ -12184,16 +12127,6 @@ jest-diff@^26.0.0, jest-diff@^26.6.2: jest-get-type "^26.3.0" pretty-format "^26.6.2" -jest-diff@^27.5.1: - version "27.5.1" - resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.5.1.tgz#a07f5011ac9e6643cf8a95a462b7b1ecf6680def" - integrity sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw== - dependencies: - chalk "^4.0.0" - diff-sequences "^27.5.1" - jest-get-type "^27.5.1" - pretty-format "^27.5.1" - jest-docblock@^26.0.0: version "26.0.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-26.0.0.tgz#3e2fa20899fc928cb13bd0ff68bd3711a36889b5" @@ -12242,11 +12175,6 @@ jest-get-type@^26.3.0: resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-26.3.0.tgz#e97dc3c3f53c2b406ca7afaed4493b1d099199e0" integrity sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig== -jest-get-type@^27.5.1: - version "27.5.1" - resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1" - integrity sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw== - jest-haste-map@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-26.6.2.tgz#dd7e60fe7dc0e9f911a23d79c5ff7fb5c2cafeaa" @@ -12310,16 +12238,6 @@ jest-matcher-utils@^26.6.2: jest-get-type "^26.3.0" pretty-format "^26.6.2" -jest-matcher-utils@^27.0.0: - version "27.5.1" - resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz#9c0cdbda8245bc22d2331729d1091308b40cf8ab" - integrity sha512-z2uTx/T6LBaCoNWNFWwChLBKYxTMcGBRjAt+2SbP929/Fflb9aa5LGma654Rz8z9HLxsrUaYzxE9T/EFIL/PAw== - dependencies: - chalk "^4.0.0" - jest-diff "^27.5.1" - jest-get-type "^27.5.1" - pretty-format "^27.5.1" - jest-message-util@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-26.6.2.tgz#58173744ad6fc0506b5d21150b9be56ef001ca07" @@ -15341,7 +15259,7 @@ pretty-format@^26.0.0, pretty-format@^26.6.2: ansi-styles "^4.0.0" react-is "^17.0.1" -pretty-format@^27.0.0, pretty-format@^27.0.2, pretty-format@^27.5.1: +pretty-format@^27.0.2: version "27.5.1" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e" integrity sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ== @@ -17106,14 +17024,6 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-resolve@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2" - integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w== - dependencies: - atob "^2.1.2" - decode-uri-component "^0.2.0" - source-map-support@^0.5.16, source-map-support@^0.5.6, source-map-support@~0.5.12, source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" From dc25a5629be29c598ded3e1971aa4943e8e4c246 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Sat, 9 Jul 2022 16:00:31 -0300 Subject: [PATCH 028/106] feat(react-badge): badge component almost done --- apps/docs/content/components/avatar/icon.ts | 20 +- apps/docs/content/components/badge/a11y.ts | 62 ++++++ .../docs/content/components/badge/bordered.ts | 44 ++++ apps/docs/content/components/badge/colors.ts | 34 +++ .../components/badge/content-offset.ts | 79 +++++++ .../components/badge/content-placements.ts | 60 ++++++ .../content/components/badge/content-shape.ts | 35 ++++ .../components/badge/content-visibility.ts | 115 +++++++++++ apps/docs/content/components/badge/content.ts | 160 +++++++++++++++ apps/docs/content/components/badge/default.ts | 13 ++ .../components/badge/disable-outline.ts | 36 ++++ apps/docs/content/components/badge/dot.ts | 40 ++++ apps/docs/content/components/badge/flat.ts | 44 ++++ apps/docs/content/components/badge/index.ts | 35 ++++ apps/docs/content/components/badge/points.ts | 34 +++ apps/docs/content/components/badge/shadow.ts | 46 +++++ apps/docs/content/components/badge/sizes.ts | 82 ++++++++ apps/docs/content/components/badge/squared.ts | 44 ++++ apps/docs/content/components/button/icon.ts | 32 +-- .../components/collapse/custom-arrow.ts | 18 +- .../components/dropdown/description.ts | 16 +- .../components/dropdown/disable-animation.ts | 16 +- apps/docs/content/components/dropdown/icon.ts | 16 +- .../content/components/dropdown/sections.ts | 16 +- apps/docs/content/components/index.ts | 2 + .../docs/content/components/input/password.ts | 8 +- apps/docs/content/components/switch/icon.ts | 32 +-- .../content/components/table/custom-cells.ts | 18 +- apps/docs/content/docs/components/badge.mdx | 143 +++++++++++++ apps/docs/content/docs/manifest.json | 17 +- apps/docs/src/components/playground/title.tsx | 1 + apps/docs/src/components/sandpack/themes.ts | 4 +- apps/docs/src/styles/sandpack.css | 1 + packages/react/.babelrc.js | 11 +- packages/react/package.json | 1 + packages/react/src/avatar/avatar.styles.ts | 19 +- .../react/src/badge/__tests__/index.test.tsx | 26 ++- packages/react/src/badge/badge.stories.tsx | 194 ++++++++++++++---- packages/react/src/badge/badge.styles.ts | 120 ++++++++--- packages/react/src/badge/badge.tsx | 45 ++-- packages/react/src/badge/index.ts | 7 + .../react/src/css-baseline/css-baseline.tsx | 5 +- packages/react/src/index.ts | 3 + packages/react/src/utils/icons.tsx | 36 ++++ yarn.lock | 5 + 45 files changed, 1539 insertions(+), 256 deletions(-) create mode 100644 apps/docs/content/components/badge/a11y.ts create mode 100644 apps/docs/content/components/badge/bordered.ts create mode 100644 apps/docs/content/components/badge/colors.ts create mode 100644 apps/docs/content/components/badge/content-offset.ts create mode 100644 apps/docs/content/components/badge/content-placements.ts create mode 100644 apps/docs/content/components/badge/content-shape.ts create mode 100644 apps/docs/content/components/badge/content-visibility.ts create mode 100644 apps/docs/content/components/badge/content.ts create mode 100644 apps/docs/content/components/badge/default.ts create mode 100644 apps/docs/content/components/badge/disable-outline.ts create mode 100644 apps/docs/content/components/badge/dot.ts create mode 100644 apps/docs/content/components/badge/flat.ts create mode 100644 apps/docs/content/components/badge/index.ts create mode 100644 apps/docs/content/components/badge/points.ts create mode 100644 apps/docs/content/components/badge/shadow.ts create mode 100644 apps/docs/content/components/badge/sizes.ts create mode 100644 apps/docs/content/components/badge/squared.ts create mode 100644 apps/docs/content/docs/components/badge.mdx diff --git a/apps/docs/content/components/avatar/icon.ts b/apps/docs/content/components/avatar/icon.ts index b39ba13b19..d2a408cd3d 100644 --- a/apps/docs/content/components/avatar/icon.ts +++ b/apps/docs/content/components/avatar/icon.ts @@ -1,6 +1,4 @@ -const SunIcon = `import { React } from '@nextui-org/react';\n - -export const SunIcon = ({ +const SunIcon = `export const SunIcon = ({ fill = "currentColor", filled, size, @@ -60,9 +58,7 @@ export const SunIcon = ({ ); };`; -const MoonIcon = `import { React } from '@nextui-org/react';\n - -export const MoonIcon = ({ +const MoonIcon = `export const MoonIcon = ({ fill = "currentColor", filled, size, @@ -102,9 +98,7 @@ export const MoonIcon = ({ ); };`; -const VideoIcon = `import { React } from '@nextui-org/react';\n - -export const VideoIcon = ({ +const VideoIcon = `export const VideoIcon = ({ fill = "currentColor", filled, size, @@ -145,9 +139,7 @@ export const VideoIcon = ({ ); };`; -const VolumeUpIcon = `import { React } from '@nextui-org/react';\n - -export const VolumeUpIcon = ({ +const VolumeUpIcon = `export const VolumeUpIcon = ({ fill = "currentColor", filled, size, @@ -176,9 +168,7 @@ export const VolumeUpIcon = ({ ); };`; -const MicrophoneIcon = `import { React } from '@nextui-org/react';\n - -export const MicrophoneIcon = ({ +const MicrophoneIcon = `export const MicrophoneIcon = ({ fill = "currentColor", filled, size, diff --git a/apps/docs/content/components/badge/a11y.ts b/apps/docs/content/components/badge/a11y.ts new file mode 100644 index 0000000000..b7953d4430 --- /dev/null +++ b/apps/docs/content/components/badge/a11y.ts @@ -0,0 +1,62 @@ +const NotificationIcon = `export const NotificationIcon = ({ + fill = "currentColor", + size, + height, + width, + ...props +}) => { + return ( + + + + + ); +};`; + +const App = `import { Badge, Grid, styled } from "@nextui-org/react"; +import { CartIcon } from "./CartIcon"; + +const StyledButton = styled("button", { + background: "transparent", + border: "none", + cursor: "pointer", + '&:active': { + opacity: 0.8, + } +}); + +export default function App() { + return ( + + + + + + + + + + ); +}`; + +const react = { + "/App.js": App, + "/NotificationIcon.js": NotificationIcon, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/bordered.ts b/apps/docs/content/components/badge/bordered.ts new file mode 100644 index 0000000000..524897686a --- /dev/null +++ b/apps/docs/content/components/badge/bordered.ts @@ -0,0 +1,44 @@ +const App = `import { Badge, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + Neutral + + + + Primary + + + + + Secondary + + + + + Success + + + + + Warning + + + + + Error + + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/colors.ts b/apps/docs/content/components/badge/colors.ts new file mode 100644 index 0000000000..16ecaa010a --- /dev/null +++ b/apps/docs/content/components/badge/colors.ts @@ -0,0 +1,34 @@ +const App = `import { Badge, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + Neutral + + + Primary + + + Secondary + + + Success + + + Warning + + + Error + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/content-offset.ts b/apps/docs/content/components/badge/content-offset.ts new file mode 100644 index 0000000000..138f9d7c28 --- /dev/null +++ b/apps/docs/content/components/badge/content-offset.ts @@ -0,0 +1,79 @@ +const CheckIcon = `export const CheckIcon = ({ + fill = "currentColor", + size, + height, + width, + ...props +}) => { + return ( + + + + ); +};`; + +const App = `import { Badge, Avatar, Grid } from "@nextui-org/react"; +import { CheckIcon } from "./CheckIcon"; + +export default function App() { + return ( + + + } + css={{ p: "0" }} + horizontalOffset="45%" + verticalOffset="45%" + > + + + + + } + css={{ p: 0 }} + shape="circle" + placement="bottom-right" + horizontalOffset="35%" + verticalOffset="-10%" + size="xs" + > + + + + + ); +}`; + +const react = { + "/App.js": App, + "/CheckIcon.js": CheckIcon, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/content-placements.ts b/apps/docs/content/components/badge/content-placements.ts new file mode 100644 index 0000000000..ca2dbd60ef --- /dev/null +++ b/apps/docs/content/components/badge/content-placements.ts @@ -0,0 +1,60 @@ +const App = `import { Badge, Avatar, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + + + + + + + + + + + + + + + + + + + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/content-shape.ts b/apps/docs/content/components/badge/content-shape.ts new file mode 100644 index 0000000000..beda4a7707 --- /dev/null +++ b/apps/docs/content/components/badge/content-shape.ts @@ -0,0 +1,35 @@ +const App = `import { Badge, Avatar, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + + + + + + + + + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/content-visibility.ts b/apps/docs/content/components/badge/content-visibility.ts new file mode 100644 index 0000000000..4615dc1d5b --- /dev/null +++ b/apps/docs/content/components/badge/content-visibility.ts @@ -0,0 +1,115 @@ +const NotificationIcon = `export const NotificationIcon = ({ + fill = "currentColor", + size, + height, + width, + ...props +}) => { + return ( + + + + + ); +};`; + +const CartIcon = `export const CartIcon = ({ + fill = "currentColor", + size, + height, + width, + ...props +}) => { + return ( + + + + + + + ); +};`; + +const App = `import { Badge, Grid } from "@nextui-org/react"; +import { NotificationIcon } from './NotificationIcon'; +import { CartIcon } from './CartIcon'; + +export default function App() { + const [isInvisible, setIsInvisible] = React.useState(false); + + return ( + + + + + + + + + + + + + + setIsInvisible(!ev.target.checked)} + /> + Show badge + + + + ); +}`; + +const react = { + "/App.js": App, + "/NotificationIcon.js": NotificationIcon, + "/CartIcon.js": CartIcon, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/content.ts b/apps/docs/content/components/badge/content.ts new file mode 100644 index 0000000000..c766109e62 --- /dev/null +++ b/apps/docs/content/components/badge/content.ts @@ -0,0 +1,160 @@ +const CheckIcon = `export const CheckIcon = ({ + fill = "currentColor", + size, + height, + width, + ...props +}) => { + return ( + + + + ); +};`; + +const NotificationIcon = `export const NotificationIcon = ({ + fill = "currentColor", + size, + height, + width, + ...props +}) => { + return ( + + + + + ); +};`; + +const App = `import { Badge, Avatar, Grid } from "@nextui-org/react"; +import { NotificationIcon } from './NotificationIcon" +import { CheckIcon } from "./CheckIcon"; + +export default function App() { + return ( + + + + + + + + + + + + + + + + + + + + + + + } + color="success" + css={{ p: 0 }} + placement="bottom-right" + size="xs" + > + + + + + } + css={{p: "$2"}} + color="error" + placement="top-right" + shape="circle" + size="md" + > + + + + + ); +}`; + +const react = { + "/App.js": App, + "/CheckIcon.js": CheckIcon, + "/NotificationIcon.js": NotificationIcon, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/default.ts b/apps/docs/content/components/badge/default.ts new file mode 100644 index 0000000000..f07f6e7c87 --- /dev/null +++ b/apps/docs/content/components/badge/default.ts @@ -0,0 +1,13 @@ +const App = `import { Badge } from "@nextui-org/react"; + +export default function App() { + return DEFAULT; +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/disable-outline.ts b/apps/docs/content/components/badge/disable-outline.ts new file mode 100644 index 0000000000..8679e37c1f --- /dev/null +++ b/apps/docs/content/components/badge/disable-outline.ts @@ -0,0 +1,36 @@ +const App = `import { Badge, Avatar, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + + + + + + + + + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/dot.ts b/apps/docs/content/components/badge/dot.ts new file mode 100644 index 0000000000..9f1640adf9 --- /dev/null +++ b/apps/docs/content/components/badge/dot.ts @@ -0,0 +1,40 @@ +const App = `import { Badge, Text, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + + Default + + + + Primary + + + + Secondary + + + + Success + + + + Warning + + + + Error + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/flat.ts b/apps/docs/content/components/badge/flat.ts new file mode 100644 index 0000000000..684e023d7c --- /dev/null +++ b/apps/docs/content/components/badge/flat.ts @@ -0,0 +1,44 @@ +const App = `import { Badge, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + Neutral + + + + Primary + + + + + Secondary + + + + + Success + + + + + Warning + + + + + Error + + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/index.ts b/apps/docs/content/components/badge/index.ts new file mode 100644 index 0000000000..d0eec823c1 --- /dev/null +++ b/apps/docs/content/components/badge/index.ts @@ -0,0 +1,35 @@ +import defaultBadge from "./default"; +import sizesBadge from "./sizes"; +import colorsBadge from "./colors"; +import shadowBadge from "./shadow"; +import dotBadge from "./dot"; +import pointsBadge from "./points"; +import borderedBadge from "./bordered"; +import flatBadge from "./flat"; +import squaredBadge from "./squared"; +import contentBadge from "./content"; +import contentPlacementsBadge from "./content-placements"; +import contentShapeBadge from "./content-shape"; +import contentVisibilityBadge from "./content-visibility"; +import contentOffset from "./content-offset"; +import disableOutline from "./disable-outline"; +import a11y from "./a11y"; + +export default { + defaultBadge, + sizesBadge, + colorsBadge, + shadowBadge, + dotBadge, + pointsBadge, + borderedBadge, + flatBadge, + squaredBadge, + contentBadge, + contentPlacementsBadge, + contentShapeBadge, + contentVisibilityBadge, + contentOffset, + disableOutline, + a11y, +}; diff --git a/apps/docs/content/components/badge/points.ts b/apps/docs/content/components/badge/points.ts new file mode 100644 index 0000000000..e2f097d081 --- /dev/null +++ b/apps/docs/content/components/badge/points.ts @@ -0,0 +1,34 @@ +const App = `import { Badge, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + + + + + + + + + + + + + + + + + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/shadow.ts b/apps/docs/content/components/badge/shadow.ts new file mode 100644 index 0000000000..789e9218ec --- /dev/null +++ b/apps/docs/content/components/badge/shadow.ts @@ -0,0 +1,46 @@ +const App = `import { Badge, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + + Neutral + + + + + Primary + + + + + Secondary + + + + + Success + + + + + Warning + + + + + Error + + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/sizes.ts b/apps/docs/content/components/badge/sizes.ts new file mode 100644 index 0000000000..8fb7a76f5c --- /dev/null +++ b/apps/docs/content/components/badge/sizes.ts @@ -0,0 +1,82 @@ +const App = `import { Badge, Avatar, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + + New (xs) + + + New (sm) + + + New (md) + + + New (lg) + + + New (xl) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} +`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/badge/squared.ts b/apps/docs/content/components/badge/squared.ts new file mode 100644 index 0000000000..d13dcc2768 --- /dev/null +++ b/apps/docs/content/components/badge/squared.ts @@ -0,0 +1,44 @@ +const App = `import { Badge, Grid } from "@nextui-org/react"; + +export default function App() { + return ( + + + Neutral + + + + Primary + + + + + Secondary + + + + + Success + + + + + Warning + + + + + Error + + + + ); +}`; + +const react = { + "/App.js": App, +}; + +export default { + ...react, +}; diff --git a/apps/docs/content/components/button/icon.ts b/apps/docs/content/components/button/icon.ts index dfc371635b..e8dc61169b 100644 --- a/apps/docs/content/components/button/icon.ts +++ b/apps/docs/content/components/button/icon.ts @@ -1,6 +1,4 @@ -const HeartIcon = `import { React } from '@nextui-org/react';\n - -export const HeartIcon = ({ +const HeartIcon = `export const HeartIcon = ({ fill = 'currentColor', filled, size, @@ -27,11 +25,9 @@ export const HeartIcon = ({ /> ); -}`; - -const CameraIcon = `import { React } from '@nextui-org/react';\n +};`; -export const CameraIcon = ({ +const CameraIcon = `export const CameraIcon = ({ fill = 'currentColor', filled, size, @@ -57,11 +53,9 @@ export const CameraIcon = ({ /> ); -}`; - -const LockIcon = `import { React } from '@nextui-org/react';\n +};`; -export const LockIcon = ({ +const LockIcon = `export const LockIcon = ({ fill = 'currentColor', filled, size, @@ -99,11 +93,9 @@ export const LockIcon = ({ ); -}`; +};`; -const NotificationIcon = `import { React } from '@nextui-org/react';\n - -export const NotificationIcon = ({ +const NotificationIcon = `export const NotificationIcon = ({ fill = 'currentColor', filled, size, @@ -129,11 +121,9 @@ export const NotificationIcon = ({ /> ); -}`; - -const UserIcon = `import { React } from '@nextui-org/react';\n +};`; -export const UserIcon = ({ +const UserIcon = `export const UserIcon = ({ fill = 'currentColor', filled, size, @@ -172,7 +162,7 @@ export const UserIcon = ({ ); }`; -const AppJs = `import { Button,Spacer } from '@nextui-org/react'; +const AppJs = `import { Button, Spacer } from '@nextui-org/react'; import { HeartIcon } from './HeartIcon'; import { CameraIcon } from './CameraIcon'; import { LockIcon } from './LockIcon'; @@ -212,12 +202,12 @@ export default function App() { }`; const react = { + "/App.js": AppJs, "/HeartIcon.js": HeartIcon, "/CameraIcon.js": CameraIcon, "/LockIcon.js": LockIcon, "/NotificationIcon.js": NotificationIcon, "/UserIcon.js": UserIcon, - "/App.js": AppJs, }; export default { diff --git a/apps/docs/content/components/collapse/custom-arrow.ts b/apps/docs/content/components/collapse/custom-arrow.ts index d872f8abd5..30893e0ea5 100644 --- a/apps/docs/content/components/collapse/custom-arrow.ts +++ b/apps/docs/content/components/collapse/custom-arrow.ts @@ -1,6 +1,4 @@ -const SunIcon = `import { React } from '@nextui-org/react'; - -export const SunIcon = ({ +const SunIcon = `export const SunIcon = ({ fill = 'currentColor', filled, size, @@ -58,11 +56,9 @@ export const SunIcon = ({ > ); -}`; - -const MoonIcon = `import { React } from '@nextui-org/react'; +};`; -export const MoonIcon = ({ +const MoonIcon = `export const MoonIcon = ({ fill = 'currentColor', filled, size, @@ -100,11 +96,9 @@ export const MoonIcon = ({ > ); -}`; - -const AnchorIcon = `import { React } from '@nextui-org/react'; +};`; -export const AnchorIcon = ({ +const AnchorIcon = `export const AnchorIcon = ({ fill = 'currentColor', filled, size, @@ -131,7 +125,7 @@ export const AnchorIcon = ({ > ); -}`; +};`; const AppJs = `import { Collapse,Text,Grid } from '@nextui-org/react'; import { SunIcon } from './SunIcon'; diff --git a/apps/docs/content/components/dropdown/description.ts b/apps/docs/content/components/dropdown/description.ts index f36b53eeb8..d82635e526 100644 --- a/apps/docs/content/components/dropdown/description.ts +++ b/apps/docs/content/components/dropdown/description.ts @@ -1,6 +1,4 @@ -const AddNoteIcon = `import { React } from "@nextui-org/react"; - -export const AddNoteIcon = ({ fill, size, height, width, ...props }) => { +const AddNoteIcon = `export const AddNoteIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const CopyDocumentIcon = `import { React } from "@nextui-org/react"; - -export const CopyDocumentIcon = ({ fill, size, height, width, ...props }) => { +const CopyDocumentIcon = `export const CopyDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const EditDocumentIcon = `import { React } from "@nextui-org/react"; - -export const EditDocumentIcon = ({ fill, size, height, width, ...props }) => { +const EditDocumentIcon = `export const EditDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const DeleteDocumentIcon = `import { React } from "@nextui-org/react"; - -export const DeleteDocumentIcon = ({ fill, size, height, width, ...props }) => { +const DeleteDocumentIcon = `export const DeleteDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { +const AddNoteIcon = `export const AddNoteIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const CopyDocumentIcon = `import { React } from "@nextui-org/react"; - -export const CopyDocumentIcon = ({ fill, size, height, width, ...props }) => { +const CopyDocumentIcon = `export const CopyDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const EditDocumentIcon = `import { React } from "@nextui-org/react"; - -export const EditDocumentIcon = ({ fill, size, height, width, ...props }) => { +const EditDocumentIcon = `export const EditDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const DeleteDocumentIcon = `import { React } from "@nextui-org/react"; - -export const DeleteDocumentIcon = ({ fill, size, height, width, ...props }) => { +const DeleteDocumentIcon = `export const DeleteDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { +const AddNoteIcon = `export const AddNoteIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const CopyDocumentIcon = `import { React } from "@nextui-org/react"; - -export const CopyDocumentIcon = ({ fill, size, height, width, ...props }) => { +const CopyDocumentIcon = `export const CopyDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const EditDocumentIcon = `import { React } from "@nextui-org/react"; - -export const EditDocumentIcon = ({ fill, size, height, width, ...props }) => { +const EditDocumentIcon = `export const EditDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const DeleteDocumentIcon = `import { React } from "@nextui-org/react"; - -export const DeleteDocumentIcon = ({ fill, size, height, width, ...props }) => { +const DeleteDocumentIcon = `export const DeleteDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { +const AddNoteIcon = `export const AddNoteIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const CopyDocumentIcon = `import { React } from "@nextui-org/react"; - -export const CopyDocumentIcon = ({ fill, size, height, width, ...props }) => { +const CopyDocumentIcon = `export const CopyDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const EditDocumentIcon = `import { React } from "@nextui-org/react"; - -export const EditDocumentIcon = ({ fill, size, height, width, ...props }) => { +const EditDocumentIcon = `export const EditDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( { ); };`; -const DeleteDocumentIcon = `import { React } from "@nextui-org/react"; - -export const DeleteDocumentIcon = ({ fill, size, height, width, ...props }) => { +const DeleteDocumentIcon = `export const DeleteDocumentIcon = ({ fill, size, height, width, ...props }) => { return ( = ({ ); };`; -const EditIconTs = `import { React } from '@nextui-org/react';\n -type IconProps = { +const EditIconTs = `type IconProps = { fill?: string; size?: string | number; height?: string | number; @@ -148,8 +146,7 @@ export const EditIcon: React.FC = ({ ); };`; -const DeleteIconTs = `import { React } from '@nextui-org/react';\n -type IconProps = { +const DeleteIconTs = `type IconProps = { fill?: string; size?: string | number; height?: string | number; @@ -211,8 +208,7 @@ export const DeleteIcon: React.FC = ({ ); };`; -const EyeIconJs = `import { React } from '@nextui-org/react';\n -export const EyeIcon = ({ +const EyeIconJs = `export const EyeIcon = ({ fill, size, height, @@ -246,8 +242,7 @@ export const EyeIcon = ({ ); };`; -const EditIconJs = `import { React } from '@nextui-org/react';\n -export const EditIcon = ({ +const EditIconJs = `export const EditIcon = ({ fill, size, height, @@ -291,8 +286,7 @@ export const EditIcon = ({ ); };`; -const DeleteIconJs = `import { React } from '@nextui-org/react';\n -export const DeleteIcon = ({ +const DeleteIconJs = `export const DeleteIcon = ({ fill, size, height, diff --git a/apps/docs/content/docs/components/badge.mdx b/apps/docs/content/docs/components/badge.mdx new file mode 100644 index 0000000000..a8e83a9f1a --- /dev/null +++ b/apps/docs/content/docs/components/badge.mdx @@ -0,0 +1,143 @@ +--- +title: 'Badge' +description: 'Badges are used as a small numerical value or status descriptor for UI elements.' +url: https://nextui.org/docs/components/badge +--- + +# Badge + +Badges are used as a small numerical value or status descriptor for UI elements. + +```jsx +import { Badge } from '@nextui-org/react'; +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +### APIs + + + +#### Badge Props + +| Attribute | Type | Description | Default | +| ----------------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | ------- | +| **children\*** | `ReactNode[]` | The content of the dropdown. It's usually the `Dropdown.Trigger`, `Dropdown.Button` and `Dropdown.Menu`. | - | +| **type** | [TriggerType](#trigger-type) | The type of dropdown menu that the dropdown trigger opens. | `menu` | +| **trigger** | [MenuTriggerType](#menu-trigger-type) | How the dropdown menu is triggered. | `press` | +| **closeOnSelect** | `boolean` | Whether the dropdown menu closes when a selection is made. | `true` | +| **isDisabled** | `boolean` | Whether dropdown trigger is disabled. | `false` | +| **PopoverProps** | [PopoverProps](/docs/components/popover#popover-props) | Since dropdown is based on the `Popover` you can use any of the `Popover` props. | - | + + +--- + + + +### Badge types + + + + diff --git a/apps/docs/content/docs/manifest.json b/apps/docs/content/docs/manifest.json index f86899211e..7333a256a5 100644 --- a/apps/docs/content/docs/manifest.json +++ b/apps/docs/content/docs/manifest.json @@ -34,7 +34,6 @@ "routes": [ { "title": "Default theme", - "updated": true, "path": "/docs/theme/default-theme.mdx" }, { @@ -110,8 +109,7 @@ { "title": "Card", "keywords": "card, content, action, media", - "path": "/docs/components/card.mdx", - "updated": true + "path": "/docs/components/card.mdx" }, { "title": "Pagination", @@ -154,15 +152,13 @@ }, { "title": "Radio", - "updated": true, "keywords": "check, radio, select", "path": "/docs/components/radio.mdx" }, { "title": "Popover", "keywords": "popover, tooltip, tooltip, popover, popover", - "path": "/docs/components/popover.mdx", - "updated": true + "path": "/docs/components/popover.mdx" }, { "title": "Tooltip", @@ -172,14 +168,19 @@ { "title": "Dropdown", "keywords": "dropdown, select, selectable, menu", - "path": "/docs/components/dropdown.mdx", - "newPost": true + "path": "/docs/components/dropdown.mdx" }, { "title": "Progress", "keywords": "progress, bar, task, display, activity", "path": "/docs/components/progress.mdx" }, + { + "title": "Badge", + "keywords": "badge, status, display, count, highlight", + "path": "/docs/components/badge.mdx", + "newPost": true + }, { "title": "Select", "comingSoon": true diff --git a/apps/docs/src/components/playground/title.tsx b/apps/docs/src/components/playground/title.tsx index cff24ba603..9fe5d65f4f 100644 --- a/apps/docs/src/components/playground/title.tsx +++ b/apps/docs/src/components/playground/title.tsx @@ -39,6 +39,7 @@ const Title: React.FC = ({title, desc}) => { } :global(.react-markdown p) { font-size: 1.125rem; + margin-block-start: 1rem; } h3 > :global(code), h3 > :global(pre) { diff --git a/apps/docs/src/components/sandpack/themes.ts b/apps/docs/src/components/sandpack/themes.ts index 14e87b8194..33fe6555a3 100644 --- a/apps/docs/src/components/sandpack/themes.ts +++ b/apps/docs/src/components/sandpack/themes.ts @@ -29,7 +29,7 @@ export const nextuiTheme: SandpackTheme = { typography: { bodyFont: "var(--nextui-fonts-sans)", monoFont: "var(--nextui-fonts-mono)", - fontSize: "14px", - lineHeight: "1.4", + fontSize: "var(--nextui-fontSizes-sm)", + lineHeight: "var(--nextui-lineHeights-sm)", }, }; diff --git a/apps/docs/src/styles/sandpack.css b/apps/docs/src/styles/sandpack.css index 689e0cd37e..5e59b9644a 100644 --- a/apps/docs/src/styles/sandpack.css +++ b/apps/docs/src/styles/sandpack.css @@ -28,6 +28,7 @@ all: initial; font-size: var(--sp-font-size); font-family: var(--sp-font-body); + line-height: var(--nextui-lineHeights-md); display: block; box-sizing: border-box; text-rendering: optimizeLegibility; diff --git a/packages/react/.babelrc.js b/packages/react/.babelrc.js index 58e0c32c79..2247c44e20 100644 --- a/packages/react/.babelrc.js +++ b/packages/react/.babelrc.js @@ -1,6 +1,13 @@ module.exports = (api) => { const env = api.env(); + const removePropsPlugin = [ + "react-remove-properties", + { + properties: ["data-testid"], + }, + ]; + let dev = false; let modules; let plugins; @@ -14,9 +21,9 @@ module.exports = (api) => { modules = false; break; case "dist-prod": - plugins = ["@testing-library/babel-plugin-react"]; + plugins = [removePropsPlugin]; case "production": - plugins = ["@testing-library/babel-plugin-react"]; + plugins = [removePropsPlugin]; case "esm": modules = false; break; diff --git a/packages/react/package.json b/packages/react/package.json index 7026539b6c..e262b9d775 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -116,6 +116,7 @@ "babel-loader": "^8.2.2", "babel-plugin-module-resolver": "^4.1.0", "babel-plugin-optimize-clsx": "^2.6.2", + "babel-plugin-react-remove-properties": "^0.3.0", "babel-plugin-syntax-dynamic-import": "^6.18.0", "chalk": "^4.1.2", "cherry-pick": "^0.5.0", diff --git a/packages/react/src/avatar/avatar.styles.ts b/packages/react/src/avatar/avatar.styles.ts index 97b43a3dc0..cdb67aada4 100644 --- a/packages/react/src/avatar/avatar.styles.ts +++ b/packages/react/src/avatar/avatar.styles.ts @@ -22,9 +22,6 @@ export const StyledAvatar = styled( transition: "$avatar", size: "100%", }, - "&:hover .nextui-avatar-bg": { - boxShadow: " inset 0 0 40px 0 rgb(0 0 0 / 14%)", - }, ".nextui-avatar-img": { opacity: 0, zIndex: "$3", @@ -208,9 +205,6 @@ export const StyledAvatar = styled( }, bordered: { true: { - "&:hover:not(.only-text-avatar) .nextui-avatar-bg": { - opacity: "0.6", - }, ".nextui-avatar-img": { borderStyle: "solid", borderColor: "$background", @@ -225,6 +219,9 @@ export const StyledAvatar = styled( pointer: { true: { cursor: "pointer", + "&:hover .nextui-avatar-bg": { + boxShadow: "inset 0 0 40px 0 rgb(0 0 0 / 14%)", + }, }, }, rounded: { @@ -298,6 +295,16 @@ export const StyledAvatar = styled( }, }, }, + // bordered && pointer + { + bordered: true, + pointer: true, + css: { + "&:hover:not(.only-text-avatar) .nextui-avatar-bg": { + opacity: "0.7", + }, + }, + }, ], defaultVariants: { size: "md", diff --git a/packages/react/src/badge/__tests__/index.test.tsx b/packages/react/src/badge/__tests__/index.test.tsx index 8b58aa8be8..8b4ab5ed66 100644 --- a/packages/react/src/badge/__tests__/index.test.tsx +++ b/packages/react/src/badge/__tests__/index.test.tsx @@ -1,5 +1,6 @@ import React from "react"; -import {render, screen} from "@testing-library/react"; +import {mount} from "enzyme"; +import {render} from "@testing-library/react"; import Badge from "../index"; @@ -10,6 +11,13 @@ describe("Badge", () => { expect(() => wrapper.unmount()).not.toThrow(); }); + it("ref should be forwarded", () => { + const ref = React.createRef(); + const wrapper = mount(action); + + expect(() => wrapper.unmount()).not.toThrow(); + }); + it("should render children and content", () => { const wrapper = render( }> @@ -47,13 +55,13 @@ describe("Badge", () => { expect(wrapper.getAllByTestId("badge-point")).toHaveLength(3); }); - // it("should be invisible if invisible is true", () => { - // const {container} = render( - // } data-testid="badge-root"> - // new - // , - // ); + it("should be invisible if invisible is true", () => { + const wrapper = mount( + } data-testid="badge-root"> + new + , + ); - // expect(container.querySelectorAll(".nextui-badge")[0]).toHaveClass("nextui-badge--invisible"); - // }); + expect(wrapper.find(".nextui-badge--is-invisible").at(0)).toHaveLength(1); + }); }); diff --git a/packages/react/src/badge/badge.stories.tsx b/packages/react/src/badge/badge.stories.tsx index bb46e48de1..9f8c9b5bae 100644 --- a/packages/react/src/badge/badge.stories.tsx +++ b/packages/react/src/badge/badge.stories.tsx @@ -2,7 +2,7 @@ import React from "react"; import {Meta} from "@storybook/react"; import {Col, Row, Spacer, Grid, Avatar, Switch, Text} from "../index"; -import {Notification} from "../utils/icons"; +import {Notification, CartIcon} from "../utils/icons"; import Badge from "./index"; @@ -11,7 +11,7 @@ export default { component: Badge, } as Meta; -export const Default = () => New; +export const Default = () => Default; export const WithAvatar = () => ( @@ -66,23 +66,24 @@ export const WithContentIcon = () => ( ); export const ToggleBadge = () => { - const [invisible, setInvisible] = React.useState(false); + const [isInvisible, setIsInvisible] = React.useState(false); return ( - + + + + + + - setInvisible(!ev.target.checked)} - /> - Show badge + setIsInvisible(!ev.target.checked)} /> + Show badge @@ -94,7 +95,7 @@ export const WithContentPlacements = () => { <> - + { - + { { }; export const Sizes = () => ( - - - New (xs) - - - - New (sm) - - - - New (md) - - - - New (lg) - - - - New (xl) - - - + + + + New (xs) + + + New (sm) + + + New (md) + + + New (lg) + + + New (xl) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); export const Squared = () => ( diff --git a/packages/react/src/badge/badge.styles.ts b/packages/react/src/badge/badge.styles.ts index ba393eec72..9c0892777b 100644 --- a/packages/react/src/badge/badge.styles.ts +++ b/packages/react/src/badge/badge.styles.ts @@ -23,18 +23,17 @@ export const StyledBadgeRoot = styled("span", { export const StyledBadge = styled("span", { $$badgePlacementHOffset: "0%", $$badgePlacementVOffset: "0%", - display: "inline-block", + dflex: "center", whiteSpace: "nowrap", - verticalAlign: "middle", bg: "$$badgeBackgroundColor", color: "$$badgeTextColor", - fontWeight: "$semibold", + fontWeight: "$bold", fontSize: "$$badgeFontSize", - p: "$1 $$badgeHPadding", + p: "$$badgeVPadding $$badgeHPadding", "@motion": { animation: "none", transition: "none", - "&.nextui-badge--invisible": { + "&.nextui-badge--is-invisible": { animation: "none", transition: "none", }, @@ -42,23 +41,28 @@ export const StyledBadge = styled("span", { variants: { size: { xs: { + $$badgeVPadding: "$space$2", $$badgeHPadding: "$space$3", $$badgeFontSize: "0.65rem", }, sm: { + $$badgeVPadding: "$space$2", $$badgeHPadding: "$space$4", - $$badgeFontSize: "$fontSizes$xs", + $$badgeFontSize: "0.7rem", }, md: { - $$badgeHPadding: "$space$4", - $$badgeFontSize: "$fontSizes$sm", + $$badgeVPadding: "$space$2", + $$badgeHPadding: "$space$5", + $$badgeFontSize: "$fontSizes$xs", }, lg: { - $$badgeHPadding: "$space$5", - $$badgeFontSize: "$fontSizes$lg", + $$badgeVPadding: "$space$2", + $$badgeHPadding: "$space$6", + $$badgeFontSize: "$fontSizes$base", }, xl: { - $$badgeHPadding: "$space$5", + $$badgeVPadding: "$space$2", + $$badgeHPadding: "$space$6", $$badgeFontSize: "$fontSizes$xl", }, }, @@ -69,15 +73,11 @@ export const StyledBadge = styled("span", { asChild: { true: { zIndex: "$2", - dflex: "center", position: "absolute", }, }, isOneChar: { - true: { - size: "calc($$badgeFontSize + $$badgeHPadding)", - p: "calc($$badgeHPadding + 1px)", - }, + true: {}, }, color: { neutral: { @@ -127,30 +127,30 @@ export const StyledBadge = styled("span", { placement: { "top-right": { animation: `${appearanceInTopRight} 0.25s ease-out`, - "&.nextui-badge--invisible": { + "&.nextui-badge--is-invisible": { opacity: 0, - animation: `${appearanceOutTopRight} 0.25s ease-in`, + animation: `${appearanceOutTopRight} 0.2s ease-in`, }, }, "top-left": { animation: `${appearanceInTopLeft} 0.25s ease-out`, - "&.nextui-badge--invisible": { + "&.nextui-badge--is-invisible": { opacity: 0, - animation: `${appearanceOutTopLeft} 0.25s ease-in`, + animation: `${appearanceOutTopLeft} 0.2s ease-in`, }, }, "bottom-right": { animation: `${appearanceInBottomRight} 0.25s ease-out`, - "&.nextui-badge--invisible": { + "&.nextui-badge--is-invisible": { opacity: 0, - animation: `${appearanceOutBottomRight} 0.25s ease-in`, + animation: `${appearanceOutBottomRight} 0.2s ease-in`, }, }, "bottom-left": { animation: `${appearanceInBottomLeft} 0.25s ease-out`, - "&.nextui-badge--invisible": { + "&.nextui-badge--is-invisible": { opacity: 0, - animation: `${appearanceOutBottomLeft} 0.25s ease-in`, + animation: `${appearanceOutBottomLeft} 0.2s ease-in`, }, }, }, @@ -202,7 +202,7 @@ export const StyledBadge = styled("span", { true: { animation: "none", transition: "none", - "&.nextui-badge--invisible": { + "&.nextui-badge--is-invisible": { animation: "none", transition: "none", }, @@ -379,8 +379,8 @@ export const StyledBadge = styled("span", { shape: "circle", placement: "top-right", css: { - top: "calc(14% + $$badgePlacementVOffset)", - right: "calc(14% + $$badgePlacementHOffset)", + top: "calc(15% + $$badgePlacementVOffset)", + right: "calc(15% + $$badgePlacementHOffset)", transform: "scale(1) translate(50%, -50%)", transformOrigin: "100% 0%", }, @@ -391,8 +391,8 @@ export const StyledBadge = styled("span", { shape: "circle", placement: "top-left", css: { - top: "calc(14% + $$badgePlacementVOffset)", - left: "calc(14% + $$badgePlacementHOffset)", + top: "calc(15% + $$badgePlacementVOffset)", + left: "calc(15% + $$badgePlacementHOffset)", transform: "scale(1) translate(-50%, -50%)", transformOrigin: "0% 0%", }, @@ -403,8 +403,8 @@ export const StyledBadge = styled("span", { shape: "circle", placement: "bottom-right", css: { - bottom: "calc(14% + $$badgePlacementVOffset)", - right: "calc(14% + $$badgePlacementHOffset)", + bottom: "calc(15% + $$badgePlacementVOffset)", + right: "calc(15% + $$badgePlacementHOffset)", transform: "scale(1) translate(50%, 50%)", transformOrigin: "100% 100%", }, @@ -415,8 +415,8 @@ export const StyledBadge = styled("span", { shape: "circle", placement: "bottom-left", css: { - bottom: "calc(14% + $$badgePlacementVOffset)", - left: "calc(14% + $$badgePlacementHOffset)", + bottom: "calc(15% + $$badgePlacementVOffset)", + left: "calc(15% + $$badgePlacementHOffset)", transform: "scale(1) translate(-50%, 50%)", transformOrigin: "0% 100%", }, @@ -433,9 +433,61 @@ export const StyledBadge = styled("span", { $$badgePlacementVOffset: "calc($$badgeFontSize * 0.1)", }, }, + /** + * @isOneChar {true, false} + * @asChild {true, false} + */ + { + isOneChar: true, + asChild: true, + css: { + p: 0, + size: "calc($$badgeFontSize + $$badgeHPadding)", + }, + }, + { + isOneChar: false, + asChild: true, + css: { + $$badgeVPadding: "0px", + $$badgeHPadding: "$space$2", + }, + }, + /** + * @isOneChar false + * @asChild true + * @size {md, lg, xl} + */ + // size = md + { + isOneChar: false, + asChild: true, + size: "md", + css: { + $$badgeHPadding: "$space$3", + }, + }, + // size = lg + { + isOneChar: false, + asChild: true, + size: "lg", + css: { + $$badgeHPadding: "$space$4", + }, + }, + // size = xl + { + isOneChar: false, + asChild: true, + size: "xl", + css: { + $$badgeHPadding: "$space$5", + }, + }, ], defaultVariants: { - size: "sm", + size: "md", color: "neutral", variant: "default", borderWeight: "normal", diff --git a/packages/react/src/badge/badge.tsx b/packages/react/src/badge/badge.tsx index a02ab0d14c..98b8114e9a 100644 --- a/packages/react/src/badge/badge.tsx +++ b/packages/react/src/badge/badge.tsx @@ -8,10 +8,10 @@ import {__DEV__} from "../utils/assertion"; import {StyledBadge, StyledBadgePoints, StyledBadgeRoot, BadgeVariantsProps} from "./badge.styles"; interface Props extends Omit, keyof BadgeVariantsProps> { - invisible?: boolean; + isInvisible?: boolean; content?: string | number | React.ReactNode; - verticalOffset?: number; - horizontalOffset?: number; + verticalOffset?: string | number; + horizontalOffset?: string | number; children?: React.ReactNode; } @@ -22,7 +22,7 @@ export const Badge = forwardRef((props, ref) => { css, children, content, - invisible = false, + isInvisible = false, disableOutline, placement = "top-right", variant = "default", @@ -37,6 +37,17 @@ export const Badge = forwardRef((props, ref) => { const asChild = content !== undefined && !!children; + const isOneChar = React.useMemo(() => { + if (asChild && content && variant !== "points" && variant !== "dot") { + return String(content)?.length === 1; + } + if (children && typeof children === "string") { + return children.length === 1; + } + + return false; + }, [asChild, children, variant, content]); + const badgeChildren = React.useMemo(() => { if (variant === "dot") { return null; @@ -53,36 +64,28 @@ export const Badge = forwardRef((props, ref) => { } return asChild ? content : children; - }, [variant, asChild, content, children]); - - const isOneChar = React.useMemo(() => { - if (asChild && content && variant !== "points" && variant !== "dot") { - return String(content)?.length === 1; - } - if (children && typeof children === "string") { - return children.length === 1; - } - - return false; - }, [asChild, children, variant, content]); + }, [variant, isOneChar, asChild, content, children]); const badgeCss = React.useMemo(() => { + const isHOffsetNumber = typeof horizontalOffset === "number"; + const isVOffsetNumber = typeof verticalOffset === "number"; + if (verticalOffset && horizontalOffset) { return { - $$badgePlacementHOffset: `${horizontalOffset}px`, - $$badgePlacementVOffset: `${verticalOffset}px`, + $$badgePlacementHOffset: isHOffsetNumber ? `${horizontalOffset}px` : horizontalOffset, + $$badgePlacementVOffset: isVOffsetNumber ? `${verticalOffset}px` : verticalOffset, ...css, }; } if (verticalOffset) { return { - $$badgePlacementVOffset: `${verticalOffset}px`, + $$badgePlacementVOffset: isVOffsetNumber ? `${verticalOffset}px` : verticalOffset, ...css, }; } if (horizontalOffset) { return { - $$badgePlacementHOffset: `${horizontalOffset}px`, + $$badgePlacementHOffset: isHOffsetNumber ? `${horizontalOffset}px` : horizontalOffset, ...css, }; } @@ -96,7 +99,7 @@ export const Badge = forwardRef((props, ref) => {