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

[UI Framework] [K7] Require modifiers for components with multiple types #13380

Merged
merged 3 commits into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
43 changes: 27 additions & 16 deletions ui_framework/dist/ui_framework.css
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,8 @@ table {
cursor: pointer;
height: 40px;
text-decoration: none;
border: solid 1px #0079a5;
border: solid 1px transparent;
border-radius: 4px;
color: #0079a5;
padding: 0 12px;
min-width: 112px;
text-align: center;
Expand All @@ -360,8 +359,6 @@ table {
*/ }
.kuiButton.kuiButton--small {
height: 32px; }
.kuiButton .kuiButton__icon {
fill: #0079a5; }
.kuiButton .kuiButton__content {
display: -webkit-box;
display: -webkit-flex;
Expand All @@ -384,15 +381,6 @@ table {
.kuiButton:focus {
-webkit-animation: kuiButtonFocus 250ms cubic-bezier(0.34, 1.61, 0.7, 1);
animation: kuiButtonFocus 250ms cubic-bezier(0.34, 1.61, 0.7, 1); }
.kuiButton.kuiButton--fill {
background-color: #0079a5;
color: #FFF;
border-color: #0079a5; }
.kuiButton.kuiButton--fill:hover, .kuiButton.kuiButton--fill:focus {
background-color: #00668c;
border-color: #00668c; }
.kuiButton.kuiButton--fill .kuiButton__icon {
fill: #FFF; }
.kuiButton.kuiButton--reverse .kuiButton__content {
-webkit-box-orient: horizontal;
-webkit-box-direction: reverse;
Expand All @@ -403,6 +391,23 @@ table {
margin-left: 0;
margin-right: 8px; }

.kuiButton--primary {
color: #0079a5;
border-color: #0079a5; }
.kuiButton--primary .kuiButton__icon {
fill: #0079a5; }
.kuiButton--primary:hover, .kuiButton--primary:focus {
background-color: rgba(0, 121, 165, 0.1); }
.kuiButton--primary.kuiButton--fill {
background-color: #0079a5;
color: #FFF;
border-color: #0079a5; }
.kuiButton--primary.kuiButton--fill:hover, .kuiButton--primary.kuiButton--fill:focus {
background-color: #00668c;
border-color: #00668c; }
.kuiButton--primary.kuiButton--fill .kuiButton__icon {
fill: #FFF; }

.kuiButton--secondary {
color: #00A69B;
border-color: #00A69B; }
Expand Down Expand Up @@ -484,9 +489,15 @@ table {

.kuiCallOut {
padding: 12px 24px;
border-left: 4px solid #0079a5;
background-color: #e6f2f6;
/* 1 */ }
border-left: 4px solid transparent; }

.kuiCallOut--info {
border-color: #0079a5;
background-color: #e6f2f6; }
.kuiCallOut--info .kuiCallOutHeader__icon {
fill: #005574; }
.kuiCallOut--info .kuiCallOutHeader__title {
color: #005574; }

.kuiCallOut--success {
border-color: #00A69B;
Expand Down
2 changes: 1 addition & 1 deletion ui_framework/doc_site/src/views/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default () => (
<KuiButton
onClick={() => window.alert('Button clicked')}
>
Default
Primary
</KuiButton>

&nbsp;&nbsp;
Expand Down
14 changes: 7 additions & 7 deletions ui_framework/doc_site/src/views/call_out/call_out_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
GuideText,
} from '../../components';

import CallOut from './call_out';
const callOutSource = require('!!raw!./call_out');
const callOutHtml = renderToHtml(CallOut);
import Info from './info';
const infoSource = require('!!raw!./info');
const infoHtml = renderToHtml(Info);

import Success from './success';
const successSource = require('!!raw!./success');
Expand All @@ -29,21 +29,21 @@ const dangerHtml = renderToHtml(Danger);
export default props => (
<GuidePage title={props.route.name}>
<GuideSection
title="CallOut"
title="Info"
source={[{
type: GuideSectionTypes.JS,
code: callOutSource,
code: infoSource,
}, {
type: GuideSectionTypes.HTML,
code: callOutHtml,
code: infoHtml,
}]}
>
<GuideText>
Use this CallOut to communicate general information to the user.
</GuideText>

<GuideDemo>
<CallOut />
<Info />
</GuideDemo>
</GuideSection>

Expand Down
23 changes: 2 additions & 21 deletions ui_framework/src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
cursor: pointer;
height: $kuiSizeXXL;
text-decoration: none;
border: solid 1px $kuiColorPrimary;
border: solid 1px transparent;
border-radius: $kuiBorderRadius;
color: $kuiColorPrimary;
padding: 0 ($kuiSize - $kuiSizeXS);
min-width: $kuiSize * 7;
text-align: center;
Expand All @@ -20,10 +19,6 @@
height: $kuiSizeXL;
}

.kuiButton__icon {
fill: $kuiColorPrimary;
}

/**
* 1. Apply margin to all but last item in the flex.
*/
Expand All @@ -46,21 +41,6 @@
animation: kuiButtonFocus $kuiAnimSpeedNormal $kuiAnimSlightBounce;
}

&.kuiButton--fill {
background-color: $kuiColorPrimary;
color: #FFF;
border-color: $kuiColorPrimary;

&:hover, &:focus {
background-color: darken($kuiColorPrimary, 5%);
border-color: darken($kuiColorPrimary, 5%);
}

.kuiButton__icon {
fill: #FFF;
}
}

&.kuiButton--reverse {
.kuiButton__content {
flex-direction: row-reverse;
Expand All @@ -75,6 +55,7 @@

// Modifier naming and colors.
$buttonTypes: (
primary: $kuiColorPrimary,
secondary: $kuiColorSecondary,
warning: $kuiColorWarning,
danger: $kuiColorDanger,
Expand Down
101 changes: 48 additions & 53 deletions ui_framework/src/components/button/button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {
Component,
PropTypes,
} from 'react';

Expand All @@ -11,9 +10,10 @@ import {
} from '../icon';

const typeToClassNameMap = {
danger: 'kuiButton--danger',
warning: 'kuiButton--warning',
primary: 'kuiButton--primary',
secondary: 'kuiButton--secondary',
warning: 'kuiButton--warning',
danger: 'kuiButton--danger',
disabled: 'kuiButton--disabled',
};

Expand All @@ -26,61 +26,55 @@ const sizeToClassNameMap = {

export const SIZES = Object.keys(sizeToClassNameMap);

export class KuiButton extends Component {
constructor(props) {
super(props);
}

render() {
const {
children,
className,
iconType,
iconReverse,
type,
size,
fill,
...rest,
} = this.props;

const classes = classNames(
'kuiButton',
typeToClassNameMap[type],
sizeToClassNameMap[size],
className,
{
'kuiButton--fill': fill,
'kuiButton--reverse': iconReverse,
},
);
export const KuiButton = props => {
const {
children,
className,
iconType,
iconReverse,
type,
size,
fill,
...rest,
} = props;

// Add an icon to the button if one exists.
let buttonIcon;
const classes = classNames(
'kuiButton',
typeToClassNameMap[type],
sizeToClassNameMap[size],
className,
{
'kuiButton--fill': fill,
'kuiButton--reverse': iconReverse,
},
);

if (iconType) {
buttonIcon = (
<KuiIcon
className="kuiButton__icon"
type={iconType}
size="medium"
aria-hidden="true"
/>
);
}
// Add an icon to the button if one exists.
let buttonIcon;

return (
<button
className={classes}
{...rest}
>
<span className="kuiButton__content">
{buttonIcon}
<span>{children}</span>
</span>
</button>
if (iconType) {
buttonIcon = (
<KuiIcon
className="kuiButton__icon"
type={iconType}
size="medium"
aria-hidden="true"
/>
);
}
}

return (
<button
className={classes}
{...rest}
>
<span className="kuiButton__content">
{buttonIcon}
<span>{children}</span>
</span>
</button>
);
};

KuiButton.propTypes = {
iconType: PropTypes.oneOf(ICON_TYPES),
Expand All @@ -92,5 +86,6 @@ KuiButton.propTypes = {

KuiButton.defaultProps = {
iconReverse: false,
type: 'primary',
fill: false,
};
5 changes: 2 additions & 3 deletions ui_framework/src/components/call_out/_call_out.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.kuiCallOut {
padding: $kuiSizeM $kuiSizeL;
border-left: 4px solid $kuiColorPrimary;
background-color: tintOrShade($kuiColorPrimary, 90%, 70%); /* 1 */
border-left: 4px solid transparent;
}

// Modifier naming and colors.
$callOutTypes: (
info: $kuiColorPrimary,
success: $kuiColorSecondary,
warning: $kuiColorWarning,
danger: $kuiColorDanger,
Expand Down Expand Up @@ -54,6 +54,5 @@ $callOutTypes: (
}

.kuiCallOutHeader__title {
// font-weight: $kuiFontWeightMedium;
color: $kuiColorPrimary;
}
5 changes: 5 additions & 0 deletions ui_framework/src/components/call_out/call_out.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '../icon';

const typeToClassNameMap = {
info: 'kuiCallOut--info',
success: 'kuiCallOut--success',
warning: 'kuiCallOut--warning',
danger: 'kuiCallOut--danger',
Expand Down Expand Up @@ -56,3 +57,7 @@ KuiCallOut.propTypes = {
iconType: PropTypes.oneOf(ICON_TYPES),
type: PropTypes.oneOf(TYPES),
};

KuiCallOut.defaultProps = {
type: 'info',
};