diff --git a/components/button/src/button/button.js b/components/button/src/button/button.js index f3313500ea..bbfa6065a1 100644 --- a/components/button/src/button/button.js +++ b/components/button/src/button/button.js @@ -1,5 +1,6 @@ import { CircularLoader } from '@dhis2-ui/loader' import { sharedPropTypes } from '@dhis2/ui-constants' +import { NativeButton } from '../index.js' import cx from 'classnames' import PropTypes from 'prop-types' import React, { useEffect, useRef } from 'react' @@ -55,7 +56,7 @@ export const Button = ({ }) return ( - + ) } diff --git a/components/button/src/button/button.styles.js b/components/button/src/button/button.styles.js index e21b631a83..9a5c08e039 100644 --- a/components/button/src/button/button.styles.js +++ b/components/button/src/button/button.styles.js @@ -2,77 +2,6 @@ import { colors, theme, spacers } from '@dhis2/ui-constants' import css from 'styled-jsx/css' export default css` - button { - display: inline-flex; - position: relative; - align-items: center; - justify-content: center; - border-radius: 4px; - font-weight: 400; - letter-spacing: 0.5px; - text-decoration: none; - cursor: pointer; - user-select: none; - color: ${colors.grey900}; - - /*medium*/ - height: 36px; - padding: 0 ${spacers.dp12}; - font-size: 14px; - line-height: 16px; - - /*basic*/ - border: 1px solid ${colors.grey500}; - background-color: #f9fafb; - } - - button:disabled { - cursor: not-allowed; - } - - button:focus { - outline: 3px solid ${theme.focus}; - outline-offset: -3px; - text-decoration: underline; - } - - /* Prevent focus styles when mouse clicking */ - button:focus:not(:focus-visible) { - outline: none; - text-decoration: none; - } - - /* Prevent focus styles on active and disabled buttons */ - button:active:focus, - button:disabled:focus { - outline: none; - text-decoration: none; - } - - button:hover { - border-color: ${colors.grey500}; - background-color: ${colors.grey200}; - } - - button:active, - button:active:focus { - border-color: ${colors.grey500}; - background-color: ${colors.grey200}; - box-shadow: 0 0 0 1px rgb(0, 0, 0, 0.1) inset; - } - - button:focus { - background-color: #f9fafb; - } - - button:disabled { - border-color: ${colors.grey400}; - background-color: #f9fafb; - box-shadow: none; - color: ${theme.disabled}; - fill: ${theme.disabled}; - } - .small { height: 28px; padding: 0 6px; diff --git a/components/button/src/native-button/button.stories.js b/components/button/src/native-button/button.stories.js new file mode 100644 index 0000000000..904613a0aa --- /dev/null +++ b/components/button/src/native-button/button.stories.js @@ -0,0 +1,290 @@ +import { sharedPropTypes } from '@dhis2/ui-constants' +import React from 'react' +import { Button } from './button.js' + +// Note: make sure 'fenced code blocks' are not indentend in this template string +const description = `Buttons are used for triggering actions. +There are different types of buttons in the design system which are intended +for different types of actions. + +\`\`\`js +import { Button } from '@dhis2/ui' +\`\`\`` + +const { buttonVariantArgType, sizeArgType } = sharedPropTypes + +const logger = ({ name, value }) => console.log(`${name}: ${value}`) + +export default { + title: 'Button', + component: Button, + parameters: { + componentSubtitle: 'Initiates an action', + docs: { + description: { + component: description, + }, + }, + }, + args: { + children: 'Label me!', + value: 'default', + onClick: logger, + }, + argTypes: { + primary: { ...buttonVariantArgType }, + secondary: { ...buttonVariantArgType }, + destructive: { ...buttonVariantArgType }, + small: { ...sizeArgType }, + large: { ...sizeArgType }, + }, +} + +const DemoIcon24 = ( + + + +) + +const DemoIcon16 = ( + + + +) + +const Template = (args) => + ) +}) + +NativeButton.propTypes = { + /** Component to render inside the button */ + children: PropTypes.node, +}