Skip to content

Commit

Permalink
fix: cant change button text color by font
Browse files Browse the repository at this point in the history
Signed-off-by: Bibazavr <[email protected]>
  • Loading branch information
Bibazavr committed Feb 2, 2024
1 parent 3b31c6c commit 878512a
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4532,15 +4532,14 @@ exports[`ModalCalendar bottomView IButtonView.large 1`] = `
style={
[
{
"color": "#FFF",
"color": "#2B78EE",
"fontFamily": "Inter-SemiBold",
"fontSize": 27,
"lineHeight": 33,
"minHeight": 33,
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -4607,7 +4606,6 @@ exports[`ModalCalendar bottomView IButtonView.large 1`] = `
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -9141,7 +9139,6 @@ exports[`ModalCalendar bottomView IButtonView.small onAcceptDateRangeChange 1`]
},
[
{
"color": "#FFF",
"paddingHorizontal": 6,
},
undefined,
Expand Down Expand Up @@ -13675,7 +13672,6 @@ exports[`ModalCalendar bottomView IButtonView.small onDateRangeChange 1`] = `
},
[
{
"color": "#FFF",
"paddingHorizontal": 6,
},
undefined,
Expand Down Expand Up @@ -27154,15 +27150,14 @@ exports[`ModalCalendar renders correctly initialRange only fromDate isShowToday
style={
[
{
"color": "#FFF",
"color": "#2B78EE",
"fontFamily": "Inter-SemiBold",
"fontSize": 27,
"lineHeight": 33,
"minHeight": 33,
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -27229,7 +27224,6 @@ exports[`ModalCalendar renders correctly initialRange only fromDate isShowToday
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/cta/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Counter from '../../../other/components/Badge/Counter/Counter';

import {IButtonProps, IButtonSize, IButtonTypes} from './types';
import stylesCreate from './stylesCreate';
import {getDefaultFont} from './getDefaultFont';

const Button = forwardRef<ITouchableOpacity, IButtonProps>((props, ref) => {
const {
Expand All @@ -36,8 +37,7 @@ const Button = forwardRef<ITouchableOpacity, IButtonProps>((props, ref) => {
Boolean(text),
);

const defaultFont =
size === IButtonSize.small ? 'SemiBold-White-XS' : 'SemiBold-White-L';
const defaultFont = getDefaultFont(size, type);

const counterSize =
size === IButtonSize.small ? ICounterSize.small : ICounterSize.medium;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ exports[`@lad-tech/mobydick-core/Button renders correctly 1`] = `
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -124,7 +123,6 @@ exports[`@lad-tech/mobydick-core/Button renders correctly 2`] = `
},
[
{
"color": "#FFF",
"paddingHorizontal": 6,
},
undefined,
Expand Down Expand Up @@ -413,7 +411,6 @@ exports[`@lad-tech/mobydick-core/Button renders correctly left icon size large 1
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -484,7 +481,6 @@ exports[`@lad-tech/mobydick-core/Button renders correctly left icon size small 1
},
[
{
"color": "#FFF",
"paddingHorizontal": 6,
},
undefined,
Expand Down Expand Up @@ -1594,7 +1590,6 @@ exports[`@lad-tech/mobydick-core/Button renders correctly text 1`] = `
},
[
{
"color": "#FFF",
"paddingHorizontal": 6,
},
undefined,
Expand Down
35 changes: 35 additions & 0 deletions packages/core/src/cta/components/Button/getDefaultFont.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {TypographyProp} from '../../../typography';

import {IButtonSize, IButtonTypes} from './types';

export const getDefaultFont = (
size: IButtonSize,
type: IButtonTypes,
): TypographyProp => {
let defaultButtonFont = 'SemiBold';

switch (type) {
case IButtonTypes.primary:
case IButtonTypes.disabled:
case IButtonTypes.destructive:
case IButtonTypes.loading:
defaultButtonFont += '-White';
break;
case IButtonTypes.secondary:
case IButtonTypes.tertiary:
defaultButtonFont += '-Accent';
}

switch (size) {
case IButtonSize.small:
defaultButtonFont += '-XS';
break;
case IButtonSize.large:
case IButtonSize.fixed:
default:
defaultButtonFont += '-L';
break;
}

return defaultButtonFont as TypographyProp;
};
14 changes: 3 additions & 11 deletions packages/core/src/cta/components/Button/stylesCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const primaryStyle = ({
},

text: {
color: colors.TextWhite,
paddingHorizontal:
size === IButtonSize.small ? theme.spaces.Space4 : theme.spaces.Space6,
},
Expand All @@ -103,11 +102,10 @@ const secondaryStyle = ({
}: IButtonContents) => {
const defaultStyles = primaryStyle({theme, size, leftIcon, rightIcon, text});
const {
colors: {CtaBtnSecondary, TextAccent},
colors: {CtaBtnSecondary},
} = theme;

defaultStyles.container.backgroundColor = CtaBtnSecondary;
defaultStyles.text.color = TextAccent;

return defaultStyles;
};
Expand All @@ -120,12 +118,8 @@ const tertiaryStyle = ({
text,
}: IButtonContents) => {
const defaultStyles = primaryStyle({theme, size, leftIcon, rightIcon, text});
const {
colors: {TextAccent},
} = theme;

defaultStyles.container.backgroundColor = 'transparent';
defaultStyles.text.color = TextAccent;

return defaultStyles;
};
Expand All @@ -139,11 +133,10 @@ const disabledStyle = ({
}: IButtonContents) => {
const defaultStyles = primaryStyle({theme, size, leftIcon, rightIcon, text});
const {
colors: {CtaBtnMuted, TextWhite},
colors: {CtaBtnMuted},
} = theme;

defaultStyles.container.backgroundColor = CtaBtnMuted;
defaultStyles.text.color = TextWhite;

return defaultStyles;
};
Expand All @@ -157,11 +150,10 @@ const destructiveStyle = ({
}: IButtonContents) => {
const defaultStyles = primaryStyle({theme, size, leftIcon, rightIcon, text});
const {
colors: {CtaBtnDestructive, TextWhite},
colors: {CtaBtnDestructive},
} = theme;

defaultStyles.container.backgroundColor = CtaBtnDestructive;
defaultStyles.text.color = TextWhite;

return defaultStyles;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ exports[`@lad-tech/mobydick-core/modalBase should renders correctly HorizontalBu
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -132,7 +131,6 @@ exports[`@lad-tech/mobydick-core/modalBase should renders correctly HorizontalBu
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -211,7 +209,6 @@ exports[`@lad-tech/mobydick-core/modalBase should renders correctly HorizontalBu
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -278,7 +275,6 @@ exports[`@lad-tech/mobydick-core/modalBase should renders correctly HorizontalBu
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -349,15 +345,14 @@ exports[`@lad-tech/mobydick-core/modalBase should renders correctly HorizontalBu
style={
[
{
"color": "#FFF",
"color": "#2B78EE",
"fontFamily": "Inter-SemiBold",
"fontSize": 27,
"lineHeight": 33,
"minHeight": 33,
},
[
{
"color": "#2B78EE",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -416,15 +411,14 @@ exports[`@lad-tech/mobydick-core/modalBase should renders correctly HorizontalBu
style={
[
{
"color": "#FFF",
"color": "#2B78EE",
"fontFamily": "Inter-SemiBold",
"fontSize": 27,
"lineHeight": 33,
"minHeight": 33,
},
[
{
"color": "#2B78EE",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -495,15 +489,14 @@ exports[`@lad-tech/mobydick-core/modalBase should renders correctly HorizontalBu
style={
[
{
"color": "#FFF",
"color": "#2B78EE",
"fontFamily": "Inter-SemiBold",
"fontSize": 27,
"lineHeight": 33,
"minHeight": 33,
},
[
{
"color": "#2B78EE",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -562,15 +555,14 @@ exports[`@lad-tech/mobydick-core/modalBase should renders correctly HorizontalBu
style={
[
{
"color": "#FFF",
"color": "#2B78EE",
"fontFamily": "Inter-SemiBold",
"fontSize": 27,
"lineHeight": 33,
"minHeight": 33,
},
[
{
"color": "#2B78EE",
"paddingHorizontal": 9,
},
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ exports[`@lad-tech/mobydick-core/modalBase should renders correctly VerticalButt
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,14 @@ exports[`@lad-tech/mobydick-core/modalAsk should renders correctly 1`] = `
style={
[
{
"color": "#FFF",
"color": "#2B78EE",
"fontFamily": "Inter-SemiBold",
"fontSize": 27,
"lineHeight": 33,
"minHeight": 33,
},
[
{
"color": "#2B78EE",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -284,7 +283,6 @@ exports[`@lad-tech/mobydick-core/modalAsk should renders correctly 1`] = `
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -517,7 +515,6 @@ exports[`@lad-tech/mobydick-core/modalAsk should renders correctly with optional
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -584,7 +581,6 @@ exports[`@lad-tech/mobydick-core/modalAsk should renders correctly with optional
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ exports[`@lad-tech/mobydick-core/modalError should renders correctly 1`] = `
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down Expand Up @@ -448,7 +447,6 @@ exports[`@lad-tech/mobydick-core/modalError should renders correctly with option
},
[
{
"color": "#FFF",
"paddingHorizontal": 9,
},
undefined,
Expand Down
Loading

0 comments on commit 878512a

Please sign in to comment.