Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 7297fa9

Browse files
committed
feat(theme): added styled system variables
1 parent 6d71eb6 commit 7297fa9

File tree

20 files changed

+376
-9
lines changed

20 files changed

+376
-9
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"register-service-worker": "^1.6.2",
2121
"style-loader": "^1.0.0",
2222
"vue": "^2.6.10",
23-
"vue-router": "^3.0.3"
23+
"vue-router": "^3.0.3",
24+
"vue-styled-components": "^1.4.13"
2425
},
2526
"devDependencies": {
2627
"@babel/core": "^7.6.0",

src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
<script>
1515
import Button from './components/Button'
16-
import { useIncrement } from './use-increment'
16+
import { useIncrement as useFeature } from './use-increment'
1717
1818
export default {
1919
setup () {
20-
const { state, increment } = useIncrement()
20+
const { state, increment } = useFeature()
2121
2222
return {
2323
state,

src/components/Box/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// import styled from 'vue-styled-components'

src/components/Button/button.styled.js

Whitespace-only changes.

src/components/Button/index.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as Vue from 'vue';
2+
3+
declare const Button: Vue.Component<{
4+
as?: String,
5+
color?: String,
6+
variant?: String,
7+
active?: Boolean,
8+
disabled?: Boolean,
9+
isLoading?: Boolean,
10+
size?: String,
11+
loadingText?: String,
12+
px?: String,
13+
py?: String,
14+
iconSpacing?: String,
15+
rounded?: Boolean,
16+
ripple?: Boolean,
17+
shadow?: Boolean
18+
}>;
19+
export default Button;

src/components/Button/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<script>
2222
export default {
2323
name: 'Button',
24-
inject: ['KiwiTheme'],
24+
inject: ['theme', 'colorMode'],
2525
props: {
2626
as: {
2727
type: String,

src/components/Button/styles.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import styled from 'vue-styled-components'
2+
// import { colors } from '../../lib/theme'
3+
4+
const buttonProps = {
5+
variant: String
6+
}
7+
8+
/**
9+
* @description Determines style colors for solid variant
10+
* @param {{color:String, colorMode:String, _theme:Object }} params
11+
*/
12+
const solidVariantProps = ({ color, colorMode = 'light', _theme }) => {
13+
let style = {
14+
light: {
15+
bg: `${color}.500`,
16+
color: 'white',
17+
_hover: {
18+
bg: `${color}.600`
19+
},
20+
_active: {
21+
bg: `${color}.700`
22+
}
23+
}
24+
}
25+
return style[colorMode]
26+
}
27+
28+
/**
29+
* @description Generates styled for variants
30+
* @param {Object} props
31+
* @returns {Object} Variant styles object
32+
*/
33+
const variantProps = props => {
34+
switch (props.variant) {
35+
case 'solid':
36+
return solidVariantProps(props)
37+
}
38+
}
39+
40+
// const baseProps = {
41+
// display: 'inline-flex',
42+
// appearance: 'none',
43+
// alignItems: 'center',
44+
// justifyContent: 'center',
45+
// transition: 'all 250ms',
46+
// userSelect: 'none',
47+
// position: 'relative',
48+
// whiteSpace: 'nowrap',
49+
// verticalAlign: 'middle',
50+
// lineHeight: '1.2',
51+
// outline: 'none'
52+
// }
53+
54+
const Button = styled('button', buttonProps)`
55+
font-size: 1em;
56+
text-align: center;
57+
padding: 10px 15px;
58+
border-radius: ${({ radius }) => radius ? '6px' : null};
59+
${(props) => variantProps(props)}
60+
`
61+
62+
export default Button
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as Vue from 'vue';
2+
3+
declare const ThemeProvider: Vue.Component<{ theme?: Object }>;
4+
export default ThemeProvider;
5+

src/lib/plugin/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import Theme from '../../../kiwi.config'
33
const Kiwi = {
44
install (Vue, options = {}) {
55
// Create Kiwi instance and initialize theme
6-
const KiwiTheme = {
6+
const theme = {
77
...Theme,
88
...options.theme
99
}
1010

1111
Vue.prototype.$kiwi = {
12-
theme: KiwiTheme
12+
theme
1313
}
1414

1515
// TODO:
@@ -18,7 +18,7 @@ const Kiwi = {
1818
// Provide Theme via global mixin.
1919
Vue.mixin({
2020
provide: {
21-
KiwiTheme
21+
theme
2222
}
2323
})
2424
}

src/lib/theme/borders.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @description These border styles were adapted from [@chakra-ui](https://chakra-ui.com/)
3+
*/
4+
const borders = {
5+
none: 0,
6+
'1px': '1px solid',
7+
'2px': '2px solid',
8+
'4px': '4px solid'
9+
}
10+
11+
export default borders

0 commit comments

Comments
 (0)