Skip to content

Commit

Permalink
feat: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaSimonePorceddu authored and Mauro Erta committed Nov 30, 2022
1 parent 835510b commit 4e191da
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
1 change: 0 additions & 1 deletion packages/core/src/parsers/colors/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export function parseColor({
}
}


const color = theme.getValue('colors', value as Color);

if (color && color.indexOf('$') === 0) {
Expand Down
18 changes: 13 additions & 5 deletions packages/core/tests/parsers/components.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const THEME: Theme = {
danger: {
bg: 'danger',
borderColor: 'warning',
borderWidth: '1px'
}
borderWidth: '1px',
},
},
variants: {
primary: {
Expand All @@ -32,7 +32,7 @@ const THEME: Theme = {
danger: {
bg: 'warning',
borderColor: 'danger',
}
},
},
},
},
Expand Down Expand Up @@ -151,7 +151,11 @@ describe('components', () => {
componentName: 'Box',
state: 'danger',
});
expect(result).toEqual({ backgroundColor: 'red', borderColor: 'orange', borderWidth: '1px' });
expect(result).toEqual({
backgroundColor: 'red',
borderColor: 'orange',
borderWidth: '1px',
});
});

test('should return the variant state style if state is declared within the variant', () => {
Expand All @@ -160,7 +164,11 @@ describe('components', () => {
variant: 'primary',
state: 'danger',
});
expect(result).toEqual({ backgroundColor: 'orange', borderColor: 'red', color: '#000' });
expect(result).toEqual({
backgroundColor: 'orange',
borderColor: 'red',
color: '#000',
});
});

test("should return the default style if the declared state doesn't exist", () => {
Expand Down
16 changes: 10 additions & 6 deletions packages/spec/src/types/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ export interface ComponentMeta {
};
}

type ComponentStyle<Props extends Style = Style, State extends string = string> = {
type ComponentStyle<
Props extends Style = Style,
State extends string = string,
> = {
tag?: string;
style: Style;
props?: Props;
meta?: ComponentMeta;
states: Record<State, Style>
states: Record<State, Style>;
};

export type ComponentConfig<
Variant extends string = string,
Props extends Style = Style,
State extends string = string
State extends string = string,
> = ComponentStyle<Props, State> & {
variants: Record<Variant, ComponentStyle<Props>>;
};
Expand All @@ -44,11 +47,12 @@ type StateMap = {
export type Variant<C extends Component = Component> =
VariantMap[C] extends string ? VariantMap[C] : string;

export type State <C extends Component = Component> =
StateMap[C] extends string ? StateMap[C] : string;
export type State<C extends Component = Component> = StateMap[C] extends string
? StateMap[C]
: string;

export type ComponentProps<C extends Component = Component> = {
componentName?: C;
variant?: Variant<C>;
state?: State<C>
state?: State<C>;
};

0 comments on commit 4e191da

Please sign in to comment.