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

Deduplicate local tokens #2807

Merged
merged 27 commits into from
Jul 2, 2024

Conversation

macintoshhelper
Copy link
Contributor

@macintoshhelper macintoshhelper commented May 30, 2024

Why does this PR exist?

Fixes #2779

What does this pull request do?

  • Adds a modal in the footer

Need to decide how to display the modal to the user on startup (will need more extensive testing around this since many users may experience it).

Testing this change

Additional Notes (if any)

Will need a review of the text copy/locales surrounding this.

image

Highlighted with yellow circle

image

Copy link

changeset-bot bot commented May 30, 2024

⚠️ No Changeset found

Latest commit: 2ac9e76

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@macintoshhelper macintoshhelper marked this pull request as ready for review June 28, 2024 14:44
Copy link
Collaborator

@six7 six7 left a comment

Choose a reason for hiding this comment

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

functionality wise i'm not sure if this should work already. i click resolve duplicates but nothing happens

can you add an e2e test so we verify on a test level that it does indeed work and we're safe for future changes?

CleanShot.2024-07-01.at.08.57.58.mp4

Comment on lines 50 to 51
<Heading size="small" css={{ minWidth: '$9' }}>Token: </Heading>
<Heading size="small">{groupKey}</Heading>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<Heading size="small" css={{ minWidth: '$9' }}>Token: </Heading>
<Heading size="small">{groupKey}</Heading>
<Heading size="small"><Box as="span" css={{ minWidth: '$9' }}>Token: </Box>{groupKey}</Heading>

<Heading size="small">{groupKey}</Heading>
</Stack>
<Stack direction="row">
<Heading size="small" css={{ minWidth: '$9' }}>Value: </Heading>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<Heading size="small" css={{ minWidth: '$9' }}>Value: </Heading>
<Heading size="small" css={{ minWidth: '$9' }}>Value</Heading>

<RadioGroup
onValueChange={onRadioClick}
value={checkedToken}
css={{ gap: '$3' }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
css={{ gap: '$3' }}

with the upgrade in the @tokens-studio/ui package to 0.6.9 this should not be needed anymore, if it is feel free to change back

const tokens = useSelector(tokensSelector);
const [showResolveDuplicateTokensModal, setShowResolveDuplicateTokensModal] = React.useState<boolean>(false);

const hasDuplicates = useMemo(() => Object.keys(tokens).some((setName) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

something is off with this condition / memo, i always get that triangle in the bottom even on fresh files.
CleanShot 2024-07-01 at 08 54 01@2x

const hasDuplicates = useMemo(() => Object.keys(tokens).some((setName) => {
const currentSetTokens = tokens[setName];
return currentSetTokens.some((token) => {
const allTokensWithName = currentSetTokens.filter((a) => a.name === token.name);
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this performant? a filter on a filter?

like why not just use that as the condition?

variant="invisible"
size="small"
tooltip="Duplicate Warning"
target="_blank"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
target="_blank"

this is not a link, no need for target blank

Comment on lines 123 to 124
// tokens={tokens}
// resolvedTokens={resolvedTokens}
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

Copy link
Collaborator

@six7 six7 left a comment

Choose a reason for hiding this comment

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

LGTM!

@macintoshhelper macintoshhelper merged commit 5227ec3 into release-139 Jul 2, 2024
7 of 8 checks passed
@macintoshhelper macintoshhelper deleted the fix/2779-deduplicate-local-tokens branch July 2, 2024 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When parsing tokens stored on the local document, first de-duplicate tokens
2 participants