-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from matheusps/feature/theme-strategy
Feature/theme strategy
- Loading branch information
Showing
12 changed files
with
76 additions
and
36 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 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,27 +1,26 @@ | ||
import React, { FunctionComponent } from 'react' | ||
import styled from 'styled-components' | ||
import { selectTheme } from '../../global/helpers' | ||
|
||
interface ContainerProps { | ||
bg: 'primary' | ||
theme?: any | ||
} | ||
interface Props extends EnhancedWithTheme {} | ||
|
||
const Div = styled.div` | ||
background-color: ${(props: ContainerProps) => { | ||
switch (props.bg) { | ||
case 'primary': | ||
return props.theme.color.primary.lighten | ||
} | ||
}}; | ||
const Div = styled.div<EnhancedWithTheme>` | ||
background-color: ${props => | ||
selectTheme(props.theme, props.color, props.shade)}; | ||
padding: 1rem; | ||
` | ||
|
||
const Container: FunctionComponent<ContainerProps> = ({ bg, children }) => { | ||
return <Div bg={bg}>{children}</Div> | ||
const Container: FunctionComponent<Props> = ({ color, shade, children }) => { | ||
return ( | ||
<Div color={color} shade={shade}> | ||
{children} | ||
</Div> | ||
) | ||
} | ||
|
||
Container.defaultProps = { | ||
bg: 'primary', | ||
color: 'primary', | ||
shade: 'lighten', | ||
} | ||
|
||
export default Container |
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,7 +1,12 @@ | ||
Loader colors | ||
|
||
```js | ||
|
||
<Loader /> | ||
<Loader shade='lighten' /> | ||
<Loader shade='darken' /> | ||
|
||
<Loader color='secondary' /> | ||
<Loader color='success' /> | ||
|
||
``` |
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,10 +1,6 @@ | ||
type Measure = 'sm' | 'md' | 'lg' | 'xl' | ||
type Speed = 'fast' | 'slow' | 'normal' | ||
type Color = 'primary' | 'secondary' | 'success' | ||
interface LoaderProps { | ||
color?: Color | ||
speed?: Speed | ||
gap?: Measure | ||
thickness?: Measure | ||
size?: string | ||
interface LoaderProps extends EnhancedWithTheme { | ||
readonly speed?: Speed | ||
readonly gap?: Measure | ||
readonly thickness?: Measure | ||
readonly size?: string | ||
} |
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,5 +1,5 @@ | ||
export const light = { | ||
color: { | ||
colors: { | ||
base: { | ||
default: '#fafafa', | ||
darken: '#cecece', | ||
|
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,7 @@ | ||
import { get } from 'lodash' | ||
|
||
export const selectTheme = ( | ||
props?: ThemeProps, | ||
choose?: Color, | ||
shade?: Shade | ||
): string => get(props!, `colors.${choose!}.${shade!}`) |
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,29 @@ | ||
type Measure = 'sm' | 'md' | 'lg' | 'xl' | ||
type Speed = 'fast' | 'slow' | 'normal' | ||
|
||
type Color = 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error' | ||
|
||
type Shade = 'default' | 'lighten' | 'darken' | 'constrast' | ||
interface Shades { | ||
default: string | ||
lighten: string | ||
darken: string | ||
constrast: string | ||
} | ||
interface ColorSystem { | ||
readonly base: Shades | ||
readonly primary: Shades | ||
readonly secondary: Shades | ||
readonly success: Shades | ||
readonly info: Shades | ||
readonly warning: Shades | ||
readonly error: Shades | ||
} | ||
interface ThemeProps { | ||
readonly colors: ColorSystem | ||
} | ||
|
||
interface EnhancedWithTheme { | ||
readonly color?: Color | ||
readonly shade?: Shade | ||
} |
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