-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move all core components to widgets
This introduces the new separation of what is a core component (style + structure) and what is a widget (behavior). The idea is to keep core components very stable and generic over time, and instead using the concept of "widges" to mean things that are fully formed and usable directly in an application. This stability means that it becomes easier and safer to build new components by composing core components. It also provides a clear distinction between what is a core component and what is a widget. BREAKING CHANGE: All @dhis2/ui-core exports have been migrated to @dhis2/ui-widgets.
- Loading branch information
Showing
235 changed files
with
253 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,4 @@ cypress.env.json | |
# d2 | ||
.d2/ | ||
locales/ | ||
packages/forms/i18n/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react' | ||
import cx from 'classnames' | ||
|
||
import propTypes from '@dhis2/prop-types' | ||
|
||
import styles from './ButtonBase.styles.js' | ||
|
||
/** | ||
* @module | ||
* @param {ButtonBase.PropTypes} props | ||
* @returns {React.Component} | ||
*/ | ||
export const ButtonBase = ({ | ||
children, | ||
className, | ||
primary, | ||
secondary, | ||
destructive, | ||
small, | ||
large, | ||
disabled, | ||
...props | ||
}) => ( | ||
<button | ||
{...props} | ||
className={cx(className, { | ||
primary, | ||
secondary, | ||
destructive, | ||
small, | ||
large, | ||
})} | ||
disabled={disabled} | ||
> | ||
{children} | ||
<style jsx>{styles}</style> | ||
</button> | ||
) | ||
|
||
/** | ||
* @typedef {Object} PropTypes | ||
* @static | ||
* @prop {Node} [children] | ||
* @prop {string} [className] | ||
* @prop {boolean} [small] | ||
* @prop {boolean} [large] | ||
* @prop {boolean } [primary] | ||
* @prop {boolean } [secondary] | ||
* @prop {boolean } [destructive] | ||
* @prop {boolean} [disabled] | ||
*/ | ||
ButtonBase.propTypes = { | ||
children: propTypes.node, | ||
className: propTypes.string, | ||
destructive: propTypes.bool, | ||
disabled: propTypes.bool, | ||
large: propTypes.bool, | ||
primary: propTypes.bool, | ||
secondary: propTypes.bool, | ||
small: propTypes.bool, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
|
||
import { ButtonBase } from './ButtonBase.js' | ||
|
||
export default { | ||
title: 'Component/Core/ButtonBase', | ||
component: ButtonBase, | ||
} | ||
|
||
export const Default = () => <ButtonBase>Default button</ButtonBase> | ||
export const Primary = () => <ButtonBase primary>Default button</ButtonBase> | ||
export const Secondary = () => <ButtonBase secondary>Default button</ButtonBase> | ||
export const Destructive = () => ( | ||
<ButtonBase destructive>Default button</ButtonBase> | ||
) | ||
export const Small = () => <ButtonBase small>Default button</ButtonBase> | ||
export const Large = () => <ButtonBase large>Default button</ButtonBase> | ||
export const Disabled = () => <ButtonBase disabled>Default button</ButtonBase> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/forms/src/CheckboxGroupControl/CheckboxGroupControl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import css from 'styled-jsx/css' | ||
|
||
import { spacers } from '@dhis2/ui-constants' | ||
|
||
export default css` | ||
.icon { | ||
padding-left: ${spacers.dp12}; | ||
} | ||
.icon-only.icon { | ||
padding-left: 6px; | ||
} | ||
.icon-only { | ||
padding: 0; | ||
} | ||
.icon-only i { | ||
margin-right: 0; | ||
margin-left: 0; | ||
} | ||
.button-icon { | ||
margin-right: 6px; | ||
color: inherit; | ||
fill: inherit; | ||
font-size: 26px; | ||
vertical-align: middle; | ||
pointer-events: none; | ||
} | ||
` |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.