Skip to content

Commit

Permalink
feat(runtime): fully rewrite and tests runtime features ; whole packa…
Browse files Browse the repository at this point in the history
…ge fully covered
  • Loading branch information
Tahul committed Sep 12, 2023
1 parent 6752770 commit 15e818f
Show file tree
Hide file tree
Showing 151 changed files with 4,741 additions and 2,251 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"max-statements-per-line": "off",
"@typescript-eslint/prefer-ts-expect-error": "off",
"no-console":"off",
"@typescript-eslint/ban-types": "off"
"@typescript-eslint/ban-types": "off",
"vue/one-component-per-file": "off"
},
"overrides": [
{
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"devDependencies": {
"@nuxt-themes/docus": "^1.14.6",
"@types/node": "^20.5.7",
"@types/node": "^20.6.0",
"@vueuse/motion": "^2.0.0"
}
}
58 changes: 3 additions & 55 deletions examples/nuxt/app.vue
Original file line number Diff line number Diff line change
@@ -1,57 +1,5 @@
<template>
<main>
<p>
{{ color }}
</p>
<MyButton />
</main>
<App>
<NuxtPage />
</App>
</template>

<script setup lang="ts">
import theme from '$pinceau/theme'
const color = ref('blue')
const colors = Object.keys(theme.color)
const rand = array => array[Math.floor(Math.random() * array.length)];
let interval: NodeJS.Timeout
onMounted(() => {
if (interval) clearInterval(interval)
interval = setInterval(
() => {
color.value = rand(colors)
},
1000
)
})
</script>

<style lang="ts">
css({
'html, body, #__nuxt': {
minHeight: '100vh',
minWidth: '100vw'
}
})
</style>

<style scoped lang="ts">
css({
main: {
color: '$color.blue.1',
backgroundColor: '$color.blue.9',
minHeight: '100vh',
minWidth: '100vw',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
padding: '$space.16'
},
p: {
marginBottom: 24
}
})
</style>
6 changes: 6 additions & 0 deletions examples/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export default defineNuxtConfig({
modules: [
'@pinceau/nuxt',
],
components: [
{
path: resolve('../shared'),
global: true
}
],
pinceau: {
theme: {
layers: [
Expand Down
2 changes: 1 addition & 1 deletion examples/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"pinceau": "workspace:*"
},
"devDependencies": {
"nuxt": "^3.7.0"
"nuxt": "^3.7.1"
},
"stackblitz": {
"installDependencies": false,
Expand Down
5 changes: 5 additions & 0 deletions examples/nuxt/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<MyButton size="xl" color="green" />
</div>
</template>
48 changes: 48 additions & 0 deletions examples/shared/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<template>
<main>
<slot />
</main>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import theme from '$pinceau/theme'
const color = ref('blue')
const colors = Object.keys(theme.color)
const rand = (array: any[]) => array[Math.floor(Math.random() * array.length)];
let interval: NodeJS.Timeout
onMounted(() => {
if (interval) clearInterval(interval)
interval = setInterval(
() => {
color.value = rand(colors)
},
1000
)
})
</script>

<style lang="ts">
css({
'html, body, #__nuxt': {
minHeight: '100vh',
minWidth: '100vw'
}
})
</style>

<style scoped lang="ts">
css({
main: {
color: '$color.blue.1',
backgroundColor: '$color.blue.9',
minHeight: '100vh',
minWidth: '100vw',
padding: '$space.16'
}
})
</style>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
withDefaults(
const props = withDefaults(
defineProps<{
color?: StyleProp<keyof PinceauTheme['color']>
color?: keyof PinceauTheme['color']
}>(),
{
color: 'blue'
color: 'green'
}
)
</script>
Expand All @@ -23,58 +23,57 @@ withDefaults(
<style scoped lang="ts">
css({
'.my-button': {
'--button-primary': (props) => `$color.${props.color}.600`,
'--button-secondary': (props) => `$color.${props.color}.500`,
'--button-bg': () => `$color.${props.color}.5`,
'--button-border': () => `$color.${props.color}.6`,
'--button-active': () => `$color.${props.color}.4`,
transition: 'all 333ms ease-out',
display: 'inline-block',
borderRadius: '$radii.xl',
transition: '$transition.all',
borderRadius: '$radii.xs',
color: '$color.white',
boxShadow: `0 5px 0 $button.primary, 0 12px 16px $color.dimmed`,
backgroundColor: '$button.bg',
span: {
boxShadow: 'inset 0 0 0 2px $button.border, 0 1px 2px $color.black',
display: 'inline-block',
fontFamily: '$font.sans',
borderRadius: '$radii.lg',
borderRadius: '$radii.xs',
fontSize: '$fontSize.xl',
lineHeight: '$lead.none',
transition: '$transition.all',
backgroundColor: '$button.primary',
boxShadow: 'inset 0 -1px 1px $color.dark',
lineHeight: '0',
},
'&:hover': {
span: {
backgroundColor: `$button.secondary`,
backgroundColor: `$button.border`,
}
},
'&:active': {
span: {
transform: 'translateY($space.4)'
boxShadow: 'inset 0 0 0 2px $button.active',
}
}
},
variants: {
size: {
sm: {
span: {
padding: '$space.6 $space.12',
padding: '$space.3 $space.6',
},
},
md: {
span: {
padding: '$space.12 $space.16'
padding: '$space.4 $space.8'
},
},
lg: {
span: {
padding: '$space.16 $space.24'
padding: '$space.6 $space.12'
},
},
xl: {
span: {
padding: '$space.32 $space.48'
padding: '$space.8 $space.16'
},
},
options: {
default: 'sm',
default: 'md',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion examples/vite-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"pinceau": "workspace:*"
},
"devDependencies": {
"typescript": "^5.2.0",
"typescript": "^5.2.2",
"vite": "^4.4.9"
}
}
2 changes: 1 addition & 1 deletion examples/vite-lib/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createResolver } from '@nuxt/kit'
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Pinceau from 'pinceau/plugin'
import { Pinceau } from 'pinceau/plugin'

const resolve = (p: string) => createResolver(import.meta.url).resolve(p)

Expand Down
35 changes: 12 additions & 23 deletions examples/vite-vue/app.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
<template>
<main class="main">
<Navigation />
<App class="main">
<div
:styled="{
width: '100%',
}"
>
<Navigation />
</div>

<RouterView />
</main>
</App>
</template>


<style lang="ts">
css({
'html, body, #app': {
height: '100vh',
width: '100vw',
backgroundColor: '$color.blue.2'
},
})
</style>

<style scoped lang="ts">
css({
'.main': {
width: '100%',
height: '100%',
padding: '$space.8',
}
})
</style>
<script lang="ts" setup>
import App from '../shared/App.vue'
</script>
5 changes: 4 additions & 1 deletion examples/vite-vue/components/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ import { routes } from '../main'
<style scoped lang="ts">
css({
ul: {
width: '100%',
listStyleType: 'count',
display: 'flex',
flexDirection: 'column',
flexDirection: 'row',
justifyContent: 'space-evenly',
gap: '$space.2',
marginBottom: '2rem',
},
a: {
textTransform: 'capitalize',
Expand Down
2 changes: 1 addition & 1 deletion examples/vite-vue/features/core.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

<style scoped lang="postcss">
div {
background-color: $theme('color.yellow.1');
background-color: $theme('color.yellow.9');
}
</style>
2 changes: 1 addition & 1 deletion examples/vite-vue/features/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

<style scoped lang="postcss">
div {
background-color: $theme('color.green.1');
background-color: $theme('color.green.9');
}
</style>
2 changes: 1 addition & 1 deletion examples/vite-vue/features/runtime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

<style scoped lang="postcss">
div {
background-color: $theme('color.violet.1');
background-color: $theme('color.violet.9');
}
</style>
2 changes: 1 addition & 1 deletion examples/vite-vue/features/theme.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

<style scoped lang="postcss">
div {
background-color: $theme('color.red.1');
background-color: $theme('color.red.9');
}
</style>
30 changes: 0 additions & 30 deletions examples/vite-vue/features/vue-runtime.vue

This file was deleted.

Loading

0 comments on commit 15e818f

Please sign in to comment.