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

Try: Add CSS Custom Properties to CSS types #61872

Merged
merged 2 commits into from
May 22, 2024
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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Internal

- Add type support for CSS Custom Properties ([#61872](https://github.com/WordPress/gutenberg/pull/61872)).
- Remove usage of deprecated spreading of `key` prop in JSX in CustomSelectControl and FormTokenField components ([#61692](https://github.com/WordPress/gutenberg/pull/61692)).
- Tooltip: Fix Ariakit tooltip store usage ([#61858](https://github.com/WordPress/gutenberg/pull/61858)).

Expand Down
13 changes: 5 additions & 8 deletions packages/components/src/color-palette/stories/index.story.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import type { CSSProperties } from 'react';
import type { Meta, StoryFn } from '@storybook/react';

/**
Expand Down Expand Up @@ -92,13 +91,11 @@ MultipleOrigins.args = {
export const CSSVariables: StoryFn< typeof ColorPalette > = ( args ) => {
return (
<div
style={
{
'--red': '#f00',
'--yellow': '#ff0',
'--blue': '#00f',
} as CSSProperties
}
style={ {
'--red': '#f00',
'--yellow': '#ff0',
'--blue': '#00f',
} }
>
<Template { ...args } />
</div>
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/css.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type * as CSS from 'csstype';

// See: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/f6d4d15522356eba4a0267142834e3abc6b603fc/types/react/index.d.ts#L2580-L2587
declare module 'csstype' {
interface Properties {
// Allow any CSS Custom Properties
[ index: `--${ string }` ]: any;
}
}
14 changes: 6 additions & 8 deletions packages/components/src/progress-bar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import type { CSSProperties, ForwardedRef } from 'react';
import type { ForwardedRef } from 'react';

/**
* WordPress dependencies
Expand All @@ -26,13 +26,11 @@ function UnforwardedProgressBar(
return (
<ProgressBarStyled.Track className={ className }>
<ProgressBarStyled.Indicator
style={
{
'--indicator-width': ! isIndeterminate
? `${ value }%`
: undefined,
} as CSSProperties
}
style={ {
'--indicator-width': ! isIndeterminate
? `${ value }%`
: undefined,
} }
isIndeterminate={ isIndeterminate }
/>
<ProgressBarStyled.ProgressElement
Expand Down
Loading