Skip to content

Commit

Permalink
upgrade tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
8845musign committed Aug 9, 2024
1 parent d8f2b3f commit acb0907
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 279 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"@types/react-dom": "18.2.7",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@ubie/design-tokens": "0.1.4",
"@ubie/prettier-config": "0.1.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react-swc": "^3.6.0",
Expand Down Expand Up @@ -127,7 +126,7 @@
},
"peerDependencies": {
"@headlessui/react": ">1.7.0 <2.0.0",
"@ubie/design-tokens": "^0.0.10 || ^0.1.0",
"@ubie/design-tokens": ">=0.2.0",
"@ubie/ubie-icons": ">=0.5.0 <0.6.2 || >=0.8.0",
"clsx": ">1.2.0",
"react": "^17 || ^18",
Expand Down
31 changes: 1 addition & 30 deletions src/components/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import type {
TextColor,
BodyFontSize,
BodyLeading,
NoteFontSize,
NoteLeading,
WidthProps,
} from '../../types/style';
import type { CSSProperties, FC, ReactNode } from 'react';
Expand Down Expand Up @@ -110,21 +108,6 @@ type PropsWithTextBody = BaseProps & {
textLeading?: BodyLeading;
};

type PropsWithTextNote = BaseProps & {
/**
* 配下に含むテキストの種類
*/
textType: Extract<TextType, 'note'>;
/**
* 配下に含むテキストのフォントサイズの抽象値。合わせてtextTypeの指定が必須で、typeに応じた値が指定可能
*/
textSize?: NoteFontSize;
/**
* 配下に含むテキストの行送りの抽象値(`line-height`)。合わせてtextTypeとtextSizeの指定が必須で、typeに応じた値が指定可能
*/
textLeading?: NoteLeading;
};

/**
* If type is not specified, an empty object is returned because it is unknown how it is to be styled, i.e. it is not styled.
* If type is specified but size or leading is not, specify default values (md or default.)
Expand All @@ -143,11 +126,6 @@ export const textStyleVariables = ({
type: Extract<TextType, 'body'>;
size: BodyFontSize | undefined;
leading: BodyLeading | undefined;
}
| {
type: Extract<TextType, 'note'>;
size: NoteFontSize | undefined;
leading: NoteLeading | undefined;
}): CSSProperties => {
if (type == null) return {};

Expand All @@ -160,11 +138,6 @@ export const textStyleVariables = ({
'--text-size': size ? cssFontSizeToken({ type, size }) : 'inherit',
'--text-leading': leading ? cssLeadingToken({ type, size: size || 'md', leading }) : 'inherit',
} as CSSProperties;
case 'note':
return {
'--text-size': size ? cssFontSizeToken({ type, size }) : 'inherit',
'--text-leading': leading ? cssLeadingToken({ type, size: size || 'md', leading }) : 'inherit',
} as CSSProperties;
default:
// eslint-disable-next-line no-case-declarations
const _: never = type;
Expand All @@ -175,7 +148,7 @@ export const textStyleVariables = ({

const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);

export const Box: FC<PropsWithoutText | PropsWithTextBody | PropsWithTextNote> = ({
export const Box: FC<PropsWithoutText | PropsWithTextBody> = ({
as: BoxComponent = 'div',
children,
p,
Expand Down Expand Up @@ -212,8 +185,6 @@ export const Box: FC<PropsWithoutText | PropsWithTextBody | PropsWithTextNote> =

if (textType === 'body') {
_textVariables = textStyleVariables({ type: textType, size: textSize, leading: textLeading });
} else if (textType === 'note') {
_textVariables = textStyleVariables({ type: textType, size: textSize, leading: textLeading });
}

const width = _width === 'full' ? '100%' : _width;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Button/Button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@

.fixedIcon > * {
width: var(--icon-size);
height: var(--sicon-size);
height: var(--icon-size);
}

.suffixIcon {
Expand All @@ -264,5 +264,5 @@

.suffixIcon > * {
width: var(--icon-size);
height: var(--sicon-size);
height: var(--icon-size);
}
8 changes: 4 additions & 4 deletions src/components/Checkbox/Checkbox.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
}

.label.medium {
font-size: var(--text-body-md-tight-size);
line-height: var(--text-body-md-tight-line);
font-size: var(--text-body-md-size);
line-height: var(--text-body-md-narrow-line);
}

.label.small {
font-size: var(--text-body-sm-tight-size);
line-height: var(--text-body-sm-tight-line);
font-size: var(--text-body-sm-size);
line-height: var(--text-body-sm-narrow-line);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/HelperMessage/HelperMessage.module.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.message {
margin: 0;
font-size: var(--text-note-lg-size);
font-size: var(--text-body-sm-size);
hyphens: auto;
line-height: var(--text-note-lg-tight-line);
line-height: var(--text-body-sm-line);
color: var(--color-text-sub);
overflow-wrap: anywhere;
}
8 changes: 4 additions & 4 deletions src/components/LinkCard/LinkCard.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@
.medium {
--icon-size: 2rem;
--title-font-size: var(--text-heading-xs-line);
--description-font-size: var(--text-note-lg-size);
--description-line-height: var(--text-note-lg-line);
--description-font-size: var(--text-body-sm-size);
--description-line-height: var(--text-body-sm-line);
}

.small {
--icon-size: 1.25rem;
--title-font-size: var(--text-button-md-size);
--description-font-size: var(--text-note-md-size);
--description-line-height: var(--text-note-md-line);
--description-font-size: var(--text-body-xs-size);
--description-line-height: var(--text-body-xs-line);
}
8 changes: 4 additions & 4 deletions src/components/RadioButton/RadioButton.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@
}

.medium .label {
font-size: var(--text-body-md-tight-size);
line-height: var(--text-body-md-tight-line);
font-size: var(--text-body-md-size);
line-height: var(--text-body-md-narrow-line);
}

.small .label {
font-size: var(--text-body-sm-tight-size);
line-height: var(--text-body-sm-tight-line);
font-size: var(--text-body-sm-size);
line-height: var(--text-body-sm-narrow-line);
}
4 changes: 2 additions & 2 deletions src/components/RadioCard/RadioCard.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
box-sizing: border-box;
display: inline-block;
padding: 16px 12px 16px 44px;
font-size: 16px;
font-size: var(--text-body-md-size);
font-weight: bold;
hyphens: auto;
line-height: 23px;
line-height: var(--text-body-md-narrow-line);
color: var(--color-text-main);
overflow-wrap: anywhere;
vertical-align: text-top;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Select/Select.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
width: 100%;
min-height: 54px;
padding: 0 64px 0 16px;
font-size: 16px;
font-size: var(--text-body-md-size);
font-weight: bold;
line-height: 54px;
color: var(--color-text-main);
Expand Down
24 changes: 4 additions & 20 deletions src/components/Text/Text.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ button.text.link:focus-visible {
}

/* font-size */
.body.xs {
--font-size: var(--text-body-xs-size);
}

.body.sm {
--font-size: var(--text-body-sm-size);
}
Expand Down Expand Up @@ -87,18 +91,6 @@ button.text.link:focus-visible {
--font-size: var(--text-heading-xl-size);
}

.note.sm {
--font-size: var(--text-note-sm-size);
}

.note.md {
--font-size: var(--text-note-md-size);
}

.note.lg {
--font-size: var(--text-note-lg-size);
}

.button.sm {
--font-size: var(--text-button-sm-size);
}
Expand All @@ -111,10 +103,6 @@ button.text.link:focus-visible {
--font-size: var(--text-button-lg-size);
}

.tag.sm {
--font-size: var(--text-tag-sm-size);
}

.tag.md {
--font-size: var(--text-tag-md-size);
}
Expand Down Expand Up @@ -151,10 +139,6 @@ button.text.link:focus-visible {
--leading: var(--text-body-md-narrow-line);
}

.tight {
--leading: var(--text-body-md-tight-line);
}

/* color */
.main {
--color: var(--color-text-main);
Expand Down
20 changes: 1 addition & 19 deletions src/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
BodyLeading,
HeadingFontSize,
HeadingLeading,
NoteFontSize,
NoteLeading,
ButtonFontSize,
ButtonLeading,
TagFontSize,
Expand Down Expand Up @@ -88,22 +86,6 @@ type HeadingProps = BaseProps & {
leading?: HeadingLeading;
};

type NoteProps = BaseProps & {
/**
* テキストの種類
*/
type: 'note';
/**
* フォントサイズの抽象値
*/
size?: NoteFontSize;
/**
* 行送りの抽象値(`line-height`)
* @default default
*/
leading?: NoteLeading;
};

type ButtonProps = BaseProps & {
/**
* テキストの種類
Expand Down Expand Up @@ -136,7 +118,7 @@ type TagProps = BaseProps & {
leading?: TagLeading;
};

type TextProps = BodyProps | HeadingProps | NoteProps | ButtonProps | TagProps;
type TextProps = BodyProps | HeadingProps | ButtonProps | TagProps;

function TextInner<T extends ElementType>(
props: {
Expand Down
Loading

0 comments on commit acb0907

Please sign in to comment.