-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for SCSS output in bezier-tokens (#2568)
<!-- How to write a good PR title: - Follow [the Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ## Self Checklist - [x] I wrote a PR title in **English** and added an appropriate **label** to the PR. - [x] I wrote the commit message in **English** and to follow [**the Conventional Commits specification**](https://www.conventionalcommits.org/en/v1.0.0/). - [x] I [added the **changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) about the changes that needed to be released. (or didn't have to) - [x] I wrote or updated **documentation** related to the changes. (or didn't have to) - [x] I wrote or updated **tests** related to the changes. (or didn't have to) - [x] I tested the changes in various browsers. (or didn't have to) - Windows: Chrome, Edge, (Optional) Firefox - macOS: Chrome, Edge, Safari, (Optional) Firefox ## Related Issue <!-- Please link to issue if one exists --> <!-- Fixes #0000 --> ## Summary <!-- Please brief explanation of the changes made --> bezier-tokens에서 scss 파일을 내보냅니다. ## Details <!-- Please elaborate description of the changes --> - 일부 유틸 클래스를 만드는 CSS 모듈에서 토큰에 대한 종류를 모두 알고있어야하는 불편함이 있었습니다. 이번에 #2566 PR 작업을 진행하면서 동일한 작업이 반복되는걸 느껴 이를 함께 수정합니다. - bezier-tokens에서 [map-deep](https://styledictionary.com/reference/hooks/formats/predefined/#scssmap-deep) 포맷으로 scss output을 만들도록 합니다. 자바스크립트 케이스처럼 `index.scss` 를 만드는 과정을 추가했습니다. - bezier-token의 `sideEffects` 필드에 scss 파일을 추가합니다. - scss의 `pkg:` Importer 규칙에 따라 bezier-tokens의 conditional export field를 수정했습니다. bezier-react에선 storybook & build 과정 모두 상대 경로로 지정하는 게 잘 동작해서 pkg 프로토콜은 이 PR에서 사용하지 않았습니다 (시간이 좀 더 걸릴듯함) ### Breaking change? (Yes/No) <!-- If Yes, please describe the impact and migration path for users --> No - ev-inner, ev-base 에 대한 유틸 클래스가 추가로 생기지만 사용처 영향은 없습니다 (매우 미미한 스타일 시트 파일 크기 상승) ## References <!-- Please list any other resources or points the reviewer should be aware of --> - https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/ - https://webpack.kr/guides/tree-shaking/
- Loading branch information
1 parent
bc4319e
commit d89ac74
Showing
9 changed files
with
121 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@channel.io/bezier-tokens': minor | ||
--- | ||
|
||
Add SCSS support to access design tokens directly through SCSS variables. |
5 changes: 3 additions & 2 deletions
5
packages/bezier-react/src/styles/components/elevation.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 3 additions & 13 deletions
16
packages/bezier-react/src/styles/components/radius.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
packages/bezier-react/src/styles/components/z-index.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import fs from 'fs/promises' | ||
import path from 'path' | ||
|
||
interface BuildScssIndexOptions { | ||
buildPath: string | ||
} | ||
|
||
export async function buildScssIndex({ buildPath }: BuildScssIndexOptions) { | ||
const destination = path.join(buildPath, 'index.scss') | ||
|
||
try { | ||
const files = await fs.readdir(buildPath) | ||
let useStatements = '' | ||
let mapStatements = '$tokens: (\n' | ||
|
||
for (const file of files.filter( | ||
(file) => file.endsWith('.scss') && file !== path.basename(destination) | ||
)) { | ||
const moduleName = path.basename(file, '.scss') | ||
|
||
useStatements += `@use './${moduleName}' as ${moduleName};\n` | ||
mapStatements += ` "${moduleName}": ${moduleName}.$tokens,\n` | ||
} | ||
|
||
mapStatements += ');\n' | ||
|
||
const result = `${useStatements}\n${mapStatements}` | ||
|
||
await fs.writeFile(destination, result) | ||
|
||
console.log(`\n✔︎ Created ${destination}`) | ||
} catch (error) { | ||
throw error | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters