Skip to content

Commit

Permalink
Merge pull request #24 from platformbuilders/fix/FlatButton
Browse files Browse the repository at this point in the history
Fix/flat button
  • Loading branch information
mdlucas authored Aug 9, 2021
2 parents de10459 + 12a691a commit af22460
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@platformbuilders/react-native-elements",
"version": "0.4.0",
"version": "0.4.1",
"description": "Platform Builders Shared Components Library For React Native",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
47 changes: 23 additions & 24 deletions src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ exports[`<Button /> should render button 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -55,6 +54,7 @@ exports[`<Button /> should render button 1`] = `
accessibilityLabel="undefined"
buttonVariant="primary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -108,9 +108,8 @@ exports[`<Button /> should render button when rounded 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 35.35714285714286,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -132,6 +131,7 @@ exports[`<Button /> should render button when rounded 1`] = `
accessibilityLabel="undefined"
buttonVariant="primary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -185,9 +185,8 @@ exports[`<Button /> should render button with children 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -209,6 +208,7 @@ exports[`<Button /> should render button with children 1`] = `
accessibilityLabel="[object Object]"
buttonVariant="primary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -280,9 +280,8 @@ exports[`<Button /> should render button with contrast 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -304,6 +303,7 @@ exports[`<Button /> should render button with contrast 1`] = `
accessibilityLabel="undefined"
buttonVariant="primary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -357,9 +357,8 @@ exports[`<Button /> should render button with custom accessibility label 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -381,6 +380,7 @@ exports[`<Button /> should render button with custom accessibility label 1`] = `
accessibilityLabel="undefined"
buttonVariant="primary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -434,9 +434,8 @@ exports[`<Button /> should render button with custom style 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -460,6 +459,7 @@ exports[`<Button /> should render button with custom style 1`] = `
accessibilityLabel="undefined"
buttonVariant="primary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -513,9 +513,8 @@ exports[`<Button /> should render button with custom text style 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -537,6 +536,7 @@ exports[`<Button /> should render button with custom text style 1`] = `
accessibilityLabel="undefined"
buttonVariant="primary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -592,9 +592,8 @@ exports[`<Button /> should render button with disabled 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E70",
"borderColor": "black",
"borderColor": "#C6B09E70",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -616,6 +615,7 @@ exports[`<Button /> should render button with disabled 1`] = `
accessibilityLabel="undefined"
buttonVariant="primary"
disabled={true}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -669,9 +669,8 @@ exports[`<Button /> should render button with loading 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand Down Expand Up @@ -765,9 +764,8 @@ exports[`<Button /> should render button with test id 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -789,6 +787,7 @@ exports[`<Button /> should render button with test id 1`] = `
accessibilityLabel="undefined"
buttonVariant="primary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -842,9 +841,8 @@ exports[`<Button /> should render button with typography variant 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#C6B09E",
"borderColor": "black",
"borderColor": "#C6B09E",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -866,6 +864,7 @@ exports[`<Button /> should render button with typography variant 1`] = `
accessibilityLabel="undefined"
buttonVariant="primary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down Expand Up @@ -919,9 +918,8 @@ exports[`<Button /> should render button with variant 1`] = `
Object {
"alignItems": "center",
"backgroundColor": "#805281",
"borderColor": "black",
"borderColor": "#805281",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"flexDirection": "row",
"height": 70.71428571428572,
Expand All @@ -943,6 +941,7 @@ exports[`<Button /> should render button with variant 1`] = `
accessibilityLabel="undefined"
buttonVariant="secondary"
disabled={false}
flat={false}
style={
Array [
Object {
Expand Down
1 change: 1 addition & 0 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const Button: FC<ButtonProps> = ({
<TextButton
style={textStyle}
disabled={disabled}
flat={flat}
variant={typographyVariant}
buttonVariant={variant}
>
Expand Down
8 changes: 5 additions & 3 deletions src/components/Button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import LoadingIndicator from '../LoadingIndicator';
import TouchableComponent from '../Touchable';
import TypographyComponent from '../Typography';

const borderWidthSmall = getTheme('borderWidth.xxs');
const brandPrimary = getTheme('brand.primary.main');
const brandPrimaryContrast = getTheme('brand.primary.contrast');
const brandSecondary = getTheme('brand.secondary.main');
Expand Down Expand Up @@ -70,6 +71,7 @@ type TextButtonProps = {
buttonVariant: ButtonVariants;
variant?: TypographyVariants;
disabled?: boolean;
flat?: boolean;
style: any;
};

Expand Down Expand Up @@ -120,13 +122,13 @@ export const ButtonWrapper = styled.View<ButtonWrapperProps>`
props.rounded ? buttonSize / 2 : buttonRadius(props)}px;
justify-content: center;
background-color: ${isFlat('transparent', getBackgroundColor)};
border-color: ${getTextColor};
border: ${(props) => hasBorder(`1px solid ${getTextColor(props)}`, '0')};
border-color: ${getBackgroundColor};
border-width: ${hasBorder(borderWidthSmall, '0')};
`;

export const TextButton = styled(TypographyComponent)<TextButtonProps>`
letter-spacing: 0.4px;
color: ${getTextColor};
color: ${isFlat(getBackgroundColor, getTextColor)};
font-weight: 500;
`;

Expand Down

0 comments on commit af22460

Please sign in to comment.