Skip to content

Set all bootstrap color variables so normal bootstrap utilities work #120

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

cbeer
Copy link
Member

@cbeer cbeer commented Mar 25, 2025

library-hours uses .text-primary (presumably among other utilities). As a consumer of the component library styles, I think I'd expect bootstrap's utility classes to just work (and not end up with a combination of Stanford digital blue and Bootstrap-default blue).

In the first commit of this PR ("Import upstream variables"), I bring over all the bootstrap variables from upstream: https://github.com/twbs/bootstrap/blob/main/dist/css/bootstrap.css#L7-L126

before merging them with our previous overrides, hopefully for easier review.

While evaluating the merge, I think I ran into a couple bugs:

  • there isn't a current link hover color (and probably should be, update link hover color css #48?)
  • we didn't define font fallbacks if Source Sans 3 isn't available. Presumably we'd prefer some sans serif fonts?

Copy link

A preview of this branch is available at https://sul-dlss.github.io/component-library/preview-120.

--bs-danger-border-subtle: rgb(var(--bs-danger-rgb));
--bs-danger-text-emphasis: rgb(var(--bs-danger-rgb));
--bs-blue: var(--stanford-sky-dark);
--bs-indigo: #6610f2;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd really prefer we only pull in the colors we need to do the functions in colors/text.html. Let's keep this to just what we need as it makes maintenance easier.

Copy link
Member Author

Choose a reason for hiding this comment

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

How do we know what colors we'll need? My hope is we don't have to think about it, and if we ask for a bootstrap color in our applications we get one of the branding colors.

--stanford-digital-blue-rgb: 0, 108, 184;
--stanford-digital-blue-dark: #00588c;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use rgb(var(--stanford-digital-blue-dark-rgb)) instead. Then there's no risk of getting out of synch.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think upstream bootstrap defines their colors explicitly/separately. I figure it's probably a performance thing, and for as often as we're changing branding colors we can expect either a PR author and reviewer to look at the line above or below and catch it 🤷‍♂️

--stanford-digital-blue-dark-rgb: 0, 84, 143;
--stanford-digital-green-dark-rgb: 0, 111, 84;
--stanford-digital-red-dark-rgb: 130, 0, 0;
--stanford-digital-green: #008566;
--stanford-digital-red: #b1040e;
--stanford-digital-red-light: #e50808;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used by anything in the component library? I'd prefer that if it's not used in any of our designs, we keep it out, even if it is in the current identity guide.

Copy link
Member Author

Choose a reason for hiding this comment

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

And I'm the opposite. It seems trivial to add now, and really annoying to have an incomplete component library when we need it.

@@ -14,5 +14,5 @@

:root {
--font-family-serif: "Source Serif 4", serif;
--bs-font-sans-serif: "Source Sans 3";
--bs-font-sans-serif: "Source Sans 3", system-ui, -apple-system, "Segoe UI", roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
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
--bs-font-sans-serif: "Source Sans 3", system-ui, -apple-system, "Segoe UI", roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--bs-font-sans-serif: "Source Sans 3", system-ui;

system-ui is broadly supported. I can't think of a case where we'd need more than this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe I copied the upstream font stack and pre-pended our brand font. That bootstrap hasn't dropped the fallbacks seems like an indicator that it's maybe too soon?

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