Skip to content

Commit

Permalink
feat(layout-modules): add withBackground higher-order component (#851)
Browse files Browse the repository at this point in the history
* feat(layout-modules): add `withBackground` higher-order component

* chore: merge `dev` into `with-background`
  • Loading branch information
SimonFinney authored Dec 3, 2020
1 parent cfad653 commit 79c0077
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 19 deletions.
14 changes: 0 additions & 14 deletions .storybook/components/Background/_index.scss

This file was deleted.

2 changes: 0 additions & 2 deletions .storybook/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
@import 'decorators/index';
@import 'docs/index';

@import 'components/Background/index';

* {
box-sizing: border-box;
}
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/scss/__snapshots__/SCSS.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26179,6 +26179,11 @@ a.bx--navigation-link:focus {
margin-left: auto;
}

.security--unstable--layout__module--background {
background-color: var(--ui-01, #262626);
outline: 0.0625rem solid var(--ui-background, #161616);
}

.security--unstable--layout__module--button-cluster {
padding-bottom: 1rem;
}
Expand Down
17 changes: 17 additions & 0 deletions src/components/UNSTABLE__LayoutModules/Background/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
////
/// Background.
/// @group background
/// @copyright IBM Security 2020
////

@import '@carbon/themes/scss/tokens';

@import '../../../globals/border/index';

@import '../../Component/mixins';
@import '../variables';

@include security--component($name: #{$layout-modules__name}--background) {
background-color: $ui-01;
outline: $border__sizing__width solid $ui-background;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import classnames from 'classnames';
import React from 'react';

import { layoutModuleNamespace } from '../LayoutModule';

export default WrappedComponent => {
const WithBackground = ({ className, ...other }) => (
<WrappedComponent
className={classnames('container--background', className)}
className={classnames(`${layoutModuleNamespace}--background`, className)}
{...other}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { List16, Search16, Table16 } from '@carbon/icons-react';
import React from 'react';

import { getDocsParameters } from '../../../../.storybook';
import withBackground from '../../../../.storybook/components/Background';

import {
ActionBarModule,
Expand All @@ -20,6 +19,7 @@ import {
SummaryCardBody,
SummaryCardHeader,
TitleBarModule,
withBackground,
} from '../../..';

import getTitle from '../stories';
Expand Down
2 changes: 1 addition & 1 deletion src/components/UNSTABLE__LayoutModules/Layout.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { Grid, Row, Column } from 'carbon-components-react';
import React from 'react';

import { disableCentered, patterns } from '../../../.storybook';
import withBackground from '../../../.storybook/components/Background';

import {
ActionBarModule,
Expand Down Expand Up @@ -46,6 +45,7 @@ import {
TypeLayoutBody,
TypeLayoutCell,
TypeLayoutRow,
withBackground,
} from '../..';

const ColumnWithBackground = withBackground(Column);
Expand Down
1 change: 1 addition & 0 deletions src/components/UNSTABLE__LayoutModules/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
////

@import 'ActionBarModule/index';
@import 'Background/index';
@import 'ButtonClusterModule/index';
@import 'CardModule/index';
@import 'DescriptionListModule/index';
Expand Down
1 change: 1 addition & 0 deletions src/components/UNSTABLE__LayoutModules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
ActionBarModuleItems,
} from './ActionBarModule';

export { default as withBackground } from './Background';
export { default as ButtonClusterModule } from './ButtonClusterModule';
export { default as CardModule } from './CardModule';
export { default as DescriptionListModule } from './DescriptionListModule';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14039,5 +14039,6 @@ Map {
},
},
},
"withBackground" => Object {},
}
`;
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export {
DescriptionModule,
ICAModule,
TitleBarModule,
withBackground,
} from './components/UNSTABLE__LayoutModules';

export UNSTABLE__Pagination, {
Expand Down

0 comments on commit 79c0077

Please sign in to comment.