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(code-snippet): Update templates #779

Merged
merged 8 commits into from
May 17, 2018
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion demo/scss/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ td {
}

& > *:not(.component-example):not(.component-variation),
& > {
& > {
button {
border-radius: 0;
}
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ gulp.task('sass:source', () => {
});

gulp.task('html:source', () =>
templates.render({ preview: 'NONE' }).then(renderedItems => {
templates.render().then(renderedItems => {
const promises = [];
renderedItems.forEach((rendered, item) => {
const dirname = path.dirname(path.resolve(__dirname, 'html', item.relViewPath));
Expand Down
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ app.get('/component/:component', (req, res) => {
res.status(404).end();
} else {
templates
.render({ defaultPreview: 'preview', concat: true }, name)
.render({ layout: 'preview', concat: true }, name)
.then(rendered => {
// eslint-disable-next-line eqeqeq
if (rendered == null) {
Expand All @@ -117,7 +117,7 @@ app.get('/code/:component', (req, res) => {
res.status(404).end();
} else {
templates
.render({ preview: 'NONE' }, name)
.render({}, name)
.then(renderedItems => {
const o = {};
renderedItems.forEach((rendered, item) => {
Expand Down
43 changes: 42 additions & 1 deletion src/components/code-snippet/_code-snippet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@
display: flex;
align-items: center;
height: 130%;
white-space: nowrap;
overflow-x: scroll;
position: relative;
padding-bottom: $spacing-md;
}

.#{$prefix}--snippet--single pre {
white-space: nowrap;
}

// Multi Line Snippet
.#{$prefix}--snippet--multi {
@include bx--snippet;
Expand Down Expand Up @@ -165,6 +168,44 @@
transform: rotate(180deg);
}

// Skeleton

#{$prefix}--snippet--multi.#{$prefix}--skeleton {
height: rem(98px);
}

.#{$prefix}--snippet--single.#{$prefix}--skeleton {
height: rem(56px);
}

.#{$prefix}--snippet.#{$prefix}--skeleton .#{$prefix}--snippet-container {
height: 100%;
}

.#{$prefix}--snippet.#{$prefix}--skeleton span {
@include skeleton;
width: 100%;
height: 1rem;
display: block;
margin-top: 0.5rem;

&:first-child {
margin: 0;
}

&:nth-child(2) {
width: 85%;
}

&:nth-child(3) {
width: 95%;
}
}

.#{$prefix}--snippet--single.#{$prefix}--skeleton .#{$prefix}--snippet-container {
padding-bottom: 0;
}

/*
Deprecated class names will be removed in v10.x
*/
Expand Down
40 changes: 33 additions & 7 deletions src/components/code-snippet/code-snippet.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,52 @@ module.exports = {
variants: [
{
name: 'default',
label: 'Code',
label: 'Single Line',
notes: `
Code snippets are small blocks of reusable code that can be inserted in a code file.
The Code style is for larger, multi-line code snippets.
The Single style is for single-line code snippets.
`,
context: {
variant: 'code',
variant: 'single',
},
},
{
name: 'terminal',
label: 'Terminal',
name: 'multi',
label: 'Multi Line',
notes: `
Code snippets are small blocks of reusable code that can be inserted in a code file.
The Terminal style is for single-line .
The Multi-line style is for larger code blocks.
`,
context: {
variant: 'terminal',
variant: 'multi',
},
},
{
name: 'inline',
label: 'Inline',
notes: `
Code snippets are small blocks of reusable code that can be inserted in a code file.
The inline style is for code blocks within a block of text on a white background.
`,
context: {
variant: 'inline',
light: 'false',
},
},
{
name: 'inline-light',
label: 'Inline Light',
notes: `
Code snippets are small blocks of reusable code that can be inserted in a code file.
The inline style is for code blocks within a block of text.
`,
context: {
variant: 'inline',
light: 'true',
},
},
],
Expand Down
82 changes: 50 additions & 32 deletions src/components/code-snippet/code-snippet.hbs
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
<div class="bx--snippet bx--snippet--{{variant}}">
<div class="bx--snippet-container">
{{#is variant "code"}}
<code>
<pre>
@mixin bx--snippet($type) {
@if $type == 'terminal' {
background-color: red;
} @else if $type == 'code' {
background-color: blue;
} @else if $type == 'text' {
background-color: white;
}
{{#is variant "inline"}}
<p>Here is an example of a text that a user would be reading. In this paragraph would be
<button data-copy-btn="" class="bx--snippet bx--snippet--inline {{#if light}} bx--snippet--light{{/if}}" aria-label="Copy code" tabindex="0">
<code>inline code</code>
<div class="bx--btn--copy__feedback" data-feedback="Copied!"></div>
</button>
that the user could look at and copy in to their code editor.</p>
{{else}}

<div class="bx--snippet bx--snippet--{{variant}}" {{#is variant "multi"}}data-code-snippet{{/is}}>
<div class="bx--snippet-container">

@if $type == 'terminal' {
background-color: red;
} @else if $type == 'code' {
background-color: blue;
} @else if $type == 'text' {
background-color: white;
<pre>
<code>
@mixin grid-container {
width: 100%;
padding-right: padding(mobile);
padding-left: padding(mobile);

@include breakpoint(bp--xs--major) {
padding-right: padding(xs);
padding-left: padding(xs);
}
}
}
</pre>
</code>
{{else}}
<pre><code>node -v Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, veritatis voluptate id incidunt molestiae officia possimus, quasi itaque alias, architecto hic, dicta fugit? Debitis delectus quidem explicabo vitae fuga laboriosam!</code></pre>

$z-indexes: (
modal : 9000,
overlay : 8000,
dropdown : 7000,
header : 6000,
footer : 5000,
hidden : - 1,
overflowHidden: - 1,
floating: 10000
);

</code>
</pre>
</div>
<button data-copy-btn class="bx--snippet-button" aria-label="Copy code" tabindex="0">
<svg class="bx--snippet__icon" width="18" height="24" viewBox="0 0 18 24" fill-rule="evenodd">
<path d="M13 5V0H0v19h5v5h13V5h-5zM2 17V2h9v3H5v12H2zm14 5H7V7h9v15z"></path>
<path d="M9 9h5v2H9zM9 12h5v2H9zM9 15h3v2H9z"></path>
</svg>
<div class="bx--btn--copy__feedback" data-feedback="Copied!"></div>
</button>
{{#is variant "multi"}}
<button class="bx--btn bx--btn--ghost bx--btn--sm bx--snippet-btn--expand" type="button">
<span class="bx--snippet-btn--text" data-show-more-text="Show more" data-show-less-text="Show less">Show more</span>
<svg class="bx--icon-chevron--down" width='12' height='8' viewBox='0 0 12 8' fill-rule='evenodd' aria-label="Show more icon" alt="Show more icon"><title>Show more icon</title><path d='M10.6 0L6 4.7 1.4 0 0 1.4l6 6.1 6-6.1z'></path></svg>
</button>
{{/is}}
</div>
<button data-copy-btn class="bx--snippet-button" aria-label="Copy code" tabindex="0">
<svg class="bx--snippet__icon" width="18" height="24" viewBox="0 0 18 24" fill-rule="evenodd">
<path d="M13 5V0H0v19h5v5h13V5h-5zM2 17V2h9v3H5v12H2zm14 5H7V7h9v15z"></path>
<path d="M9 9h5v2H9zM9 12h5v2H9zM9 15h3v2H9z"></path>
</svg>
<div class="bx--btn--copy__feedback" data-feedback="Copied!"></div>
</button>
</div>
{{/is}}
6 changes: 0 additions & 6 deletions src/components/code-snippet/inline-code-snippet-light.html

This file was deleted.

7 changes: 0 additions & 7 deletions src/components/code-snippet/inline-code-snippet.html

This file was deleted.

40 changes: 0 additions & 40 deletions src/components/code-snippet/multi-line-code-snippet.html

This file was deleted.

12 changes: 0 additions & 12 deletions src/components/code-snippet/single-line-code-snippet.html

This file was deleted.

12 changes: 6 additions & 6 deletions src/globals/scss/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ $padding: (
}

$z-indexes: (
modal : 9000,
overlay : 8000,
dropdown : 7000,
header : 6000,
footer : 5000,
hidden : - 1,
modal: 9000,
overlay: 8000,
dropdown: 7000,
header: 6000,
footer: 5000,
hidden: - 1,
overflowHidden: - 1,
floating: 10000
);
Expand Down
44 changes: 22 additions & 22 deletions src/globals/scss/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ $font-family-helvetica: 'IBM Helvetica', Helvetica Neue, HelveticaNeue, Helvetic
$base-font-size: 16px !default; // Default, Use with em() and rem() functions

$typescale-map: (
'giga' : 4.75rem,
'mega' : 3.375rem,
'alpha' : 2.25rem,
'beta' : 1.75rem,
'gamma' : 1.25rem,
'delta' : 1.125rem,
'epsilon' : 1rem,
'zeta' : 0.875rem,
'omega' : 0.75rem,
'caption' : 0.75rem,
'legal' : 0.6875rem,
'p' : 1rem
'giga': 4.75rem,
'mega': 3.375rem,
'alpha': 2.25rem,
'beta': 1.75rem,
'gamma': 1.25rem,
'delta': 1.125rem,
'epsilon': 1rem,
'zeta': 0.875rem,
'omega': 0.75rem,
'caption': 0.75rem,
'legal': 0.6875rem,
'p': 1rem
);

@mixin typescale($size) {
Expand Down Expand Up @@ -72,16 +72,16 @@ $typescale-map: (
}

$font-size-map: (
'76' : 4.75rem,
'54' : 3.375rem,
'36' : 2.25rem,
'28' : 1.75rem,
'20' : 1.25rem,
'18' : 1.125rem,
'16' : 1rem,
'14' : 0.875rem,
'12' : 0.75rem,
'11' : 0.6875rem
'76': 4.75rem,
'54': 3.375rem,
'36': 2.25rem,
'28': 1.75rem,
'20': 1.25rem,
'18': 1.125rem,
'16': 1rem,
'14': 0.875rem,
'12': 0.75rem,
'11': 0.6875rem
);

@mixin font-size($size) {
Expand Down