Skip to content

Commit

Permalink
unify intent API, deprecate info
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenransijn committed Jul 11, 2018
1 parent 13f1b44 commit 938f2e1
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 105 deletions.
25 changes: 12 additions & 13 deletions src/alert/src/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Alert extends PureComponent {
/**
* The intent of the alert.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger', 'info'])
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger'])
.isRequired,

/**
Expand Down Expand Up @@ -115,18 +115,17 @@ class Alert extends PureComponent {
{...themeProps}
{...props}
>
{hasIcon &&
intent !== 'none' && (
<Pane
marginRight={10}
marginLeft={2}
height={14}
display="block"
marginTop={2}
>
{this.getIconForIntent(intent)}
</Pane>
)}
{hasIcon && (
<Pane
marginRight={10}
marginLeft={2}
height={14}
display="block"
marginTop={2}
>
{this.getIconForIntent(intent)}
</Pane>
)}
<Pane display="flex" width="100%">
<Pane flex={1}>
<Heading
Expand Down
13 changes: 6 additions & 7 deletions src/alert/src/InlineAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class InlineAlert extends PureComponent {
/**
* The intent of the alert. This should always be set explicitly.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger', 'info'])
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger'])
.isRequired,

/**
Expand Down Expand Up @@ -61,12 +61,11 @@ class InlineAlert extends PureComponent {

return (
<Pane alignItems="center" display="flex" {...props}>
{hasIcon &&
intent !== 'none' && (
<Pane display="inline" marginRight={8}>
{this.getIconForIntent(intent)}
</Pane>
)}
{hasIcon && (
<Pane display="inline" marginRight={8}>
{this.getIconForIntent(intent)}
</Pane>
)}
<Text size={size} fontWeight={500}>
{children}
</Text>
Expand Down
17 changes: 1 addition & 16 deletions src/alert/stories/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ storiesOf('alert', module)
intent="danger"
title="We weren’t able to save your changes."
/>
<Alert
appearance={appearance}
marginBottom={32}
intent="info"
title="There are over 180 integrations available."
/>
</Box>
))}
</Box>
Expand Down Expand Up @@ -86,15 +80,6 @@ storiesOf('alert', module)
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</Alert>
<Alert
appearance={appearance}
marginBottom={32}
intent="info"
title="There are over 180 integrations available."
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</Alert>
</Box>
))}
</Box>
Expand All @@ -120,7 +105,7 @@ storiesOf('alert', module)
<InlineAlert intent="danger" marginBottom={16}>
We weren’t able to save your changes.
</InlineAlert>
<InlineAlert intent="info" marginBottom={16}>
<InlineAlert intent="none" marginBottom={16}>
There are over 200 integrations available.
</InlineAlert>
</Box>
Expand Down
6 changes: 6 additions & 0 deletions src/buttons/src/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class Button extends PureComponent {
*/
...layout.propTypes,

/**
* The intent of the button.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger'])
.isRequired,

/**
* The appearance of the button.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/constants/src/Intent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ export default {
NONE: 'none',
SUCCESS: 'success',
WARNING: 'warning',
DANGER: 'danger',
INFO: 'info'
DANGER: 'danger'
}
2 changes: 1 addition & 1 deletion src/corner-dialog/src/CornerDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class CornerDialog extends PureComponent {
/**
* The intent of the CornerDialog. Used for the button.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger', 'info'])
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger'])
.isRequired,

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/src/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Dialog extends React.Component {
/**
* The intent of the Dialog. Used for the button.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger', 'info'])
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger'])
.isRequired,

/**
Expand Down
2 changes: 1 addition & 1 deletion src/menu/src/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MenuItem extends React.PureComponent {
/**
* The intent of the menu item.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger', 'info'])
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger'])
.isRequired,

/**
Expand Down
2 changes: 1 addition & 1 deletion src/table/docs/examples/TableRow.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
{['none', 'danger', 'warning', 'info', 'success'].map(intent => {
{['none', 'danger', 'warning', 'success'].map(intent => {
return (
<Table.Row
key={intent}
Expand Down
2 changes: 1 addition & 1 deletion src/table/src/TableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TableRow extends PureComponent {
/**
* The intent of the alert.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger', 'info'])
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger'])
.isRequired,

/**
Expand Down
2 changes: 1 addition & 1 deletion src/table/stories/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ storiesOf('table', module)
document.body.style.margin = '0'
document.body.style.height = '100vh'
})()}
{['none', 'danger', 'warning', 'info', 'success'].map(intent => {
{['none', 'danger', 'warning', 'success'].map(intent => {
return (
<Table.Row key={intent} isSelectable intent={intent}>
<Table.TextCell>{intent}</Table.TextCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const getButtonAppearance = (appearance, intent) => {
})
}
case 'minimal': {
const intentTextColor = getTextColorForIntent(intent)
const intentTextColor = getTextColorForIntent(intent, scales.blue.B9)
return Themer.createButtonAppearance({
disabled,
base: {
Expand Down
28 changes: 0 additions & 28 deletions src/theme/src/default-theme/component-specific/getRowClassName.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,6 @@ Appearances.warning = Themer.createRowAppearance({
current: {}
})

Appearances.info = Themer.createRowAppearance({
base: {
backgroundColor: palette.blue.lightest
},

hover: {
backgroundColor: tinycolor(palette.blue.lightest)
.darken(1)
.toString()
},

focus: {
backgroundColor: tinycolor(palette.blue.lightest)
.darken(1.5)
.toString()
},

active: {
backgroundColor: tinycolor(palette.blue.lightest)
.darken(2.5)
.toString()
},

current: {}
})

Appearances.success = Themer.createRowAppearance({
base: {
backgroundColor: palette.green.lightest
Expand Down Expand Up @@ -140,8 +114,6 @@ const getRowAppearance = (appearance, intent) => {
return Appearances.danger
case 'warning':
return Appearances.warning
case 'info':
return Appearances.info
case 'success':
return Appearances.success
case 'none':
Expand Down
4 changes: 2 additions & 2 deletions src/theme/src/default-theme/foundational-styles/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ export default {

/**
* Used for Alerts and other (future) componentes that express intent.
* @property {string} intent.info - Required property.
* @property {string} intent.none - Required property.
* @property {string} intent.success - Required property.
* @property {string} intent.danger - Required property.
* @property {string} intent.warning - Required property.
*/
intent: {
info: palette.blue.base,
none: palette.blue.base,
success: palette.green.base,
danger: palette.red.base,
warning: palette.orange.base
Expand Down
4 changes: 2 additions & 2 deletions src/theme/src/default-theme/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const linearGradient = (top, bottom) => {
* @param {Intent} intent
* @return {String} color
*/
const getTextColorForIntent = intent => {
const getTextColorForIntent = (intent, defaultColor) => {
switch (intent) {
case Intent.SUCCESS:
return colors.text.success
Expand All @@ -24,7 +24,7 @@ const getTextColorForIntent = intent => {
case Intent.WARNING:
return colors.text.warning
default:
return colors.text.default
return defaultColor || colors.text.default
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/theme/src/default-theme/theme-helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const getIconForIntent = intent => {
return { icon: 'error', color: 'danger' }
case Intent.WARNING:
return { icon: 'warning-sign', color: 'warning' }
case Intent.INFO:
case Intent.NONE:
default:
return { icon: 'info-sign', color: 'info' }
}
Expand Down
2 changes: 1 addition & 1 deletion src/toaster/src/Toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class Toast extends React.PureComponent {
/**
* The type of the alert.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger', 'info'])
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger'])
.isRequired,

/**
Expand Down
4 changes: 0 additions & 4 deletions src/toaster/src/Toaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,4 @@ export default class Toaster {
danger = (title, settings = {}) => {
return this.notifyHandler(title, { ...settings, intent: 'danger' })
}

info = (title, settings = {}) => {
return this.notifyHandler(title, { ...settings, intent: 'info' })
}
}
22 changes: 0 additions & 22 deletions src/toaster/stories/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ storiesOf('toaster', module).add('examples', () => (
<Li>success</Li>
<Li>warning</Li>
<Li>danger</Li>
<Li>info</Li>
<Li>
closeAll — useful for page transitions when you want to close all
toasts.
Expand Down Expand Up @@ -111,27 +110,6 @@ storiesOf('toaster', module).add('examples', () => (
Danger with Text
</Button>
</Box>
<Box marginBottom={12}>
<Button
marginRight={8}
onClick={() =>
toaster.info('There are over 180 integrations available.')
}
>
Info
</Button>

<Button
marginRight={8}
onClick={() =>
toaster.info('There are over 180 integrations available.', {
description: loremIpsum
})
}
>
Info with Text
</Button>
</Box>
</Box>
</Box>
))

0 comments on commit 938f2e1

Please sign in to comment.