Skip to content

Commit b86f108

Browse files
authored
Adjust CSS specificity to ensure Japanese font is properly applied (#2776)
<!-- 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) - [ ] 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 --> - https://github.com/channel-io/bezier-react/pull/2764/changes#diff-d5343edd2cbd4060cb12d851b2ce7b8776194248a36fa05f6a4bf7c9dff9cfdfR19-R27 <!-- Fixes #0000 --> ## Summary <!-- Please brief explanation of the changes made --> css 적용 우선순위로 인해 일본어일 때 타이포그래피 폰트의 오버라이드가 적용되지 않는 문제를 수정합니다. ## Details <!-- Please elaborate description of the changes --> - 베지어 V3 토큰을 추가하며 font-family에 대한 토큰이 사용처 별로 나뉘게 되었습니다. - 그에 대한 대응으로 언어가 일본어일 때 폰트를 오버라이드 하도록 수정했으나 css 특이성으로 인해 적용되지 않았습니다. - 기존에는 font-family를 재정의하여 오버라이드 하는 방식이었으나, font-family에 사용된 토큰을 오버라이드 해야 일본어일 때 `typography-*font-family`를 사용할 경우 일본어 폰트가 적용될 수 있습니다. ```md **AS IS (v1)** - --font-family-sans-kr - --font-family-sans-jp **TO BE (v3 semantic)** - --typography-heading-font-family: --typography-font-family-sans-kr - --typography-text-font-family: --typography-font-family-sans-kr - --typography-display-font-family: --typography-font-family-sans-kr **일본어일 때 아래와 같이 오버라이드 되어야 함** - --typography-heading-font-family: --typography-font-family-sans-jp - --typography-text-font-family: --typography-font-family-sans-jp - --typography-display-font-family: --typography-font-family-sans-jp ``` ### CSS 특이성(Specificity) - 특이성이란? - 여러 규칙이 같은 요소에 적용될 때 어떤 규칙이 우선되는지 결정하는 점수입니다. - 계산 방법 - 특이성은 4개의 숫자로 표현됩니다: (인라인, ID, 클래스/속성/가상클래스, 요소) - 점수 체계: - 인라인 스타일 (style="..."): 1,0,0,0 - ID 선택자 (#id): 0,1,0,0 - 클래스/속성/가상클래스: - `.class: 0,0,1,0` - `[data-theme]: 0,0,1,0` - `:hover, :lang(ja): 0,0,1,0` - `요소 선택자 (div, p): 0,0,0,1` - 예외: - :where(): 특이성 0,0,0,0 (항상 낮음) - :is(), :has(): 내부 선택자 중 가장 높은 특이성 사용 - 비교 규칙 - 왼쪽부터 비교합니다. 예: - 0,1,0,0 > 0,0,2,0 (ID가 클래스보다 우선) - 0,0,2,0 > 0,0,1,0 (클래스가 많을수록 높음) ```scss /* 특이성: 0,0,1,0 (속성 선택자 1개) */ [data-bezier-theme="dark"] { --typography-text-font-family: var(--typography-font-family-sans-kr); } /* 특이성: 0,0,1,0 (가상클래스 1개) */ :lang(ja) { --typography-text-font-family: var(--typography-font-family-sans-jp); } /* 두 규칙의 특이성이 같으면 (0,0,1,0), 나중에 선언된 규칙이 우선됩니다. 하지만 레이어가 다르면 레이어 우선순위가 먼저 적용됩니다. */ /* 특이성: 0,1,1,0 (속성 1개 + 가상클래스 1개) */ [data-bezier-theme="dark"]:lang(ja) { --typography-text-font-family: var(--typography-font-family-sans-jp); } ``` ### Breaking change? (Yes/No) <!-- If Yes, please describe the impact and migration path for users --> No ## References <!-- Please list any other resources or points the reviewer should be aware of -->
1 parent 84ed149 commit b86f108

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

.changeset/polite-pants-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@channel.io/bezier-react': patch
3+
---
4+
5+
Adjust CSS specificity to ensure Japanese font is properly applied.

packages/bezier-react/src/styles/_base.scss

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,11 @@
1515
color-scheme: dark;
1616
}
1717

18-
:lang(ja) {
19-
--typography-heading-font-family: var(
20-
--typography-font-family-sans-jp
21-
);
22-
--typography-text-font-family: var(
23-
--typography-font-family-sans-jp
24-
);
25-
--typography-display-font-family: var(
26-
--typography-font-family-sans-jp
27-
);
18+
[data-bezier-theme='dark']:lang(ja),
19+
[data-bezier-theme='light']:lang(ja) {
20+
--typography-heading-font-family: var(--typography-font-family-sans-jp);
21+
--typography-text-font-family: var(--typography-font-family-sans-jp);
22+
--typography-display-font-family: var(--typography-font-family-sans-jp);
2823
}
2924

3025
code {

0 commit comments

Comments
 (0)