Skip to content

Commit

Permalink
feat: context supplements a (#569)
Browse files Browse the repository at this point in the history
* adding context enhancements scoping and new elements

* adding some of context styling

* fixing the tests now failing due to the scoped contexts

* fixing the note to most recent design

* fixing CR remarks
  • Loading branch information
gullerya committed Jan 13, 2021
1 parent 1af6d9d commit a3f4a2c
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 62 deletions.
1 change: 1 addition & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import vvdContext from '@vonage/vvd-context';
vvdContext.mount()
.then(() => console.info('init Vivid core done (preview frame)'))
.catch(e => console.error(e));
document.body.classList.add('vivid-scope-tmp');

async function run() {
setCustomElements(customElements);
Expand Down
43 changes: 34 additions & 9 deletions common/context/src/partials/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,42 @@
padding: 0;
}

pre,
code {
padding: 3px 4px;
border-radius: 6px;
}
.vivid-scope-tmp {
pre,
code,
kbd,
samp,
var {
padding: 3px 4px;
border-radius: 6px;
}

pre {
overflow: auto;

code,
kbd,
samp,
var {
padding: initial;
}
}

blockquote {
margin-left: 0;
margin-right: 0;
padding: 20px 22px;
border-radius: 6px;

pre {
overflow: auto;
:first-child {
margin-block-start: 0;
padding-block-start: 0;
}

code {
padding: initial;
:last-child {
margin-block-end: 0;
padding-block-end: 0;
}
}
}
}
36 changes: 27 additions & 9 deletions common/context/src/partials/_theme.scss
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
@use '@vonage/vvd-design-tokens/build/scss/semantic-variables/scheme-variables';
@use '@vonage/vvd-foundation/scss/variable-names/color-base-variable-names' as color-base;
@use '@vonage/vvd-foundation/scss/variable-names/color-semantic-variable-names' as color-semantic;
@use '@vonage/vvd-foundation/scss/mixins/color-connotation-mixins' with (
$connotations: success alert warning info announcement
);

@mixin scheme-variables-coupling {
body {
background-color: var(#{scheme-variables.$vvd-color-base});
color: var(#{scheme-variables.$vvd-color-on-base});
}

a {
color: color-base.$purple-600;
}
.vivid-scope-tmp {
a {
color: color-base.$purple-600;
}

code {
background-color:var(#{scheme-variables.$vvd-color-surface});
color: color-base.$orange-600;
}
code,
kbd,
samp,
var {
background-color:var(#{scheme-variables.$vvd-color-surface});
color: color-base.$orange-600;
}

pre {
background-color:var(#{scheme-variables.$vvd-color-surface});
}

pre {
background-color:var(#{scheme-variables.$vvd-color-surface});
blockquote {
border-inline-start: 8px solid var(#{color-semantic.$vvd-color-connotation});
box-shadow: inset 0 1px 0 0 #b3b3b3, inset 0 -1px 0 0 #b3b3b3, inset -1px 0 0 0 #b3b3b3;
}
@include color-connotation-mixins.connotations-context(
'blockquote#{color-connotation-mixins.$connotation-placeholder}',
'info'
);
}
}
91 changes: 48 additions & 43 deletions common/context/src/partials/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,53 @@
@include typography.typography-cat-shorthand('body-1');
}

h1 {
@include typography.typography-cat-shorthand('headline-1');
}

h2 {
@include typography.typography-cat-shorthand('headline-2');
}

h3 {
@include typography.typography-cat-shorthand('title-1');
}

h4 {
@include typography.typography-cat-shorthand('title-2');
}

h5 {
@include typography.typography-cat-shorthand('subtitle-1');
}

h6 {
@include typography.typography-cat-shorthand('subtitle-2');
}

code,
kbd,
samp {
font-family: 'SpeziaMonoWebVariable', monospace;
}

b,
strong {
font-weight: 600;
.vivid-scope-tmp {
h1 {
@include typography.typography-cat-shorthand('headline-1');
}

h2 {
@include typography.typography-cat-shorthand('headline-2');
}

h3 {
@include typography.typography-cat-shorthand('title-1');
}

h4 {
@include typography.typography-cat-shorthand('title-2');
}

h5 {
@include typography.typography-cat-shorthand('subtitle-1');
}

h6 {
@include typography.typography-cat-shorthand('subtitle-2');
}

code,
kbd,
samp,
var {
font-family: 'SpeziaMonoWebVariable', monospace;
}

b,
strong {
font-weight: 600;
}

small {
@include typography.typography-cat-shorthand('body-2');
}

a {
text-decoration: underline;
}

blockquote {
@include typography.typography-cat-shorthand('body-2');
}
}

a {
text-decoration: underline;
}

var {
font-family: 'SpeziaMonoWebVariable', monospace;
display: block;
border-radius: 4px;
}
}
3 changes: 3 additions & 0 deletions common/context/test/context-typography.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ describe('vvd-context typography', () => {
it(`should have '${deviatingElement}' element styled withing '${contextElement}'`, async () => {
const iframe = await setupLocalIframe();
const d = iframe.contentWindow.document;

d.body.classList.add('vivid-scope-tmp');

await vvdContext.mount(d);

const ce = d.createElement(contextElement);
Expand Down
18 changes: 17 additions & 1 deletion common/foundation/scss/mixins/_color-connotation-mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $allConnotations: (
);

// selector can be altered by relevance
@mixin connotations-context($selector: ':host(#{$connotation-placeholder})') {
@mixin connotations-context($selector: ':host(#{$connotation-placeholder})', $default-fallback: null) {
@each $connotation in functions.pick($connotations, $allConnotations) {
$attr: '[connotation="#{$connotation}" i]';

Expand All @@ -38,4 +38,20 @@ $allConnotations: (
);
}
}

// add default fallback if/when required
@if ($default-fallback) {
$processed-selector: selector.replace(
#{$selector},
#{$connotation-placeholder},
':not([connotation])'
);

#{$processed-selector} {
#{color-semantic.$vvd-color-connotation}: var(--vvd-color-#{$default-fallback});
#{color-semantic.$vvd-color-on-connotation}: var(
--vvd-color-on-#{$default-fallback}
);
}
}
}

0 comments on commit a3f4a2c

Please sign in to comment.