Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alpha token to autocomplete suggestion of bezier-vscode #2496

Merged

Conversation

yangwooseong
Copy link
Collaborator

Self Checklist

  • I wrote a PR title in English and added an appropriate label to the PR.
  • I wrote the commit message in English and to follow the Conventional Commits specification.
  • I added the changeset about the changes that needed to be released. (or didn't have to)
  • I wrote or updated documentation related to the changes. (or didn't have to)
  • 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

Summary

  • alpha 토큰도 자동완성 추천에 나오도록 합니다.

Details

  • legacy token, alpha token 별로 { category: { [name]: value } 객체를 assignToTokenMap 함수를 통해 만든 다음에 딥 머지를 했습니다. 이 때 alpha token의 "dimension" category 는 바뀔 예정이라 제외했습니다.
2024-11-12.10.26.31.mov

Breaking change? (Yes/No)

  • No

References

  • None

@yangwooseong yangwooseong added the bezier-vscode Issue or PR related to bezier-vscode label Nov 12, 2024
@yangwooseong yangwooseong self-assigned this Nov 12, 2024
Copy link

channeltalk bot commented Nov 12, 2024

Copy link

changeset-bot bot commented Nov 12, 2024

🦋 Changeset detected

Latest commit: 170d739

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
bezier-vscode Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.27%. Comparing base (d3d0acf) to head (170d739).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2496   +/-   ##
=======================================
  Coverage   82.27%   82.27%           
=======================================
  Files         143      143           
  Lines        2979     2979           
  Branches      917      917           
=======================================
  Hits         2451     2451           
  Misses        497      497           
  Partials       31       31           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yangwooseong yangwooseong force-pushed the WEB-5305/alpha-token-vscode branch 2 times, most recently from f422800 to eefc967 Compare November 12, 2024 02:51
'z-index': /z-index:/,
} satisfies Record<TokenGroup, RegExp>
} satisfies Record<Exclude<TokenGroup, 'dimension'>, RegExp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마이너) FIXME 주석 추가해주시면 좋을 거 같습니다

Comment on lines 17 to 35
type TokenValue = string | number | Record<string, string | number>
type TokenMap = Record<string, Record<string, TokenValue>>

const assignToTokenMap = (
target: TokenMap,
source: TokenMap,
fn: Function = (v: TokenMap) => v
) => {
Object.entries(source).forEach(([category, tokenObject]) => {
if (target[category] === undefined) {
target[category] = {}
}
Object.entries(tokenObject).forEach(([name, value]) => {
target[category][name] = fn(value)
})
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type TokenValue = string | number | Record<string, string | number>
type TokenMap = Record<string, Record<string, TokenValue>>
const assignToTokenMap = (
target: TokenMap,
source: TokenMap,
fn: Function = (v: TokenMap) => v
) => {
Object.entries(source).forEach(([category, tokenObject]) => {
if (target[category] === undefined) {
target[category] = {}
}
Object.entries(tokenObject).forEach(([name, value]) => {
target[category][name] = fn(value)
})
})
}
type TokenValue = string | number
type AlphaTokenValue = Record<string, TokenValue>
type TokenMap = Record<string, Record<string, TokenValue | AlphaTokenValue>>
const assignToTokenMap = (
target: TokenMap,
source: TokenMap,
transformValue: (v: TokenValue | AlphaTokenValue) => TokenValue = (v) =>
v as TokenValue
) => {
Object.entries(source).forEach(([category, tokenObject]) => {
if (target[category] === undefined) {
target[category] = {}
}
Object.entries(tokenObject).forEach(([name, value]) => {
target[category][name] = transformValue(value)
})
})

버전 별 토큰에 alias를 적절히 붙이고, 타입 단언을 사용하더라도 의도를 더 드러내는 편이 좋을 거 같습니다!

Comment on lines 38 to 49
assignToTokenMap(
alphaTokenMap,
alphaTokens.lightTheme,
(v: Record<string, string>) => v.value
)
assignToTokenMap(
alphaTokenMap,
alphaTokens.global,
(v: Record<string, string>) => v.value
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assignToTokenMap(
alphaTokenMap,
alphaTokens.lightTheme,
(v: Record<string, string>) => v.value
)
assignToTokenMap(
alphaTokenMap,
alphaTokens.global,
(v: Record<string, string>) => v.value
)
assignToTokenMap(
alphaTokenMap,
alphaTokens.lightTheme,
(v) => (v as AlphaTokenValue).value
)
assignToTokenMap(
alphaTokenMap,
alphaTokens.global,
(v) => (v as AlphaTokenValue).value
)

'z-index': /z-index:/,
} satisfies Record<TokenGroup, RegExp>
// FIXME: dimension token should be supported later
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dimension 토큰이 제거될 예정이라, 제거 이후 L94의 Exclude를 제거해도 된다는 식의 주석을 남기면 좋겠다는 코멘트였어요..!

@yangwooseong yangwooseong merged commit 0c92418 into channel-io:main Nov 12, 2024
5 checks passed
@yangwooseong yangwooseong added the enhancement Issues or PR related to making existing features better label Nov 13, 2024
sungik-choi pushed a commit that referenced this pull request Nov 14, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @channel.io/[email protected]

### Patch Changes

- Improves the styling of the `ListItem` component based on whether it
is interacted with or not.
([#2501](#2501)) by
@sungik-choi

## [email protected]

### Minor Changes

- Include `alpha` token for autocomplete suggestion.
([#2496](#2496)) by
@yangwooseong

### Patch Changes

- Fix bug where `bezier-vscode` is not running.
([#2499](#2499)) by
@yangwooseong

## [email protected]

### Patch Changes

-   Updated dependencies
    -   @channel.io/[email protected]

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bezier-vscode Issue or PR related to bezier-vscode enhancement Issues or PR related to making existing features better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants