Skip to content

Commit

Permalink
Replace use of utility classes in components with component classes. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal authored Jul 27, 2017
1 parent bd9659a commit 481922e
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 20 deletions.
28 changes: 28 additions & 0 deletions ui_framework/dist/ui_framework.css
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ table {
height: 64px; }

.kuiHeader {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
background: #FFF;
border-bottom: 1px solid #D9D9D9; }

Expand Down Expand Up @@ -398,6 +402,12 @@ table {
width: 24px;
opacity: 1; }

.kuiHeaderBreadcrumbs {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex; }

.kuiHeaderBreadcrumb {
display: inline-block;
height: 64px;
Expand Down Expand Up @@ -449,6 +459,23 @@ table {
.kuiHeaderBreadcrumb {
display: none; } }

.kuiHeaderSection {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex; }

.kuiHeaderSection--left {
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
flex-grow: 1; }

.kuiHeaderSection--right {
-webkit-flex-shrink: 1;
-ms-flex-negative: 1;
flex-shrink: 1; }

.kuiHeaderSectionItem {
position: relative; }
.kuiHeaderSectionItem:hover {
Expand Down Expand Up @@ -589,6 +616,7 @@ table {
margin-top: 8px; }

.kuiPopover__body {
box-shadow: 0 16px 16px -8px rgba(0, 0, 0, 0.1);
background: #FFF;
position: absolute;
min-width: 256px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`KuiHeader is rendered 1`] = `
<div
aria-label="aria-label"
class="kuiHeader kui--flex testClass1 testClass2"
class="kuiHeader testClass1 testClass2"
data-test-subj="test subject string"
/>
`;
1 change: 1 addition & 0 deletions ui_framework/src/components/header/_header.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Header. Includes breadcrumbs of nav buttons.

.kuiHeader {
display: flex;
background: $kuiHeaderBackgroundColor;
border-bottom: $kuiBorderThin;
}
Expand Down
2 changes: 1 addition & 1 deletion ui_framework/src/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import classNames from 'classnames';

export const KuiHeader = ({ children, className, ...rest }) => {
const classes = classNames('kuiHeader kui--flex', className);
const classes = classNames('kuiHeader', className);

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`KuiHeaderBreadcrumbs is rendered 1`] = `
<div
aria-label="aria-label"
class="kui--flex testClass1 testClass2"
class="kuiHeaderBreadcrumbs testClass1 testClass2"
data-test-subj="test subject string"
/>
`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Breadcrumb navigation included in the header.

.kuiHeaderBreadcrumbs {
display: flex;
}

.kuiHeaderBreadcrumb {
display: inline-block;
height: $kuiHeaderChildSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import classNames from 'classnames';

export const KuiHeaderBreadcrumbs = ({ children, className, ...rest }) => {
const classes = classNames('kui--flex', className);
const classes = classNames('kuiHeaderBreadcrumbs', className);

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
exports[`KuiHeaderSection is rendered 1`] = `
<div
aria-label="aria-label"
class="kuiHeaderSection kui--flexGrow1 kui--flex testClass1 testClass2"
class="kuiHeaderSection kuiHeaderSection--left testClass1 testClass2"
data-test-subj="test subject string"
/>
`;

exports[`KuiHeaderSection side defaults to left 1`] = `
<div
class="kuiHeaderSection kui--flexGrow1 kui--flex"
class="kuiHeaderSection kuiHeaderSection--left"
/>
`;

exports[`KuiHeaderSection side renders right 1`] = `
<div
class="kuiHeaderSection kui--flexShrink1 kui--flex"
class="kuiHeaderSection kuiHeaderSection--right"
/>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.kuiHeaderSection {
display: flex;
}

.kuiHeaderSection--left {
flex-grow: 1;
}

.kuiHeaderSection--right {
flex-shrink: 1;
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import 'header_section';
@import 'header_section_item';
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React, {
import classNames from 'classnames';

const sideToClassNameMap = {
left: 'kui--flexGrow1 kui--flex',
right: 'kui--flexShrink1 kui--flex',
left: 'kuiHeaderSection--left',
right: 'kuiHeaderSection--right',
};

const SIDES = Object.keys(sideToClassNameMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`KuiPopover anchorPosition defaults to center 1`] = `
>
<button />
<div
class="kuiPopover__body kui--bottomShadow"
class="kuiPopover__body"
/>
</div>
`;
Expand All @@ -17,7 +17,7 @@ exports[`KuiPopover anchorPosition left is rendered 1`] = `
>
<button />
<div
class="kuiPopover__body kui--bottomShadow"
class="kuiPopover__body"
/>
</div>
`;
Expand All @@ -28,7 +28,7 @@ exports[`KuiPopover anchorPosition right is rendered 1`] = `
>
<button />
<div
class="kuiPopover__body kui--bottomShadow"
class="kuiPopover__body"
/>
</div>
`;
Expand All @@ -39,7 +39,7 @@ exports[`KuiPopover children is rendered 1`] = `
>
<button />
<div
class="kuiPopover__body kui--bottomShadow"
class="kuiPopover__body"
>
Children
</div>
Expand All @@ -54,7 +54,7 @@ exports[`KuiPopover is rendered 1`] = `
>
<button />
<div
class="kuiPopover__body kui--bottomShadow"
class="kuiPopover__body"
/>
</div>
`;
Expand All @@ -65,18 +65,18 @@ exports[`KuiPopover isOpen defaults to false 1`] = `
>
<button />
<div
class="kuiPopover__body kui--bottomShadow"
class="kuiPopover__body"
/>
</div>
`;

exports[`KuiPopover isOpen true is rendered 1`] = `
exports[`KuiPopover isOpen renders true 1`] = `
<div
class="kuiPopover kuiPopover-isOpen"
>
<button />
<div
class="kuiPopover__body kui--bottomShadow"
class="kuiPopover__body"
/>
</div>
`;
2 changes: 2 additions & 0 deletions ui_framework/src/components/popover/_popover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

// Animation happens on the body.
.kuiPopover__body {
@include kuiBottomShadow;

background: $kuiColorEmptyShade;
position: absolute;
min-width: $kuiSize * 16; // Can expand further, but this size is good for our menus.
Expand Down
2 changes: 1 addition & 1 deletion ui_framework/src/components/popover/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class KuiPopover extends Component {
},
);

const bodyClasses = classNames('kuiPopover__body kui--bottomShadow', bodyClassName);
const bodyClasses = classNames('kuiPopover__body', bodyClassName);

const body = (
<div className={bodyClasses}>
Expand Down
9 changes: 8 additions & 1 deletion ui_framework/src/components/popover/popover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('KuiPopover', () => {
const component = render(
<KuiPopover
button={<button />}
closePopover={() => {}}
{ ...requiredProps }
/>
);
Expand All @@ -21,6 +22,7 @@ describe('KuiPopover', () => {
const component = render(
<KuiPopover
button={<button />}
closePopover={() => {}}
>
Children
</KuiPopover>
Expand All @@ -35,6 +37,7 @@ describe('KuiPopover', () => {
const component = render(
<KuiPopover
button={<button />}
closePopover={() => {}}
/>
);

Expand All @@ -46,6 +49,7 @@ describe('KuiPopover', () => {
const component = render(
<KuiPopover
button={<button />}
closePopover={() => {}}
anchorPosition="left"
/>
);
Expand All @@ -58,6 +62,7 @@ describe('KuiPopover', () => {
const component = render(
<KuiPopover
button={<button />}
closePopover={() => {}}
anchorPosition="right"
/>
);
Expand All @@ -72,17 +77,19 @@ describe('KuiPopover', () => {
const component = render(
<KuiPopover
button={<button />}
closePopover={() => {}}
/>
);

expect(component)
.toMatchSnapshot();
});

test('true is rendered', () => {
test('renders true', () => {
const component = render(
<KuiPopover
button={<button />}
closePopover={() => {}}
isOpen={true}
/>
);
Expand Down
1 change: 1 addition & 0 deletions ui_framework/src/global_styling/mixins/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import 'naming';
@import 'responsive';
@import 'link';
@import 'shadow';
@import 'size';
@import 'helpers';
3 changes: 3 additions & 0 deletions ui_framework/src/global_styling/mixins/_shadow.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@mixin kuiBottomShadow {
box-shadow: 0 16px 16px -8px rgba(0, 0, 0, 0.1);
}
2 changes: 1 addition & 1 deletion ui_framework/src/global_styling/utilities/_shadow.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.kui--bottomShadow {
box-shadow: 0 16px 16px -8px rgba(0, 0, 0, 0.1);
@include kuiBottomShadow;
}

0 comments on commit 481922e

Please sign in to comment.