Skip to content

Commit 555123a

Browse files
author
Brijesh Bittu
committed
Refactor theme and use lightning css
1 parent 32f5c5d commit 555123a

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

docs/next.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const nextConfig: NextConfig = {
3232
experimental: {
3333
esmExternals: true,
3434
workerThreads: false,
35+
useLightningcss: true,
3536
},
3637
};
3738

docs/src/theme.ts

+2-18
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ const THEME = {
9191
},
9292
breakpoint: {
9393
maxLayoutWidth: '89rem',
94-
showQuickNav: '84rem',
95-
showSideNav: '64rem',
94+
showQuickNav: BREAKPOINTS.quickNav,
95+
showSideNav: BREAKPOINTS.lg,
9696
},
9797
ease: {
9898
out: {
@@ -113,22 +113,6 @@ const THEME = {
113113
'4xl': '2rem',
114114
},
115115
$$breakpoints: BREAKPOINT_UTILS,
116-
$$utils: {
117-
apply(key: string, value: unknown) {
118-
const ctx = this as unknown as Theme;
119-
// @ts-expect-error Not typing explicitly to avoid circular typing
120-
const val = ctx[key][value] as Theme['text']['md'];
121-
return {
122-
fontSize: val.default,
123-
lineHeight: val.lineHeight,
124-
letterSpacing: val.letterSpacing,
125-
};
126-
},
127-
spacing(number: string | number) {
128-
const ctx = this as unknown as Theme;
129-
return `calc(${ctx.spacing} * ${number})`;
130-
},
131-
},
132116
};
133117

134118
export type Theme = typeof THEME;

docs/src/utils/theme.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import type { Theme } from '@pigment-css/theme';
22

33
export function applyText(theme: Theme, value: keyof Theme['text']) {
4-
return theme.$$utils.apply.call(theme, 'text', value);
4+
const val = theme.text[value];
5+
return {
6+
fontSize: val.default,
7+
lineHeight: val.lineHeight,
8+
letterSpacing: val.letterSpacing,
9+
};
510
}
611

712
export function spacing(theme: Theme, space: number | string) {
8-
return theme.$$utils.spacing.call(theme, space);
13+
return `calc(${theme.spacing} * ${space})`;
914
}

0 commit comments

Comments
 (0)