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 Feb 23, 2024
1 parent 544582a commit f752926
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 182 deletions.
4 changes: 2 additions & 2 deletions apps/design-land/src/app/typography/typography.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h1 daffArticleTitle>Typography</h1>
<p daffArticleLead>We use typography to establish hierarchy, organize information, and guide our users through a product or experience.</p>
<p daffArticleLead>Daffodil uses 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 @@ -69,8 +69,8 @@
"./scss/daff-typography": {
"sass": "./scss/daff-typography.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
149 changes: 149 additions & 0 deletions libs/design/scss/typography/_all-typography.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
@use '../layout';

$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;

// 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: $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;
$small-font-size: 0.875rem;

$bold-font-weight: bold;

// Changes the weight of text to bold
@mixin embolden() {
font-weight: $bold-font-weight;
}

@mixin headline-xl() {
@include embolden();
font-size: 2.5rem;
line-height: 2.75rem;

@include layout.breakpoint(tablet) {
font-size: 3.5rem;
line-height: 4rem;
}
}

@mixin headline-lg() {
@include embolden();
font-size: 2rem;
line-height: 2.25rem;

@include layout.breakpoint(tablet) {
font-size: 3rem;
line-height: 3.5rem;
}
}

@mixin headline-md() {
@include embolden();
font-size: 1.5rem;
line-height: 1.75rem;

@include layout.breakpoint(tablet) {
font-size: 2rem;
line-height: 2.5rem;
}
}

@mixin headline-sm() {
@include embolden();
font-size: 1.25rem;
line-height: 1.5rem;

@include layout.breakpoint(tablet) {
font-size: 1.5rem;
line-height: 2rem;
}
}

@mixin body-lg() {
font-size: 1.5rem;
font-weight: 400;
line-height: 2rem;
}

@mixin body-md() {
font-size: 1.25rem;
font-weight: 400;
line-height: 1.75rem;
}

@mixin body-sm() {
font-size: 1rem;
font-weight: 400;
line-height: 1.5rem;
}

@mixin body-xs() {
font-size: 0.875rem;
font-weight: 400;
line-height: 1.25rem;
}

@mixin subheading() {
font-size: 0.875rem;
font-weight: 600;
letter-spacing: 0.03125rem;
line-height: 1rem;
text-transform: uppercase;
}

@mixin caption() {
font-size: 0.75rem;
line-height: 1rem;
font-weight: 400;
}

// Forces a line of text to ellipsis once it reaches the
// width of its container. It should only be used if the element
// is `display: block` or `display: inline-block`.

@mixin text-truncate() {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

// @deprecated in v1.0 in favor of text-truncate
@mixin single-line-ellipsis() {
@include text-truncate();
}

// @deprecated in v1.0.0
@mixin uppercase() {
text-transform: uppercase;
}

.embolden { /* stylelint-disable-line selector-class-pattern */
@include embolden();
}

.uppercase { /* stylelint-disable-line selector-class-pattern */
text-transform: uppercase;
}

// deprecate in v1.0
.single-line-ellipsis { /* stylelint-disable-line selector-class-pattern */
@include single-line-ellipsis();
}

.text-truncate { /* stylelint-disable-line selector-class-pattern */
@include text-truncate();
}
20 changes: 0 additions & 20 deletions libs/design/scss/typography/_classes.scss

This file was deleted.

6 changes: 1 addition & 5 deletions libs/design/scss/typography/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
@forward 'mixins/font-weight';
@forward 'mixins/sizes';
@forward 'mixins/text-transform';
@forward 'mixins/text-truncate';
@forward 'utilities';
@forward 'all-typography'
18 changes: 0 additions & 18 deletions libs/design/scss/typography/mixins/_font-weight.scss

This file was deleted.

84 changes: 0 additions & 84 deletions libs/design/scss/typography/mixins/_sizes.scss

This file was deleted.

4 changes: 0 additions & 4 deletions libs/design/scss/typography/mixins/_text-transform.scss

This file was deleted.

Loading

0 comments on commit f752926

Please sign in to comment.