-
Notifications
You must be signed in to change notification settings - Fork 16
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
refactor: move all core components to widgets #5
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d6f8a7b
refactor: move all core components to widgets
varl 2207bf2
test(widgets): update headerbar e2e test
varl 699b194
refactor(core): add forward refs to base components
varl d2ed23d
refactor(core): reexport buttonbase from index
varl b41c6d8
test(widgets): expand the prop to dom prop
varl 9711ab3
refactor(core): move default export to the bottom
varl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,69 @@ | ||
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} | ||
*/ | ||
function ButtonBase( | ||
{ | ||
children, | ||
className, | ||
primary, | ||
secondary, | ||
destructive, | ||
small, | ||
large, | ||
disabled, | ||
...props | ||
}, | ||
ref | ||
) { | ||
return ( | ||
<button | ||
{...props} | ||
className={cx(className, { | ||
primary, | ||
secondary, | ||
destructive, | ||
small, | ||
large, | ||
})} | ||
disabled={disabled} | ||
ref={ref} | ||
> | ||
{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, | ||
} | ||
|
||
export default React.forwardRef(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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reasoning behind this split? I'd expect that the icon-related styles are also just part of the
ButtonBase
. I'm sure you've got a good reason for it, but I don't immediately see it....