-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into adnasa-calendar-utils-typescript
- Loading branch information
Showing
60 changed files
with
1,113 additions
and
704 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'@commercetools-uikit/accessible-button': patch | ||
'@commercetools-uikit/flat-button': patch | ||
'@commercetools-uikit/icon-button': patch | ||
'@commercetools-uikit/primary-button': patch | ||
'@commercetools-uikit/secondary-button': patch | ||
'@commercetools-uikit/secondary-icon-button': patch | ||
--- | ||
|
||
Migrate to `TypeScript` and migrate docs to README generator. |
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,5 @@ | ||
--- | ||
'@commercetools-uikit/field-errors': patch | ||
--- | ||
|
||
Migrate `<FieldErrors />` to TypeScript |
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,5 @@ | ||
--- | ||
'@commercetools-uikit/accessible-button': patch | ||
--- | ||
|
||
Update `buttonAttributes` to support `unknown` type. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,78 @@ | ||
# Buttons: Flat Button | ||
<!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. --> | ||
<!-- This file is created by the `yarn generate-readme` script. --> | ||
|
||
# FlatButton | ||
|
||
## Description | ||
|
||
Flat buttons are minimal and a flat variation of primary and secondary buttons. | ||
|
||
## Installation | ||
|
||
``` | ||
yarn add @commercetools-uikit/flat-button | ||
``` | ||
|
||
``` | ||
npm --save install @commercetools-uikit/flat-button | ||
``` | ||
|
||
Additionally install the peer dependencies (if not present) | ||
|
||
``` | ||
yarn add react | ||
``` | ||
|
||
``` | ||
npm --save install react | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
```jsx | ||
import React from 'react'; | ||
import FlatButton from '@commercetools-uikit/flat-button'; | ||
import { InformationIcon } from '@commercetools-uikit/icons'; | ||
|
||
<FlatButton | ||
tone="primary" | ||
icon={<InformationIcon />} | ||
label="A label text" | ||
onClick={() => alert('Button clicked')} | ||
isDisabled={false} | ||
/>; | ||
``` | ||
const Example = () => ( | ||
<FlatButton | ||
tone="primary" | ||
icon={<InformationIcon />} | ||
label="A label text" | ||
onClick={() => alert('Button clicked')} | ||
isDisabled={false} | ||
/> | ||
); | ||
|
||
iconClass label url onClick | ||
export default Example; | ||
``` | ||
|
||
## Properties | ||
|
||
| Props | Type | Required | Values | Default | Description | | ||
| -------------- | --------------------- | :------: | --------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `tone` | `oneOf` | - | `primary`, `secondary`, `iverted` | `primary` | - | | ||
| `type` | `string` | - | `submit`, `reset`, `button` | `button` | Used as the HTML `type` attribute. | | ||
| `label` | `string` | ✅ | - | - | Should describe what the button is for | | ||
| `onClick` | `func` | ✅ | - | - | What the button will trigger when clicked | | ||
| `icon` | `element` | - | - | - | The icon of the button | | ||
| `iconPosition` | `oneOf` | - | `left`, `right` | `left` | The position of the icon | | ||
| `isDisabled` | `boolean` | - | - | - | Tells when the button should present a disabled state | | ||
| `as` | `string` or `element` | - | - | - | You may pass in a string like "a" to have the button render as an anchor tag instead. Or you could pass in a React Component, like a `Link`. | | ||
| Props | Type | Required | Default | Description | | ||
| -------------- | ----------------------------------------------------------------------- | :------: | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `as` | `union`<br/>Possible values:<br/>`string , ElementType` | | | You may pass in a string like "a" to have the button render as an anchor tag instead.
<br/>
Or you could pass in a React Component, like a `Link`. | | ||
| `tone` | `union`<br/>Possible values:<br/>`'primary' , 'secondary' , 'inverted'` | | `'primary'` | Indicates the color scheme of button | | ||
| `type` | `union`<br/>Possible values:<br/>`'submit' , 'reset' , 'button'` | | `'button'` | Used as the HTML `type` attribute. | | ||
| `label` | `string` | ✅ | | Should describe what the button is for | | ||
| `onClick` | `Function`<br/>[See signature.](#signature-onClick) | | | Handler when the button is clicked
<br />
Signature: (event: MouseEvent\<HTMLButtonElement) => void | | ||
| `icon` | `ReactReactElement` | | | The icon of the button | | ||
| `iconPosition` | `union`<br/>Possible values:<br/>`'left' , 'right'` | | `'left'` | The position of the icon | | ||
| `isDisabled` | `boolean` | | `false` | Determines if the button is disabled.
<br />
Note that this influences the `tone` and `onClick` will not be triggered in this state. | | ||
|
||
## Signatures | ||
|
||
The component further forwards all valid HTML attributes to the underlying `button` component. | ||
### Signature `onClick` | ||
|
||
```ts | ||
( | ||
event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement> | ||
) => void | ||
``` | ||
|
||
## Where to use | ||
|
||
Main Functions and use cases are: | ||
|
||
- Secondary or primary action _example: clear filters_ | ||
|
||
- Expand/Collapse list of fields _example: product attributes_ |
6 changes: 6 additions & 0 deletions
6
packages/components/buttons/flat-button/docs/additional-info.md
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,6 @@ | ||
## Where to use | ||
|
||
Main Functions and use cases are: | ||
|
||
- Secondary or primary action _example: clear filters_ | ||
- Expand/Collapse list of fields _example: product attributes_ |
15 changes: 15 additions & 0 deletions
15
packages/components/buttons/flat-button/docs/usage-example.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import FlatButton from '@commercetools-uikit/flat-button'; | ||
import { InformationIcon } from '@commercetools-uikit/icons'; | ||
|
||
const Example = () => ( | ||
<FlatButton | ||
tone="primary" | ||
icon={<InformationIcon />} | ||
label="A label text" | ||
onClick={() => alert('Button clicked')} | ||
isDisabled={false} | ||
/> | ||
); | ||
|
||
export default Example; |
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
30 changes: 30 additions & 0 deletions
30
packages/components/buttons/flat-button/src/flat-button.styles.ts
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,30 @@ | ||
import type { TFlatButtonProps, TExtendedTheme } from './flat-button'; | ||
|
||
export const getButtonIconColor = ( | ||
props: Pick<TFlatButtonProps, 'isDisabled' | 'tone'> | ||
) => { | ||
if (props.isDisabled) return 'neutral60'; | ||
else if (props.tone === 'primary') return 'primary'; | ||
else if (props.tone === 'secondary') return 'solid'; | ||
else if (props.tone === 'inverted') return 'surface'; | ||
return 'solid'; | ||
}; | ||
|
||
export const getTextColor = ( | ||
tone: TFlatButtonProps['tone'], | ||
isHover: boolean = false, | ||
overwrittenVars: TExtendedTheme | ||
): string => { | ||
switch (tone) { | ||
case 'primary': | ||
return isHover | ||
? overwrittenVars.colorPrimary25 | ||
: overwrittenVars.colorPrimary; | ||
case 'secondary': | ||
return overwrittenVars.colorSolid; | ||
case 'inverted': | ||
return overwrittenVars.fontColorForTextWhenInverted; | ||
default: | ||
return 'inherit'; | ||
} | ||
}; |
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.