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

style: add global css #18

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

style: add global css #18

wants to merge 1 commit into from

Conversation

sounmind
Copy link

Summary

Tests

Additional information

@@ -0,0 +1,151 @@
:root {
--font-primary: 'Uai', 'Source Sans Pro', 'Montserrat', 'Roboto', Helvetica, Arial, sans-serif;
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: ‏Did we get the font files from Cadu?

Copy link
Contributor

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

@manvinderjit @madcampos Which font format are you using? I've shared the OTF font files with the design team, but they're not proper for web browsers. I've attached the WOFF2 font files, with a link below.

Uai-Variable.zip

Choose a reason for hiding this comment

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

@manvinderjit @madcampos I've also added a small CSS font-face snippet, you just need to place the files and import in the global CSS.

Copy link
Contributor

Choose a reason for hiding this comment

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

@madcampos I am not sure if there is an issue with the font or was it just a comment. @caducarvalho Thank you for the files, we will use these just in case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Was just a comment to check if you got the files. I didn't see a css file with @font-face declarations so was just double checking.

Thank you @caducarvalho for providing the files! 😎

Comment on lines +3 to +8
--text-base: 18px;
--text-scale-ratio: 1.067;
--spacing-base: 8px;
--rounded-base: 2px;
--leading-base: 1.6em;
--shadow-base: 2px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: ‏Can we make those values relative to the text size?

Like this:

:root {
  /* Here we need a unitless number so we can do ✨ math ✨ */
  --REFERENCE_BASE_SIZE: 18;

  /* This is a decent assumption for a browser default font setting. */
  /* (i.e. "medium font size") */
  /* Also a unitless value for ✨ math reasons ✨ */
  --BROWSER_DEFAULT: 16;

  /* Here we get the ratio between the size we want and the assumed browser default. */
  /* Then multiply by 1rem to force the browser to calculate a value out of it, */
  /* instead of having a unitless number. */
  /* Now: 1rem = 18px, for the default font size configuration in all major browsers. */
  --text-base: calc((var(--REFERENCE_BASE_SIZE) / var(--BROWSER_DEFAULT)) * 1rem);

  /* This is the single value everything will be based off and be relative to. */
  /* We set the root font size so it cascades to everything else. */
  /* And rem units work. */
  font-size: var(--text-base);

  /* ✨ MOAR MATH ✨ */
  /* But now normalized to the new rem value */
  --spacing-base: calc((8 / var(--REFERENCE_BASE_SIZE)) * 1rem); /* 8px / 18px = 0.444...rem */
  --rounded-base: calc((2 / var(--REFERENCE_BASE_SIZE)) * 1rem); /* 2px / 18px = 0.111...rem */
  --shadow-base: calc((2 / var(--REFERENCE_BASE_SIZE)) * 1rem); /* Same as --rounded-base */

  /* NOTE: we just need to do this for the base values 😅 */
}

Here is a minimal demo to showcase this difference: https://codepen.io/madcampos/pen/MYWKYjN

Go to your browser settings and change the font size and see the font change on all paragraphs but the one with a fixed pixel size. (This should be under "Appearance" or something.)

Here is it the setting in Edge:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

@madcampos Thanks for comment! We might skip this for now and think about it later.

src/index.css Outdated
--rounded-lg: calc(8 * var(--rounded-base));
--rounded-xl: calc(12 * var(--rounded-base));
--rounded-full: 50%;
--border: 1px solid var(--color-border);
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: ‏There should be a --border-base value for the border thickness

line-height: var(--leading-base);
}

a { color: var(--color-accent); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: ‏Also add accent-color to the :root declaration.

Copy link
Author

@sounmind sounmind Feb 27, 2025

Choose a reason for hiding this comment

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

:root {
    // ...
	accent-color: var(--color-accent);
}

Like this?
Can you tell me why we need this?

Comment on lines +78 to +91
h1,
h2,
h3,
h4,
h5,
h6,
.text-h1,
.text-h2,
.text-h3,
.text-h4,
.text-h5,
.text-h6,
Copy link
Collaborator

@madcampos madcampos Feb 18, 2025

Choose a reason for hiding this comment

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

nitpick: It is more readable this way:

Suggested change
h1,
h2,
h3,
h4,
h5,
h6,
.text-h1,
.text-h2,
.text-h3,
.text-h4,
.text-h5,
.text-h6,
h1, h2, h3, h4, h5, h6,
.text-h1, .text-h2, .text-h3, .text-h4, .text-h5, .text-h6,

"Old man yelling at cloud" gif

And please use dprint to format the code instead of effing prettier.

Prettier is a complete and utter garbage, it messes up code in unintuitive ways for AST sake and not humab sake, and I will die on this hill!

Add these files/lines to the project please:

Copy link
Author

@sounmind sounmind Feb 27, 2025

Choose a reason for hiding this comment

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

It's weird. We already have dprint settings and its script(npm run format on pre-commit) is working well. I think there's no css config in dprint settings. Can you check this again? @madcampos

Co-authored-by: Manvinderjit Rupal <manvinderjit@users.noreply.github.com>
Copy link

cloudflare-workers-and-pages bot commented Feb 27, 2025

Deploying volunteer with  Cloudflare Pages  Cloudflare Pages

Latest commit: 38e5b19
Status: ✅  Deploy successful!
Preview URL: https://790519ca.volunteer-ekr.pages.dev
Branch Preview URL: https://style-global-css.volunteer-ekr.pages.dev

View logs

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.

4 participants