Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minify styled-components css #1544

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export default defineConfig({
noImplicitBrowsersList: 'off',
},
tsconfig: 'tsconfig.dist.json',
babel: {reactCompiler: true},
babel: {reactCompiler: true, styledComponents: true},
reactCompilerOptions: {target: '18'},
})
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sanity/ui",
"version": "2.10.17",
"version": "2.10.18-canary.0",
"keywords": [
"sanity",
"ui",
Expand Down Expand Up @@ -122,7 +122,7 @@
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
"@juggle/resize-observer": "^3.4.0",
"@sanity/pkg-utils": "^6.12.3",
"@sanity/pkg-utils": "^6.13.0",
"@sanity/prettier-config": "^1.0.3",
"@sanity/semantic-release-preset": "^5.0.0",
"@sanity/ui-workshop": "^2.0.20",
Expand Down Expand Up @@ -155,6 +155,7 @@
"@typescript-eslint/parser": "^7.18.0",
"@vitejs/plugin-react": "^4.3.4",
"babel-plugin-react-compiler": "19.0.0-beta-55955c9-20241229",
"babel-plugin-styled-components": "^2.1.4",
"commitizen": "^4.3.1",
"cypress": "^13.17.0",
"cypress-real-events": "^1.13.0",
Expand Down
30 changes: 25 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core/components/autocomplete/autocomplete.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Box} from '../../primitives'
/**
* @internal
*/
export const Root = styled.div`
export const StyledAutocomplete = styled.div`
line-height: 0;
`

Expand Down
6 changes: 3 additions & 3 deletions src/core/components/autocomplete/autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
TextInput,
} from '../../primitives'
import {Radius} from '../../types'
import {AnimatedSpinnerIcon, ListBox, Root} from './autocomplete.styles'
import {AnimatedSpinnerIcon, ListBox, StyledAutocomplete} from './autocomplete.styles'
import {AutocompleteOption} from './autocompleteOption'
import {autocompleteReducer} from './autocompleteReducer'
import {
Expand Down Expand Up @@ -97,7 +97,7 @@
const DEFAULT_FILTER_OPTION = (query: string, option: BaseAutocompleteOption) =>
option.value.toLowerCase().indexOf(query.toLowerCase()) > -1

const InnerAutocomplete = forwardRef(function InnerAutocomplete<

Check warning on line 100 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:639:24)

Check warning on line 100 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:636:8)

Check warning on line 100 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:643:8)

Check warning on line 100 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:666:26)
Option extends BaseAutocompleteOption,
>(
props: AutocompleteProps<Option> &
Expand Down Expand Up @@ -633,14 +633,14 @@
const results = useMemo(() => {
if (renderPopover) {
return renderPopover(
{

Check warning on line 636 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
content,
hidden: !expanded,
inputElement: inputElementRef.current,

Check warning on line 639 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
onMouseEnter: handlePopoverMouseEnter,
onMouseLeave: handlePopoverMouseLeave,
},
resultsPopoverElementRef,

Check warning on line 643 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
)
}

Expand All @@ -663,7 +663,7 @@
portal
radius={radius}
ref={resultsPopoverElementRef}
referenceElement={inputElementRef.current}

Check warning on line 666 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
{...popover}
/>
)
Expand All @@ -679,7 +679,7 @@
])

return (
<Root
<StyledAutocomplete
data-ui="Autocomplete"
onBlur={handleRootBlur}
onFocus={handleRootFocus}
Expand All @@ -688,7 +688,7 @@
>
{input}
{results}
</Root>
</StyledAutocomplete>
)
})

Expand Down
2 changes: 1 addition & 1 deletion src/core/components/breadcrumbs/breadcrumbs.styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {styled} from 'styled-components'
import {Button} from '../../primitives'

export const Root = styled.ol`
export const StyledBreadcrumbs = styled.ol`
margin: 0;
padding: 0;
display: flex;
Expand Down
6 changes: 3 additions & 3 deletions src/core/components/breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
} from 'react'
import {useArrayProp, useClickOutsideEvent} from '../../hooks'
import {Box, Popover, Stack, Text} from '../../primitives'
import {ExpandButton, Root} from './breadcrumbs.styles'
import {ExpandButton, StyledBreadcrumbs} from './breadcrumbs.styles'

/**
* @beta
Expand All @@ -24,7 +24,7 @@
/**
* @beta
*/
export const Breadcrumbs = forwardRef(function Breadcrumbs(

Check warning on line 27 in src/core/components/breadcrumbs/breadcrumbs.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output. (@:42:19)

Check warning on line 27 in src/core/components/breadcrumbs/breadcrumbs.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly (@:81:41)
props: BreadcrumbsProps & Omit<React.HTMLProps<HTMLOListElement>, 'as' | 'ref' | 'type'>,
ref: React.ForwardedRef<HTMLOListElement>,
) {
Expand Down Expand Up @@ -81,7 +81,7 @@
}, [collapse, expand, maxLength, open, rawItems, space])

return (
<Root data-ui="Breadcrumbs" {...restProps} ref={ref}>
<StyledBreadcrumbs data-ui="Breadcrumbs" {...restProps} ref={ref}>
{items.map((item, itemIndex) => (
<Fragment key={itemIndex}>
{itemIndex > 0 && (
Expand All @@ -92,7 +92,7 @@
<Box as="li">{item}</Box>
</Fragment>
))}
</Root>
</StyledBreadcrumbs>
)
})
Breadcrumbs.displayName = 'ForwardRef(Breadcrumbs)'
6 changes: 3 additions & 3 deletions src/core/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function isTargetWithinScope(
)
}

const Root = styled(Layer)<
const StyledDialog = styled(Layer)<
ResponsiveDialogPositionStyleProps & ResponsivePaddingStyleProps & AnimationDialogStyleProps
>(responsivePaddingStyle, dialogStyle, responsiveDialogPositionStyle, animationDialogStyle)

Expand Down Expand Up @@ -388,7 +388,7 @@ export const Dialog = forwardRef(function Dialog(

return (
<Portal __unstable_name={portalProp}>
<Root
<StyledDialog
{...restProps}
$animate={animate}
$padding={padding}
Expand Down Expand Up @@ -424,7 +424,7 @@ export const Dialog = forwardRef(function Dialog(
{children}
</DialogCard>
<div ref={postDivRef} tabIndex={0} />
</Root>
</StyledDialog>
</Portal>
)
})
Expand Down
6 changes: 3 additions & 3 deletions src/core/components/hotkeys/hotkeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface HotkeysProps {
keys?: string[]
}

const Root = styled.kbd`
const StyledHotkeys = styled.kbd`
font: inherit;
padding: 1px;

Expand Down Expand Up @@ -47,15 +47,15 @@ export const Hotkeys = forwardRef(function Hotkeys(
}

return (
<Root data-ui="Hotkeys" {...restProps} ref={ref}>
<StyledHotkeys data-ui="Hotkeys" {...restProps} ref={ref}>
<Inline as="span" space={space}>
{keys.map((key, i) => (
<Key fontSize={fontSize} key={i} padding={padding} radius={radius}>
{key}
</Key>
))}
</Inline>
</Root>
</StyledHotkeys>
)
})
Hotkeys.displayName = 'ForwardRef(Hotkeys)'
6 changes: 3 additions & 3 deletions src/core/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface MenuProps extends ResponsivePaddingProps {
'onBlurCapture'?: (event: FocusEvent) => void
}

const Root = styled(Box)`
const StyledMenu = styled(Box)`
outline: none;
overflow: auto;
`
Expand Down Expand Up @@ -159,7 +159,7 @@ export const Menu = forwardRef(function Menu(

return (
<MenuContext.Provider value={value}>
<Root
<StyledMenu
data-ui="Menu"
{...restProps}
onKeyDown={handleKeyDown}
Expand All @@ -169,7 +169,7 @@ export const Menu = forwardRef(function Menu(
tabIndex={-1}
>
<Stack space={space}>{children}</Stack>
</Root>
</StyledMenu>
</MenuContext.Provider>
)
})
Expand Down
9 changes: 4 additions & 5 deletions src/core/components/skeleton/skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import {BoxProps, ResponsiveRadiusProps} from '../../primitives'
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
import {skeletonStyle} from './styles'

const Root = styled(Box)<{$animated: boolean; $visible: boolean} & ResponsiveRadiusStyleProps>(
responsiveRadiusStyle,
skeletonStyle,
)
const StyledSkeleton = styled(Box)<
{$animated: boolean; $visible: boolean} & ResponsiveRadiusStyleProps
>(responsiveRadiusStyle, skeletonStyle)

/**
* This API might change. DO NOT USE IN PRODUCTION.
Expand Down Expand Up @@ -46,7 +45,7 @@ export const Skeleton = forwardRef(function Skeleton(
}, [delay])

return (
<Root
<StyledSkeleton
{...restProps}
$animated={animated}
$radius={useArrayProp(radius)}
Expand Down
10 changes: 5 additions & 5 deletions src/core/components/skeleton/textSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {useArrayProp} from '../../hooks'
import {ThemeProps, _responsive} from '../../styles'
import {Skeleton, SkeletonProps} from './skeleton'

const Root = styled(Skeleton)<{$size: number[]; $style: ThemeFontKey}>((
const StyledSkeleton = styled(Skeleton)<{$size: number[]; $style: ThemeFontKey}>((
props: {
$size: number[]
$style: ThemeFontKey
Expand Down Expand Up @@ -69,7 +69,7 @@ export const TextSkeleton = forwardRef(function TextSkeleton(
const {size = 2, ...restProps} = props
const $size = useArrayProp(size)

return <Root {...restProps} $size={$size} ref={ref} $style="text" />
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="text" />
})
TextSkeleton.displayName = 'ForwardRef(TextSkeleton)'

Expand All @@ -85,7 +85,7 @@ export const LabelSkeleton = forwardRef(function TextSkeleton(
const {size = 2, ...restProps} = props
const $size = useArrayProp(size)

return <Root {...restProps} $size={$size} ref={ref} $style="label" />
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="label" />
})
LabelSkeleton.displayName = 'ForwardRef(LabelSkeleton)'

Expand All @@ -101,7 +101,7 @@ export const HeadingSkeleton = forwardRef(function TextSkeleton(
const {size = 2, ...restProps} = props
const $size = useArrayProp(size)

return <Root {...restProps} $size={$size} ref={ref} $style="heading" />
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="heading" />
})
HeadingSkeleton.displayName = 'ForwardRef(HeadingSkeleton)'

Expand All @@ -117,6 +117,6 @@ export const CodeSkeleton = forwardRef(function TextSkeleton(
const {size = 2, ...restProps} = props
const $size = useArrayProp(size)

return <Root {...restProps} $size={$size} ref={ref} $style="code" />
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="code" />
})
CodeSkeleton.displayName = 'ForwardRef(CodeSkeleton)'
6 changes: 3 additions & 3 deletions src/core/components/toast/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ROLES = {
info: 'alert',
} as const

const Root = styled(Card)<{$duration?: number; tone: ThemeColorStateToneKey} & ThemeProps>(
const StyledToast = styled(Card)<{$duration?: number; tone: ThemeColorStateToneKey} & ThemeProps>(
rootStyles,
)

Expand All @@ -60,7 +60,7 @@ export function Toast(
const role = status ? ROLES[status] : 'status'

return (
<Root
<StyledToast
data-ui="Toast"
role={role}
{...restProps}
Expand Down Expand Up @@ -100,7 +100,7 @@ export function Toast(
</Box>
)}
</Flex>
</Root>
</StyledToast>
)
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/components/toast/toastProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface ToastProviderProps {
zOffset?: number | number[]
}

const Root = styled(Layer)`
const StyledToastProvider = styled(Layer)`
position: fixed;
top: 0;
left: 0;
Expand Down Expand Up @@ -153,7 +153,7 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement<any
<ToastContext.Provider value={value}>
{children}
{mounted && (
<Root data-ui="ToastProvider" zOffset={zOffset}>
<StyledToastProvider data-ui="ToastProvider" zOffset={zOffset}>
<ToastContainer>
<Box padding={padding} paddingX={paddingX} paddingY={paddingY}>
<AnimatePresence initial={false}>
Expand Down Expand Up @@ -184,7 +184,7 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement<any
</AnimatePresence>
</Box>
</ToastContainer>
</Root>
</StyledToastProvider>
)}
</ToastContext.Provider>
)
Expand Down
Loading
Loading