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

fix(type): add default type feature flag #3742

Merged
merged 4 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,55 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`_grid.scss should generate grid code when the grid feature flag is on 1`] = `
"@keyframes skeleton {
"h1 {
font-size: 2rem;
font-weight: 300;
line-height: 3.125rem;
letter-spacing: 0; }

h2 {
font-size: 2rem;
font-weight: 400;
line-height: 2.5rem;
letter-spacing: 0; }

h3 {
font-size: 1.75rem;
font-weight: 400;
line-height: 2.25rem;
letter-spacing: 0; }

h4 {
font-size: 1.25rem;
font-weight: 400;
line-height: 1.625rem;
letter-spacing: 0; }

h5 {
font-size: 1rem;
font-weight: 600;
line-height: 1.375rem;
letter-spacing: 0; }

h6 {
font-size: 0.875rem;
font-weight: 600;
line-height: 1.125rem;
letter-spacing: 0.16px; }

p {
font-size: 1rem;
font-weight: 400;
line-height: 1.5rem;
letter-spacing: 0; }

a {
color: #0062ff; }

em {
font-style: italic; }

@keyframes skeleton {
0% {
width: 0%;
left: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,55 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`_css--font-face.scss experimental should output @font-face blocks from elements if components-x flag is enabled 1`] = `
"@keyframes skeleton {
"h1 {
font-size: 2rem;
font-weight: 300;
line-height: 3.125rem;
letter-spacing: 0; }

h2 {
font-size: 2rem;
font-weight: 400;
line-height: 2.5rem;
letter-spacing: 0; }

h3 {
font-size: 1.75rem;
font-weight: 400;
line-height: 2.25rem;
letter-spacing: 0; }

h4 {
font-size: 1.25rem;
font-weight: 400;
line-height: 1.625rem;
letter-spacing: 0; }

h5 {
font-size: 1rem;
font-weight: 600;
line-height: 1.375rem;
letter-spacing: 0; }

h6 {
font-size: 0.875rem;
font-weight: 600;
line-height: 1.125rem;
letter-spacing: 0.16px; }

p {
font-size: 1rem;
font-weight: 400;
line-height: 1.5rem;
letter-spacing: 0; }

a {
color: #0062ff; }

em {
font-style: italic; }

@keyframes skeleton {
0% {
width: 0%;
left: 0;
Expand Down Expand Up @@ -723,7 +771,55 @@ exports[`_css--font-face.scss experimental should output @font-face blocks from
`;

exports[`_css--font-face.scss should not output CSS if $css--font-face is false 1`] = `
"@keyframes skeleton {
"h1 {
font-size: 2rem;
font-weight: 300;
line-height: 3.125rem;
letter-spacing: 0; }

h2 {
font-size: 2rem;
font-weight: 400;
line-height: 2.5rem;
letter-spacing: 0; }

h3 {
font-size: 1.75rem;
font-weight: 400;
line-height: 2.25rem;
letter-spacing: 0; }

h4 {
font-size: 1.25rem;
font-weight: 400;
line-height: 1.625rem;
letter-spacing: 0; }

h5 {
font-size: 1rem;
font-weight: 600;
line-height: 1.375rem;
letter-spacing: 0; }

h6 {
font-size: 0.875rem;
font-weight: 600;
line-height: 1.125rem;
letter-spacing: 0.16px; }

p {
font-size: 1rem;
font-weight: 400;
line-height: 1.5rem;
letter-spacing: 0; }

a {
color: #0062ff; }

em {
font-style: italic; }

@keyframes skeleton {
0% {
width: 0%;
left: 0;
Expand Down
9 changes: 8 additions & 1 deletion packages/components/src/globals/scss/_css--reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}

@include exports('css--reset') {
@if variable-exists(css--reset) == false or $css--reset==true {
@if variable-exists(css--reset) == false or $css--reset == true {
// http://cssreset.com/scripts/eric-meyer-reset-css/
html,
body,
Expand Down Expand Up @@ -199,3 +199,10 @@
@include carbon--icons;
}
}

@include exports('css--default-type') {
@if variable-exists(css--default-type) == false or $css--default-type == true
{
@include carbon--default-type;
}
}
6 changes: 6 additions & 0 deletions packages/components/src/globals/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ $css--use-layer: true !default;
/// @group feature-flags
$css--reset: true !default;

/// If true, include default type
/// @access public
/// @type Bool
/// @group feature-flags
$css--default-type: true !default;

/// Used with `css--font-face` feature flag, if true, uses Plex font families instead of Helvetica
/// @access public
/// @type Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
font-family: $mono-font-family;
}

strong {
@include carbon--font-weight('semibold');
}
}

/// Include default type styles
/// @access public
/// @group @carbon/type
@mixin carbon--default-type {
h1 {
@include carbon--type-style('productive-heading-06');
}
Expand Down Expand Up @@ -71,8 +80,4 @@
em {
font-style: italic;
}

strong {
@include carbon--font-weight('semibold');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
font-family: $mono-font-family;
}

strong {
@include carbon--font-weight('semibold');
}
}

/// Include default type styles
/// @access public
/// @group @carbon/type
@mixin carbon--default-type {
h1 {
@include carbon--type-style('productive-heading-06');
}
Expand Down Expand Up @@ -71,8 +80,4 @@
em {
font-style: italic;
}

strong {
@include carbon--font-weight('semibold');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
font-family: $mono-font-family;
}

strong {
@include carbon--font-weight('semibold');
}
}

/// Include default type styles
/// @access public
/// @group @carbon/type
@mixin carbon--default-type {
h1 {
@include carbon--type-style('productive-heading-06');
}
Expand Down Expand Up @@ -71,8 +80,4 @@
em {
font-style: italic;
}

strong {
@include carbon--font-weight('semibold');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
font-family: $mono-font-family;
}

strong {
@include carbon--font-weight('semibold');
}
}

/// Include default type styles
/// @access public
/// @group @carbon/type
@mixin carbon--default-type {
h1 {
@include carbon--type-style('productive-heading-06');
}
Expand Down Expand Up @@ -71,8 +80,4 @@
em {
font-style: italic;
}

strong {
@include carbon--font-weight('semibold');
}
}
1 change: 1 addition & 0 deletions packages/components/tests/styles-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const files = glob.sync('**/*.scss', {
const render = promisify(sass.render);

describe('styles', () => {
jest.setTimeout(8000);
it.each(files)('%s should compile', async relativeFilePath => {
const filepath = path.join(cwd, relativeFilePath);
try {
Expand Down
45 changes: 31 additions & 14 deletions packages/elements/docs/sass.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
- [✅carbon--font-face-mono [mixin]](#carbon--font-face-mono-mixin)
- [✅prefix [variable]](#prefix-variable)
- [✅carbon--type-reset [mixin]](#carbon--type-reset-mixin)
- [✅carbon--default-type [mixin]](#carbon--default-type-mixin)
- [✅carbon--font-face-sans [mixin]](#carbon--font-face-sans-mixin)
- [✅carbon--get-type-size [function]](#carbon--get-type-size-function)
- [✅carbon--type-scale [variable]](#carbon--type-scale-variable)
Expand Down Expand Up @@ -5708,6 +5709,35 @@ Include a type reset for a given body and mono font family
font-family: $mono-font-family;
}

strong {
@include carbon--font-weight('semibold');
}
}
```

</details>

- **Parameters**:

| Name | Description | Type | Default value |
| ------------------- | ----------------------------------------------------------------------------------- | -------- | ----------------------------- |
| `$base-font-size` | The base font size for your document | `Number` | `$carbon--base-font-size` |
| `$body-font-family` | The font family used on the `<body>` element | `String` | `carbon--font-family('sans')` |
| `$mono-font-family` | The font family used on elements that require mono fonts, like the `<code>` element | `String` | `carbon--font-family('mono')` |

- **Group**: [@carbon/type](#carbontype)
- **Requires**:
- [carbon--font-weight [mixin]](#carbon--font-weight-mixin)

### ✅carbon--default-type [mixin]

Include default type styles

<details>
<summary>Source code</summary>

```scss
@mixin carbon--default-type() {
h1 {
@include carbon--type-style('productive-heading-06');
}
Expand Down Expand Up @@ -5743,26 +5773,13 @@ Include a type reset for a given body and mono font family
em {
font-style: italic;
}

strong {
@include carbon--font-weight('semibold');
}
}
```

</details>

- **Parameters**:

| Name | Description | Type | Default value |
| ------------------- | ----------------------------------------------------------------------------------- | -------- | ----------------------------- |
| `$base-font-size` | The base font size for your document | `Number` | `$carbon--base-font-size` |
| `$body-font-family` | The font family used on the `<body>` element | `String` | `carbon--font-family('sans')` |
| `$mono-font-family` | The font family used on elements that require mono fonts, like the `<code>` element | `String` | `carbon--font-family('mono')` |

- **Group**: [@carbon/type](#carbontype)
- **Requires**:
- [carbon--font-weight [mixin]](#carbon--font-weight-mixin)
- [carbon--type-style [mixin]](#carbon--type-style-mixin)

### ✅carbon--font-face-sans [mixin]
Expand Down Expand Up @@ -7922,4 +7939,4 @@ fixed contexts.
- [tokens [variable]](#tokens-variable)
- **Used by**:
- [carbon--type-classes [mixin]](#carbon--type-classes-mixin)
- [carbon--type-reset [mixin]](#carbon--type-reset-mixin)
- [carbon--default-type [mixin]](#carbon--default-type-mixin)
Loading