Skip to content

Commit d42af74

Browse files
WesSouzaarturbien
authored andcommitted
refactor(common): change isDisabled common prop to $disabled
1 parent 0c9d7c4 commit d42af74

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/common/index.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { css, ThemedStyledProps } from 'styled-components';
2-
import { Color, CommonThemeProps, Theme } from '../types';
3-
4-
type CSSProps = ThemedStyledProps<CommonThemeProps, Theme>;
1+
import { css } from 'styled-components';
2+
import { Color, CommonThemeProps } from '../types';
53

64
export const shadow = '4px 4px 10px 0 rgba(0, 0, 0, 0.35)';
75
export const insetShadow = 'inset 2px 2px 3px rgba(0,0,0,0.2)';
@@ -47,13 +45,13 @@ export const createHatchedBackground = ({
4745
background-position: 0 0, ${`${pixelSize}px ${pixelSize}px`};
4846
`;
4947

50-
export const createFlatBoxStyles = () => css`
48+
export const createFlatBoxStyles = () => css<CommonThemeProps>`
5149
position: relative;
5250
box-sizing: border-box;
5351
display: inline-block;
5452
color: ${({ theme }) => theme.materialText};
55-
background: ${({ theme, isDisabled }: CSSProps) =>
56-
isDisabled ? theme.flatLight : theme.canvas};
53+
background: ${({ $disabled, theme }) =>
54+
$disabled ? theme.flatLight : theme.canvas};
5755
border: 2px solid ${({ theme }) => theme.canvas};
5856
outline: 2px solid ${({ theme }) => theme.flatDark};
5957
outline-offset: -4px;
@@ -64,18 +62,18 @@ export const createBorderStyles = ({
6462
windowBorders = false
6563
} = {}) =>
6664
invert
67-
? css`
65+
? css<CommonThemeProps>`
6866
border-style: solid;
6967
border-width: 2px;
7068
border-left-color: ${({ theme }) => theme.borderDarkest};
7169
border-top-color: ${({ theme }) => theme.borderDarkest};
7270
border-right-color: ${({ theme }) => theme.borderLightest};
7371
border-bottom-color: ${({ theme }) => theme.borderLightest};
74-
box-shadow: ${(props: CSSProps) => props.shadow && `${shadow}, `} inset
75-
1px 1px 0px 1px ${({ theme }) => theme.borderDark},
72+
box-shadow: ${props => props.shadow && `${shadow}, `} inset 1px 1px 0px
73+
1px ${({ theme }) => theme.borderDark},
7674
inset -1px -1px 0 1px ${({ theme }) => theme.borderLight};
7775
`
78-
: css`
76+
: css<CommonThemeProps>`
7977
border-style: solid;
8078
border-width: 2px;
8179
border-left-color: ${({ theme }) =>
@@ -84,8 +82,8 @@ export const createBorderStyles = ({
8482
windowBorders ? theme.borderLight : theme.borderLightest};
8583
border-right-color: ${({ theme }) => theme.borderDarkest};
8684
border-bottom-color: ${({ theme }) => theme.borderDarkest};
87-
box-shadow: ${(props: CSSProps) => props.shadow && `${shadow}, `} inset
88-
1px 1px 0px 1px
85+
box-shadow: ${props => props.shadow && `${shadow}, `} inset 1px 1px 0px
86+
1px
8987
${({ theme }) =>
9088
windowBorders ? theme.borderLightest : theme.borderLight},
9189
inset -1px -1px 0 1px ${({ theme }) => theme.borderDark};

src/types.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export type CommonStyledProps = {
1919
};
2020

2121
export type CommonThemeProps = {
22-
// TODO: Rename to base `disabled`
23-
isDisabled?: boolean;
22+
$disabled?: boolean;
2423
shadow?: boolean;
2524
};
2625

0 commit comments

Comments
 (0)