Skip to content

Commit

Permalink
feat(design): allow the whole typography subpackaged to be exported a…
Browse files Browse the repository at this point in the history
…nd allow body-font-family variable to be assignable
  • Loading branch information
xelaint committed Jun 21, 2024
1 parent 223b304 commit 7c2126d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ <h1>Typography</h1>
<p>We use typography to establish hierarchy, organize information, and guide our users through a product or experience.</p>

<h2>Type scale</h2>
<p>The Design Land typopgrahic scale is designed with visual distinctions to help our users better understand content and UI. Text sizes, styles, and layouts were selected to maintain logical hierarchies and drive consistency throughout an application.</p>
<p>The typopgrahic scale is designed with visual distinctions to help our users better understand content and UI. Text sizes, styles, and layouts were selected to maintain logical hierarchies and drive consistency throughout an application.</p>

<h3>8px system</h3>
<p>Our type scale is based on an 8px system, where the type is largely divisible by 8. For smaller sizes, the system allows for the scale to be divisble by 4.</p>
Expand Down
4 changes: 2 additions & 2 deletions libs/design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"./scss/utilities": {
"sass": "./scss/utilities.scss"
},
"./scss/typography/classes": {
"sass": "./scss/typography/_classes.scss"
"./scss/typography": {
"sass": "./scss/typography/_index.scss"
}
}
}
30 changes: 19 additions & 11 deletions libs/design/scss/typography/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
# Typography
Daffodil uses typography to establish hierarchy and create clear visual patterns to guide users through a product or experience.
Daffodil uses typography to establish hierarchy, organize information, and guide our users through a product or experience.

## Usage
To include typography in your project, you can add the following in your Sass file:
To include typography in your project, you can include the following in your Sass file:

```scss
@use '@daffodil/design/scss/utilities';
@use '@daffodil/design/scss/typography';
```

## Type Scale
`@daffodil/design`'s typographic scale is designed with visual distinctions to help users better understand content and UI. Text sizes, styles, and layouts have been chosen to maintain logical hierarchies and drive consistency throughout an application.
The typographic scale is designed with visual distinctions to help users better understand content and UI. Text sizes, styles, and layouts have been chosen to maintain logical hierarchies and drive consistency throughout an application.

### 8px System
Our type scale is based on an 8px system, where the type is largely divisible by 8. For smaller sizes, the system allows for the scale to be divisible by 4. Font sizes are typically smaller on mobile and scaled up at the `tablet` breakpoint to be larger on desktop.

## Font Stack
Daffodil uses a system font stack to maximize on performance, legibility, and accessibility. System fonts play into the improvement of today's rich displays Additionally, system fonts provides a seamless experience for users because the application feel more like it blends in with their device's OS.
## Default Font Stack
By default, Daffodil uses a system font stack to maximize on performance, legibility, and accessibility. System fonts play into the improvement of today's rich displays Additionally, system fonts provides a seamless experience for users because the application feel more like it blends in with their device's OS.

```scss
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
&dollar;font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
```

* `-apple-system` and `BlinkMacSystemFont` targets default fonts in Safari, Firefox, and Chrome on macOS and iOS.
* `Segoe UI` is the system font for Windows.
* `Helvetica` and `Arial` are added as fallbacks.
* `Apple Color Emoji`, `Segoe UI Emoji`, and `Segoe UI Symbol` are included so that emojis are rendered correctly in macOS and Windows.

To customize your project's font stack, you can pass the `$font-family-base` variable to the typography module in your `style.scss` file:

```scss
@use '@daffodil/design/scss/typography' with (
$font-family-base: 'Arial',
);
```

## Typography Mixins
Typography mixins are used to keep typography consistent with logical hierarchies. Utilizing the mixin ensures that content within the UI are clear and easily recognizable. Mixins are available for headlines, body, subheading, and caption. They are used within the `@daffodil/design` components and can also be used within custom CSS.

Expand All @@ -46,10 +54,10 @@ The headline mixins are responsive and will adjust at the `tablet` breakpoint.

**Example:**
```scss
@use '@daffodil/design/scss/utilities';
@use '@daffodil/design/scss/typography';

.title {
@include utilities.headline-xl;
@include typography.headline-xl();
}
```

Expand All @@ -67,13 +75,13 @@ The headline mixins are responsive and will adjust at the `tablet` breakpoint.
You can include the typography utility classes in your project by writing the following in your Sass file:

```scss
@use '@daffodil/design/scss/typography/classes';
@use '@daffodil/design/scss/typography';
```

Otherwise, you can use the mixins in your project by using the following module in your Sass file:

```scss
@use '@daffodil/design/scss/utilities';
@use '@daffodil/design/scss/typography';
```

## Typography Variables
Expand Down
2 changes: 1 addition & 1 deletion libs/design/scss/typography/_index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@forward 'utilities';
@forward 'mixins/font-weight';
@forward 'mixins/sizes';
@forward 'mixins/text-truncate';
@forward 'utilities';
18 changes: 14 additions & 4 deletions libs/design/scss/typography/utilities/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
$body-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica,
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
$font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica,
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !default;
$font-family-mono: ui-monospace, 'SFMono-Regular', SF Mono, Menlo, Consolas,
'Liberation Mono', monospace !default;

// these three variables will be deprecated in v1.0.0 in favor of more consistent naming
$body-font-family: $font-family-base;
$base-font-family: $body-font-family;
$monospace-font-family: ui-monospace, 'SFMono-Regular', SF Mono, Menlo, Consolas,
'Liberation Mono', monospace;
$monospace-font-family: $font-family-mono;

$font-size-sm: 0.875rem;
$font-size-base: 1rem;
$font-size-md: 1.25rem;
$font-size-lg: 1.5rem;

// these variables will be deprecated in v1.0.0 in favor of more consistent naming
$large-font-size: 1.5rem;
$medium-font-size: 1.25rem;
$normal-font-size: 1rem;
Expand Down

0 comments on commit 7c2126d

Please sign in to comment.