Skip to content

Commit

Permalink
Merge pull request #123 from eecs485staff/callouts/neutral-default
Browse files Browse the repository at this point in the history
[Callouts] Add neutral variant
  • Loading branch information
seshrs authored Apr 27, 2021
2 parents c0b107b + 0b9b546 commit f74e0d7
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 13 deletions.
40 changes: 28 additions & 12 deletions _sass/spec/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@ li.task-list-item .task-list-item-checkbox {
*/

$CALLOUT_VARIANTS: (
'neutral': (
'bg': #f6f8fa,
'border': #e1e4e8,
'color': inherit,
'icon': '',
),
'info': (
'bg': #dbedff,
'border': rgba(4, 66, 137, 0.2),
Expand Down Expand Up @@ -529,27 +535,37 @@ $CALLOUT_VARIANTS: (
),
);

@mixin calloutVariantProps($variant, $props) {
background-color: var(
--primer-spec-callout-#{$variant}-bg-color,
map-get($props, 'bg')
);
border-color: var(
--primer-spec-callout-#{$variant}-border-color,
map-get($props, 'border')
);
color: var(
--primer-spec-callout-#{$variant}-text-color,
map-get($props, 'color')
);
}

.primer-spec-callout {
position: relative;
padding: 20px 16px;
border-style: solid;
border-width: 1px;
border-radius: 6px;

// By default, use the neutral callout styles
@include calloutVariantProps(
'neutral',
map-get($CALLOUT_VARIANTS, 'neutral')
);

@each $variant, $props in $CALLOUT_VARIANTS {
&.#{$variant} {
background-color: var(
--primer-spec-callout-#{$variant}-bg-color,
map-get($props, 'bg')
);
border-color: var(
--primer-spec-callout-#{$variant}-border-color,
map-get($props, 'border')
);
color: var(
--primer-spec-callout-#{$variant}-text-color,
map-get($props, 'color')
);
@include calloutVariantProps($variant, $props);
}
}
}
Expand Down
19 changes: 18 additions & 1 deletion demo/callouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,32 @@ int main() {
</div>
```

Primer Spec offers four variants of callouts:
Primer Spec offers five variants of callouts:

- `neutral`
- `info`
- `warning`
- `danger`
- `sucess`

See below for examples of each of these callouts.

### `neutral`

<div class="primer-spec-callout" markdown="1">
_**Pro tip:** Use this to create a simple note box. It's weaker than `info`, but offers stronger emphasis than main body text._
</div>

<details markdown="1">
<summary><code>neutral</code> source</summary>

```markdown
<div class="primer-spec-callout" markdown="1">
_**Pro tip:** Use this to create a simple note box. It's weaker than `info`, but offers stronger emphasis than main body text._
</div>
```
</details>

### `info`

<div class="primer-spec-callout info" markdown="1">
Expand Down
3 changes: 3 additions & 0 deletions src_js/subthemes/Subtheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export const SUBTHEME_VARS = [
'--main-blockquote-text-border',
'--main-header-border-bottom-color',

'--primer-spec-callout-neutral-bg-color',
'--primer-spec-callout-neutral-text-color',
'--primer-spec-callout-neutral-border-color',
'--primer-spec-callout-info-bg-color',
'--primer-spec-callout-info-text-color',
'--primer-spec-callout-info-border-color',
Expand Down
3 changes: 3 additions & 0 deletions src_js/subthemes/definitions/common_dark_theme_colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export default {
'--main-blockquote-text-border': '#3b434b',
'--main-header-border-bottom-color': BORDER_LINE_COLOR,

'--primer-spec-callout-neutral-bg-color': 'rgba(22, 27, 34, 0.8)',
'--primer-spec-callout-neutral-text-color': MAIN_TEXT_COLOR,
'--primer-spec-callout-neutral-border-color': 'rgb(48, 54, 61)',
'--primer-spec-callout-info-bg-color': 'rgba(56, 139, 253, 0.1)',
'--primer-spec-callout-info-text-color': '#79c0ff',
'--primer-spec-callout-info-border-color': 'rgba(56, 139, 253, 0.4)',
Expand Down
1 change: 1 addition & 0 deletions src_js/subthemes/definitions/xcode_civic.theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const xcode_dark_theme_vars: SubthemeDefinitionType = {
'--tt-border-radius': '3px',
'--main-header-border-bottom-color': BORDER_LINE_COLOR,

'--primer-spec-callout-neutral-text-color': 'black',
'--primer-spec-callout-info-text-color': 'black',
'--primer-spec-callout-warning-text-color': 'black',
'--primer-spec-callout-danger-text-color': 'black',
Expand Down

0 comments on commit f74e0d7

Please sign in to comment.