Skip to content

Commit

Permalink
Merge pull request #14 from cat-crosswalk/SSlime/add-text-tokens
Browse files Browse the repository at this point in the history
テキスト系の値入れたり
  • Loading branch information
SSlime-s authored May 23, 2024
2 parents 5ca30d0 + 0074791 commit 7e3ff46
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 1 deletion.
100 changes: 100 additions & 0 deletions apps/client/app/routes/tokens.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import colors from "@/theme/colors";
import typography from "@/theme/typography";
import { css } from "@emotion/react";
import styled from "@emotion/styled";
import type React from "react";
import { Fragment } from "react";

export default function Tokens() {
return (
<div>
<section>
<Title>Typography</Title>
{Object.entries(typography).map(([key, value]) => {
return (
<div key={key} css={css(value)}>
{key}
</div>
);
})}
</section>
<section>
<Title>Colors</Title>
{Object.entries(colors).map(([key, value]) => {
return (
<section key={key}>
<SubTitle>{key}</SubTitle>
{Object.entries(
// NOTE: なんか Union のまま entries 通すと value が any になっちゃうからキャスト
value as Record<string, Record<string, string>>,
).map(([key, value]) => {
return (
<Grid key={key}>
<GridTitle
style={
{
"--row-span": Object.keys(value).length + 1,
} as React.CSSProperties
}
>
{key}
</GridTitle>
{Object.entries(value).map(([key, value]) => {
return (
<Fragment key={key}>
{key}
<Sample style={{ background: value }} />
</Fragment>
);
})}
</Grid>
);
})}
</section>
);
})}
</section>
</div>
);
}

const Title = styled.h2`
${typography.heading1}
color: ${colors.text.primary.default};
border: 0 solid ${colors.chromatic.blue.default};
border-top-width: 4px;
border-bottom-width: 4px;
padding-top: 1rem;
padding-bottom: 1rem;
`;

const SubTitle = styled.h3`
${typography.heading2}
color: ${colors.text.primary.default};
`;

const Grid = styled.div`
display: grid;
grid-template-columns: 10rem 8rem 8rem;
grid-gap: 1rem;
`;

const GridTitle = styled.div`
${typography.heading4}
color: ${colors.text.primary.default};
grid-row: 1 / span var(--row-span, 1);
`;

const Sample = styled.div`
height: 2rem;
width: 8rem;
box-shadow: 0 0 4px -1px ${colors.text.primary.default};
`;
2 changes: 1 addition & 1 deletion apps/client/app/theme/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
text: {
primary: {
default: "#000000",
disabled: "676767",
disabled: "#676767",
},
secondary: {
default: "rgb(0 0 0 / 0.7)",
Expand Down
72 changes: 72 additions & 0 deletions apps/client/app/theme/typography.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// 値部分をリテラルとして吐いてほしいので https://github.com/microsoft/TypeScript/issues/32063 が解決されるまでは ts ファイルとして置く
// json への移行を簡単にするために、json レベルの記法のみにする

import type { CSSProperties } from "react";

export default {
/**
* font-size: 32px
*/
heading1: {
fontSize: "2rem",
fontWeight: 500,
lineHeight: 1.5,
},
/**
* font-size: 24px
*/
heading2: {
fontSize: "1.5rem",
fontWeight: 500,
lineHeight: 1.5,
},
/**
* font-size: 20px
*/
heading3: {
fontSize: "1.25rem",
fontWeight: 500,
lineHeight: 1.5,
},
/**
* font-size: 18px
*/
heading4: {
fontSize: "1.125rem",
fontWeight: 500,
lineHeight: 1.5,
},
/**
* font-size: 16px
*/
heading5: {
fontSize: "1rem",
fontWeight: 500,
lineHeight: 1.5,
},

/**
* font-size: 18px
*/
body1: {
fontSize: "1.125rem",
fontWeight: 400,
lineHeight: 1.5,
},
/**
* font-size: 16px
*/
body2: {
fontSize: "1rem",
fontWeight: 400,
lineHeight: 1.5,
},
/**
* font-size: 14px
*/
body3: {
fontSize: "0.875rem",
fontWeight: 400,
lineHeight: 1.5,
},
} as const satisfies Record<string, CSSProperties>;

0 comments on commit 7e3ff46

Please sign in to comment.