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

Style engine: refine Box type #38894

Merged
merged 2 commits into from
Feb 21, 2022
Merged
Changes from 1 commit
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
Next Next commit
Style engine: refine Box type
  • Loading branch information
ciampo committed Feb 21, 2022
commit 8626cda53de1653ea6252cf08667cc9fb7ea1a13
15 changes: 8 additions & 7 deletions packages/style-engine/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
*/
import type { CSSProperties } from 'react';

export type Box = {
top?: CSSProperties[ 'top' ];
right?: CSSProperties[ 'right' ];
bottom?: CSSProperties[ 'bottom' ];
left?: CSSProperties[ 'left' ];
type BoxVariants = 'margin' | 'padding';
export type Box< T extends BoxVariants = 'margin' > = {
top?: CSSProperties[ `${ T }Top` ];
right?: CSSProperties[ `${ T }Right` ];
bottom?: CSSProperties[ `${ T }Bottom` ];
left?: CSSProperties[ `${ T }Left` ];
};

export interface Style {
spacing?: {
margin?: CSSProperties[ 'margin' ] | Box;
padding?: CSSProperties[ 'padding' ] | Box;
margin?: CSSProperties[ 'margin' ] | Box< 'margin' >;
padding?: CSSProperties[ 'padding' ] | Box< 'padding' >;
};
typography?: {
fontSize?: CSSProperties[ 'fontSize' ];
Expand Down