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

Migrate the Body's highlight variant to semibold #2750

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/circuit-ui/components/Body/Body.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

/* Weights */

.regular {
.base.regular {
font-weight: var(--cui-font-weight-regular);
}

.semibold {
.base.semibold {
font-weight: var(--cui-font-weight-semibold);
}

.bold {
.base.bold {
font-weight: var(--cui-font-weight-bold);
}

Expand Down Expand Up @@ -90,7 +90,7 @@
.highlight,
strong.base,
.base strong {
font-weight: var(--cui-font-weight-bold);
font-weight: var(--cui-font-weight-semibold);
}

.quote,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,13 @@ ruleTester.run('no-renamed-props', noRenamedProps, {
output: `
function ComponentA() {
return (
<Body as="strong" weight="bold">Lorem ipsum</Body>
<Body as="strong">Lorem ipsum</Body>
)
}

function ComponentB() {
return (
<Body as="span" weight="bold">Lorem ipsum</Body>
<Body as="span" weight="semibold">Lorem ipsum</Body>
)
}

Expand Down
12 changes: 3 additions & 9 deletions packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,22 +301,16 @@ const configs: (Config & { components: string[] })[] = [
const current = getAttributeValue(attribute);

if (current === 'highlight') {
const replacement = `as="strong" weight="bold"`;
const weightAttribute = findAttribute(node, 'weight');
const asAttribute = findAttribute(node, 'as');
const weightAttribute = findAttribute(node, 'weight');
const replacement = asAttribute ? 'weight="semibold"' : `as="strong"`;
context.report({
node: attribute,
messageId: 'bodyVariant',
data: { component, current, replacement },
fix: weightAttribute
Copy link
Contributor

Choose a reason for hiding this comment

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

does this mean that if we have a weight attribute besides the variant, we do nothing ?

Copy link
Member Author

@connor-baer connor-baer Oct 30, 2024

Choose a reason for hiding this comment

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

We don't apply a fix, but the issue is still flagged. I decided to add this back in case of custom props on styled components.

? undefined
: (fixer) => {
// Don't override an existing `as` attribute
if (asAttribute) {
return fixer.replaceText(attribute, 'weight="bold"');
}
return fixer.replaceText(attribute, replacement);
},
: (fixer) => fixer.replaceText(attribute, replacement),
});
return;
}
Expand Down