Skip to content

(PDS-380) Add Inconsolata as monospace font #176

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

Merged
merged 3 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Expand Up @@ -28,6 +28,7 @@ const highlight = element => <span style={style}>{element}</span>;
<h4>{highlight('h4')} has 8px bottom margin.</h4>
<h5>{highlight('h5')} has 8px bottom margin.</h5>
<h6>{highlight('h6')} has 8px bottom margin.</h6>
<code>{highlight('`code`')} uses a monospace font</code>
</Content>;
```

Expand Down
5 changes: 5 additions & 0 deletions packages/react-components/source/react/library/text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const propTypes = {
size: PropTypes.oneOf(['medium', 'small', 'tiny']),
/** Text color */
color: PropTypes.oneOf(['subtle', 'medium', 'danger', 'warning', 'success']),
/** Use monospace for code block */
code: PropTypes.bool,
/** Text body */
children: PropTypes.node,
/** Optional additional classname. */
Expand All @@ -23,13 +25,15 @@ const defaultProps = {
className: '',
size: 'medium',
color: null,
code: false,
style: {},
};

const Text = ({
as: Element,
size,
color,
code,
children,
className,
style,
Expand All @@ -38,6 +42,7 @@ const Text = ({
<Element
className={classNames(
'rc-text',
{ 'rc-text-code': code },
{
[`rc-text-size-${size}`]: size,
[`rc-text-${color}`]: color,
Expand Down
12 changes: 12 additions & 0 deletions packages/react-components/source/react/library/text/Text.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ The primary (default) text is categorized as Body text, used for page content.
<Text>Default text size</Text>
```

### Monospace

Monospace font should be used for codeblocks.

- Font Family: Inconsolata
- Font weight: 400 Regular
- Size / line height: 14px / 20px

```jsx
<Text code>This is a codeblock</Text>
```

## Variations

### Text sizes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
@include puppet-type-h6();
}

code {
@include puppet-type-code();
}

h1,
h2,
h3 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
@include puppet-type-tiny();
}

.rc-text-code {
@include puppet-type-code();
}

@each $color, $code in $puppet-type-colors {
.rc-text-#{$color} {
color: $code;
Expand Down
16 changes: 16 additions & 0 deletions packages/sass-variables/_fonts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,19 @@
src: url('./fonts/CalibreWeb-SemiboldItalic.woff2') format('woff2'),
url('./fonts/CalibreWeb-SemiboldItalic.woff') format('woff');
}

@font-face {
font-family: Inconsolata;
font-style: normal;
font-weight: 400;
src: url('./fonts/Inconsolata-Regular.woff2') format('woff2'),
url('./fonts/Inconsolata-Regular.woff') format('woff');
}

@font-face {
font-family: Inconsolata;
font-style: normal;
font-weight: 700;
src: url('./fonts/Inconsolata-Bold.woff2') format('woff2'),
url('./fonts/Inconsolata-Bold.woff') format('woff');
}
17 changes: 17 additions & 0 deletions packages/sass-variables/_typography.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Common font families
$puppet-type-font-family: 'Open Sans', sans-serif !default;
$puppet-type-font-family-secondary: 'Calibre', sans-serif !default;
$puppet-type-font-family-monospace: 'Inconsolata', monospace !default;

// Common weights
$puppet-type-weight-normal: 400 !default;
Expand Down Expand Up @@ -96,6 +97,16 @@ $puppet-type-label-line-height: calc(16 / 11) !default;
$puppet-type-label-font-family: $puppet-type-font-family-secondary !default;
$puppet-type-label-font-weight: $puppet-type-weight-heavy !default;

$puppet-type-code-font-size: 14px !default;
$puppet-type-code-line-height: calc(20 / 14) !default;
$puppet-type-code-font-family: $puppet-type-font-family-monospace !default;
$puppet-type-code-font-weight: 400 !default;

$puppet-type-code-bold-font-size: 14px !default;
$puppet-type-code-bold-line-height: calc(20 / 14) !default;
$puppet-type-code-bold-font-family: $puppet-type-font-family-monospace !default;
$puppet-type-code-bold-font-weight: 700 !default;

@mixin puppet-type-hero($color: base) {
color: map-get($puppet-type-colors, $color);
font-family: $puppet-type-hero-font-family;
Expand Down Expand Up @@ -201,6 +212,12 @@ $puppet-type-label-font-weight: $puppet-type-weight-heavy !default;
text-transform: uppercase;
}

@mixin puppet-type-code($color: base) {
color: map-get($puppet-type-colors, $color);
font-family: $puppet-type-code-font-family;
font-weight: $puppet-type-code-font-weight;
}

@mixin puppet-type-link() {
color: $puppet-type-color-link;
cursor: pointer;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.