Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Buttons)!: Introduce ButtonPrimitive, implementing planned break…
…ing changes (#1522) Refactored Button and ButtonLink to ButtonPrimitive to share common DOM structure, functionality and properties. BREAKING CHANGE: removing unsafe className (deprecated, not public API) removing icon property (deprecated) changing type of width to string (planned)
- Loading branch information
1 parent
6432a83
commit ca4a641
Showing
94 changed files
with
1,522 additions
and
1,329 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
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 was deleted.
Oops, something went wrong.
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,13 +1,15 @@ | ||
// @flow | ||
import type { Interpolation } from "styled-components"; | ||
|
||
import type { Props, Type } from "../index"; | ||
import type { ThemeProps } from "../../defaultTheme"; | ||
import type { Type } from "../index"; | ||
import type { Theme } from "../../defaultTheme"; | ||
|
||
type State = "default" | "focus" | "active" | "hover"; | ||
|
||
export type GetButtonBoxShadow = ( | ||
state: State, | ||
) => ({ ...Props, type: Type, ...ThemeProps }) => ?(Interpolation[]); | ||
disabled: boolean, | ||
bordered: boolean, | ||
theme: Theme, | ||
type: Type, | ||
) => ?string; | ||
|
||
declare export default GetButtonBoxShadow; |
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,22 @@ | ||
// @flow | ||
import { TOKENS } from "../consts"; | ||
import getButtonTypeToken from "./getButtonTypeToken"; | ||
import type { GetButtonIconForeground } from "./getButtonIconForeground"; | ||
|
||
const getButtonIconForeground: GetButtonIconForeground = ({ bordered, theme, type }) => { | ||
const wrappedTypeToken = name => getButtonTypeToken(name, type, theme); | ||
if (bordered) { | ||
return { | ||
foreground: wrappedTypeToken(TOKENS.colorTextButtonBordered), | ||
foregroundHover: wrappedTypeToken(TOKENS.colorTextButtonBorderedHover), | ||
foregroundActive: wrappedTypeToken(TOKENS.colorTextButtonBorderedActive), | ||
}; | ||
} | ||
return { | ||
foreground: wrappedTypeToken(TOKENS.colorTextButton), | ||
foregroundHover: wrappedTypeToken(TOKENS.colorTextButtonHover), | ||
foregroundActive: wrappedTypeToken(TOKENS.colorTextButtonActive), | ||
}; | ||
}; | ||
|
||
export default getButtonIconForeground; |
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,12 @@ | ||
// @flow | ||
import type { ThemeProps } from "../../defaultTheme"; | ||
import type { Type } from "../index"; | ||
import type { IconForeground } from "../../primitives/ButtonPrimitive"; | ||
|
||
export type GetButtonIconForeground = ({ | ||
bordered: boolean, | ||
type: Type, | ||
...ThemeProps, | ||
}) => IconForeground; | ||
|
||
declare export default GetButtonIconForeground; |
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
// @flow | ||
import { BUTTON_STATES } from "../../primitives/ButtonPrimitive/common/consts"; | ||
import getButtonTypeToken from "./getButtonTypeToken"; | ||
import { TOKENS } from "../consts"; | ||
import getButtonBoxShadow from "./getButtonBoxShadow"; | ||
import type { GetButtonStyles } from "./getButtonStyles"; | ||
|
||
const getButtonStyles: GetButtonStyles = ({ disabled, bordered, theme, type }) => { | ||
const wrappedBoxShadow = state => getButtonBoxShadow(state, disabled, bordered, theme, type); | ||
const wrappedTypeToken = name => getButtonTypeToken(name, type, theme); | ||
const boxShadow = { | ||
boxShadow: wrappedBoxShadow(BUTTON_STATES.DEFAULT), | ||
boxShadowHover: wrappedBoxShadow(BUTTON_STATES.HOVER), | ||
boxShadowActive: wrappedBoxShadow(BUTTON_STATES.ACTIVE), | ||
boxShadowFocus: wrappedBoxShadow(BUTTON_STATES.FOCUS), | ||
}; | ||
if (bordered) { | ||
return { | ||
background: wrappedTypeToken(TOKENS.backgroundButtonBordered), | ||
backgroundHover: wrappedTypeToken(TOKENS.backgroundButtonBorderedHover), | ||
backgroundActive: wrappedTypeToken(TOKENS.backgroundButtonBorderedActive), | ||
backgroundFocus: wrappedTypeToken(TOKENS.backgroundButtonFocus), | ||
foreground: wrappedTypeToken(TOKENS.colorTextButtonBordered), | ||
foregroundHover: wrappedTypeToken(TOKENS.colorTextButtonBorderedHover), | ||
foregroundActive: wrappedTypeToken(TOKENS.colorTextButtonBorderedActive), | ||
...boxShadow, | ||
}; | ||
} | ||
return { | ||
background: wrappedTypeToken(TOKENS.backgroundButton), | ||
backgroundHover: wrappedTypeToken(TOKENS.backgroundButtonHover), | ||
backgroundActive: wrappedTypeToken(TOKENS.backgroundButtonActive), | ||
backgroundFocus: null, | ||
foreground: wrappedTypeToken(TOKENS.colorTextButton), | ||
foregroundHover: wrappedTypeToken(TOKENS.colorTextButtonHover), | ||
foregroundActive: wrappedTypeToken(TOKENS.colorTextButtonActive), | ||
...boxShadow, | ||
}; | ||
}; | ||
|
||
export default getButtonStyles; |
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 @@ | ||
// @flow | ||
|
||
import type { ThemeProps } from "../../defaultTheme"; | ||
import type { Type } from "../index"; | ||
import type { Background, BoxShadow, Foreground } from "../../primitives/ButtonPrimitive"; | ||
|
||
export type GetButtonStyles = ({ | ||
disabled: boolean, | ||
bordered: boolean, | ||
type: Type, | ||
...ThemeProps, | ||
}) => {| | ||
...Background, | ||
...Foreground, | ||
...BoxShadow, | ||
|}; | ||
|
||
declare export default GetButtonStyles; |
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.