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): add light styles for all variations and update storybook knobs #4342

Merged
merged 19 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b628bff
fix(code-snippet): add light styles for all variations
Oct 15, 2019
5bfa758
docs(code-snippet): add light prop knob for single and multi-line
Oct 15, 2019
b21ea99
docs(code-snippet): fix typo in light prop description
Oct 15, 2019
f6acf52
Merge branch 'master' into code-snippet--light
jendowns Oct 15, 2019
59281da
Merge branch 'master' into code-snippet--light
jendowns Oct 16, 2019
fb3a6be
docs(code-snippet): add msg & bg when light prop knob is used
Oct 17, 2019
7570882
Merge branch 'master' into code-snippet--light
jendowns Oct 17, 2019
c94ed8e
docs(code-snippet): adjust template strings in story for prettier
Oct 17, 2019
e9500f5
docs(code-snippet): adjust light prop message styling
Oct 17, 2019
8fa40d4
docs(code-snippet): update light prop usage message
Oct 17, 2019
2f4282e
Merge branch 'master' into code-snippet--light
joshblack Oct 21, 2019
f9f2e52
Merge branch 'master' into code-snippet--light
jendowns Oct 21, 2019
00fc911
Merge branch 'master' into code-snippet--light
jendowns Oct 22, 2019
6d85473
fix(theme-tokens): add hover-ui-light theme token and function
jendowns Oct 23, 2019
0aa8d97
fix(theme-tokens): use feature-flags-enabled in get-light-value function
jendowns Oct 24, 2019
9bed966
fix(theme-tokens): use custom-property-prefix in get-light-value func…
jendowns Oct 24, 2019
450626e
Merge branch 'master' into code-snippet--light
jendowns Oct 24, 2019
d2e186b
fix(code-snippet): flatten all light variation styles
jendowns Oct 24, 2019
baf682e
Merge branch 'master' into code-snippet--light
joshblack Oct 25, 2019
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
28 changes: 20 additions & 8 deletions packages/components/src/components/code-snippet/_code-snippet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@
padding: 0 $spacing-xs;
}

.#{$prefix}--snippet--inline.#{$prefix}--snippet--light {
background-color: $field-02;

&:hover {
background-color: rgba($interactive-02, 0.1);
jendowns marked this conversation as resolved.
Show resolved Hide resolved
}
}

// Single Line Snippet
.#{$prefix}--snippet--single {
@include bx--snippet;
Expand Down Expand Up @@ -266,6 +258,26 @@
transition: transform $transition--expansion;
}

// Light version
.#{$prefix}--snippet.#{$prefix}--snippet--light {
&,
jendowns marked this conversation as resolved.
Show resolved Hide resolved
.#{$prefix}--snippet-button,
.#{$prefix}--snippet-btn--expand {
background-color: $ui-02;
}

&.#{$prefix}--snippet--inline:hover,
.#{$prefix}--snippet-button:hover,
.#{$prefix}--snippet-btn--expand:hover {
background-color: $ui-01;
}

&.#{$prefix}--snippet--single::after,
&.#{$prefix}--snippet--multi .#{$prefix}--snippet-container pre::after {
background-image: linear-gradient(to right, transparent, $ui-02);
}
}

// Skeleton State
.#{$prefix}--snippet--code.#{$prefix}--skeleton {
height: rem(98px);
Expand Down
43 changes: 36 additions & 7 deletions packages/react/src/components/CodeSnippet/CodeSnippet-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const props = {
),
}),
single: () => ({
light: boolean('Light variant (light)', false),
feedback: text('Feedback text (feedback)', 'Feedback Enabled 👍'),
copyButtonDescription: text(
'Copy icon description (copyButtonDescription)',
Expand All @@ -35,6 +36,7 @@ const props = {
onClick: action('onClick'),
}),
multiline: () => ({
light: boolean('Light variant (light)', false),
feedback: text('Feedback text (feedback)', 'Feedback Enabled 👍'),
showMoreText: text(
'Text for "show more" button (showMoreText)',
Expand All @@ -48,12 +50,33 @@ const props = {
}),
};

const lightPropMessage = (
<small style={{ display: 'block', paddingBottom: '1rem' }}>
The snippet container should never be the same color as the page background.
<br />
{'Do not use the'}
<CodeSnippet type="inline" light>
light
</CodeSnippet>
{' variant on '}
<CodeSnippet type="inline" light>
$ui-background
</CodeSnippet>
{' or '}
<CodeSnippet type="inline" light>
$ui-02
</CodeSnippet>
.
</small>
);

storiesOf('CodeSnippet', module)
.addDecorator(withKnobs)
.add(
'inline',
() => (
<div>
<div className={props.inline().light ? 'bx--tile' : ''}>
{props.inline().light && lightPropMessage}
<CodeSnippet type="inline" {...props.inline()}>
{'node -v'}
</CodeSnippet>
Expand All @@ -72,11 +95,14 @@ storiesOf('CodeSnippet', module)
.add(
'single line',
() => (
<CodeSnippet type="single" {...props.single()}>
{
'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!'
}
</CodeSnippet>
<div className={props.single().light ? 'bx--tile' : ''}>
{props.single().light && lightPropMessage}
<CodeSnippet type="single" {...props.single()}>
{
'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!'
}
</CodeSnippet>
</div>
),
{
info: {
Expand All @@ -93,7 +119,10 @@ storiesOf('CodeSnippet', module)
() => {
const multilineProps = props.multiline();
return (
<div style={{ width: '800px' }}>
<div
className={multilineProps.light ? 'bx--tile' : ''}
style={{ width: '800px' }}>
{multilineProps.light && lightPropMessage}
<CodeSnippet type="multi" {...multilineProps}>
{`@mixin grid-container {
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/CodeSnippet/CodeSnippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class CodeSnippet extends Component {

/**
* Specify whether you are using the light variant of the Code Snippet,
* typically used for inline snippest to display an alternate color
* typically used for inline snippet to display an alternate color
*/
light: PropTypes.bool,
};
Expand Down