Skip to content

Remove duplicate styles#742

Open
Que-tin wants to merge 1 commit into
pierrecomputer:mainfrom
Que-tin:remove-duplicate-styles
Open

Remove duplicate styles#742
Que-tin wants to merge 1 commit into
pierrecomputer:mainfrom
Que-tin:remove-duplicate-styles

Conversation

@Que-tin
Copy link
Copy Markdown

@Que-tin Que-tin commented May 24, 2026

Description

While scimming over the CSS I recognized plenty of duplicate code blocks. This PR merges the most obvious ones.

Motivation & Context

Keep the CSS maintainable over time.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality). You must have
    first discussed with the dev team and they should be aware that this PR is
    being opened
  • Breaking change (fix or feature that would change existing functionality).
    You must have first discussed with the dev team and they should be aware
    that this PR is being opened
  • Documentation update

Checklist

  • I have read the
    contributing guidelines
  • My code follows the code style of the project (bun run lint)
  • My code is formatted properly (bun run format)
  • I have updated the documentation accordingly (if applicable)
  • I have added tests to cover my changes (if applicable)
  • All new and existing tests pass (bun run diffs:test)

How was AI used in generating this PR

Checking for additional repeating patterns and how one could optimize them.

Related issues

None

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@Que-tin is attempting to deploy a commit to the Pierre Computer Company Team on Vercel.

A member of the Team first needs to authorize it.

Comment on lines -94 to -97
light-dark(
color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer)),
color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer))
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No need for light-dark as long as the color is the same.
This pattern is also already applied to other custom properties

--diffs-fg: light-dark(var(--diffs-light, #000), var(--diffs-dark, #fff));
--diffs-fg-number: var(
--diffs-fg-number-override,
light-dark(
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No need for light-dark as long as the color is the same.
This pattern is also already applied to other custom properties

Comment on lines +210 to +214
*,
*::before,
*::after {
box-sizing: border-box;
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Just moved above all of the element selectors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@amadeus Did you ever look into how bad the * selector perf is within the shadow we use for diffs DOM?

Comment on lines +216 to +223
button {
appearance: none;
border-style: none;
background-color: transparent;
font: inherit;
cursor: pointer;
padding: 0;
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

These resets had been done on all buttons anyway and are pretty common.

Comment on lines -528 to -542
--diffs-computed-diff-line-bg: light-dark(
color-mix(
in lab,
var(--diffs-computed-decoration-bg) var(--mix-light),
var(--diffs-diff-line-mix-target)
),
color-mix(
in lab,
var(--diffs-computed-decoration-bg) var(--mix-dark),
var(--diffs-diff-line-mix-target)
)
);

--diffs-computed-selected-line-bg: var(--diffs-computed-diff-line-bg);
--diffs-line-bg: var(--diffs-computed-diff-line-bg, inherit);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This exact code block was copied 4x, instead of copying it I listed all selectors.

Comment on lines -1541 to -1548
appearance: none;
border: 0;
background: transparent;
color: var(--diffs-fg-number);
font: inherit;
font-style: normal;
cursor: pointer;
padding: 0;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved to the button reset

Comment on lines -1666 to -1670
[data-overflow='scroll'] [data-annotation-content] {
position: sticky;
width: var(--diffs-column-content-width, auto);
left: var(--diffs-column-number-width, 0);
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This whole block was duplicated exactly beneath, with just a different selector

Comment on lines 1646 to -1705
justify-content: center;
border: none;
appearance: none;
width: 1lh;
height: 1lh;
margin-right: calc((1lh - 1ch) * -1);
padding: 0;
cursor: pointer;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved to the button reset

Comment on lines -1738 to +1682
border-left: 2px solid var(--diffs-bg);
border-right: 2px solid var(--diffs-bg);
border-inline: 2px solid var(--diffs-bg);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Quick win I stumbled across

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.

2 participants