Skip to content

Commit

Permalink
fix: augmentation of preset default and web sandbox react types
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroerta committed Nov 8, 2021
1 parent 671b760 commit 8d58426
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 74 deletions.
2 changes: 0 additions & 2 deletions apps/web-sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"@testing-library/user-event": "^12.8.3",
"@types/jest": "^26.0.22",
"@types/node": "^12.20.10",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"react-scripts": "4.0.3",
"typescript": "^4.2.4",
"web-vitals": "^1.1.1"
Expand Down
1 change: 1 addition & 0 deletions apps/web-sandbox/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function App() {
codeStyle: {
display: 'block',
py: 's',
color: 'primary.dark',
},
});

Expand Down
2 changes: 1 addition & 1 deletion apps/web-sandbox/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ loadFont({
url: 'https://fonts.googleapis.com/css2?family=Roboto:wght@400&display=swap',
},
],
name: 'regular',
name: 'default',
family: 'Roboto',
});

Expand Down
16 changes: 8 additions & 8 deletions apps/web-sandbox/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ export const components = {
Button: {
tag: 'button',
style: {
transition: 'slow',
height: '2xl',
width: '2xl',
transition: 'fast',
size: '2xl',
bg: 'primary',
color: 'white',
borderRadius: 'm',
border: 'primary',
border: 'strong',
'&:hover': {
bg: 'transparent',
color: 'primary',
Expand All @@ -34,6 +33,7 @@ export const components = {
'&:hover': {
bg: 'transparent',
color: 'primary',
borderColor: 'primary',
},
},
},
Expand Down Expand Up @@ -64,19 +64,19 @@ export const components = {
variants: {
h1: {
tag: 'h1',
style: { color: 'headTextColor' },
style: { color: 'headText' },
},
h2: {
tag: 'h1',
style: { color: 'headTextColor' },
style: { color: 'headText' },
},
h3: {
tag: 'h3',
style: { color: 'headTextColor' },
style: { color: 'headText' },
},
code: {
tag: 'pre',
style: { color: 'textColor' },
style: { color: 'text' },
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"@testing-library/react": "^11.2.6",
"@testing-library/react-hooks": "^5.1.1",
"@types/jest": "^26.0.21",
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.2",
"@types/react-test-renderer": "^17.0.1",
"@types/styled-components": "^5.1.9",
"@typescript-eslint/eslint-plugin": "^4.18.0",
Expand Down
37 changes: 0 additions & 37 deletions packages/preset-default/src/base/baseTheme.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/preset-default/src/base/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ export const lightColors = {
headText: '#000000',
invertedHeadText: '#ffffff',
};

type LocalColors = typeof lightColors & typeof darkColors;

declare module '@morfeo/spec' {
export interface Colors extends LocalColors {}
}
6 changes: 0 additions & 6 deletions packages/preset-default/src/base/fontSizes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@ export const fontSizes = {
'4xl': '7rem',
none: '0',
};

type LocalFontSizes = typeof fontSizes;

declare module '@morfeo/spec' {
export interface FontSizes extends LocalFontSizes {}
}
50 changes: 49 additions & 1 deletion packages/preset-default/src/base/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
import { baseTheme } from './baseTheme';
import { Theme } from '@morfeo/spec';
import { borderStyles } from './borderStyles';
import { borderWidths } from './borderWidths';
import { borders } from './borders';
import { breakpoints } from './breakpoints';
import { fontSizes } from './fontSizes';
import { fontWeights } from './fontWeights';
import { gradients } from './gradients';
import { letterSpacings } from './letterSpacings';
import { lineHeights } from './lineHeights';
import { opacities } from './opacities';
import { radii } from './radii';
import { shadows } from './shadows';
import { sizes } from './sizes';
import { spacings } from './spacings';
import { transitions } from './transitions';
import { zIndices } from './zIndices';
import { darkColors, lightColors } from './colors';

export const baseTheme: Omit<Theme, 'components' | 'fonts' | 'colors'> = {
borderStyles,
borderWidths,
borders,
breakpoints,
fontSizes,
fontWeights,
gradients,
letterSpacings,
lineHeights,
opacities,
radii,
shadows,
sizes,
spacings,
transitions,
zIndices,
mediaQueries: {},
};

export const darkTheme = {
...baseTheme,
colors: darkColors,
Expand All @@ -10,3 +46,15 @@ export const lightTheme = {
...baseTheme,
colors: lightColors,
};

type LocalColors = typeof lightColors & typeof darkColors;
type LocalSizes = typeof sizes;
type LocalFontSizes = typeof fontSizes;
type LocalSpacings = typeof spacings;

declare module '@morfeo/spec' {
export interface Sizes extends LocalSizes {}
export interface Colors extends LocalColors {}
export interface Spacings extends LocalSpacings {}
export interface FontSizes extends LocalFontSizes {}
}
7 changes: 0 additions & 7 deletions packages/preset-default/src/base/sizes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,3 @@ export const sizes = {
'100vw': '100vw',
none: '0px',
};

type LocalSizes = typeof sizes;

declare module '@morfeo/spec' {
export interface Sizes extends LocalSizes {}
}

6 changes: 0 additions & 6 deletions packages/preset-default/src/base/spacings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,3 @@ export const spacings = {
'4xl': '5rem',
'5xl': '6rem',
};

type LocalSpacings = typeof spacings;

declare module '@morfeo/spec' {
export interface Spacings extends LocalSpacings {}
}

0 comments on commit 8d58426

Please sign in to comment.