Skip to content

Commit

Permalink
add fonts to Theme (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitQ2019 authored Nov 18, 2020
1 parent 8fbf53d commit 74790de
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/web-server/src/styletron-react/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ const wrapper: StyletronWrapper = (StyledComponent) =>
export interface StyledFn {
<
C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
// eslint-disable-next-line @typescript-eslint/ban-types
P extends object
P extends Record<string, unknown>
>(
component: C,
style: (props: P & { $theme: Theme }) => StyleObject
Expand Down
22 changes: 22 additions & 0 deletions packages/web-server/src/styletron-react/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ export const THEME = {
nav03: "var(--nav03)",
},
sizing: ["2px", "6px", "10px", "16px", "24px", "32px"],
fonts: [
{
fontSize: "12px",
lineHeight: "20px",
},
{
fontSize: "14px",
lineHeight: "22px",
},
{
fontSize: "16px",
lineHeight: "24px",
},
{
fontSize: "20px",
lineHeight: "28px",
},
{
fontSize: "24px",
lineHeight: "32px",
},
],
};

const { Provider, Consumer } = React.createContext<Theme>(THEME);
Expand Down
8 changes: 8 additions & 0 deletions packages/web-server/src/styletron-react/theme-types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
type Font = {
fontSize: string | number;
lineHeight: string | number;
fontFamily?: string;
letterSpacing?: string | number;
};

export type Theme = {
colors: {
primary: string;
Expand Down Expand Up @@ -26,4 +33,5 @@ export type Theme = {
nav03: string; // Global footer
};
sizing: Array<string>;
fonts: Array<Font>;
};

0 comments on commit 74790de

Please sign in to comment.