Skip to content

Commit e4f6aa1

Browse files
authored
Merge pull request #3 from v-vibe/next
release: v1.0.0-beta.2
2 parents 807f97b + 4533261 commit e4f6aa1

File tree

19 files changed

+80
-52
lines changed

19 files changed

+80
-52
lines changed

.github/workflows/docs-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Deploy docs site to Pages
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [main, beta]
66

77
# workflow_dispatch:
88

.idea/codeStyles/Project.xml

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/markdown.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/prettier.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vue-styled-components.iml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"semi": false,
2+
"semi": true,
33
"singleQuote": true,
44
"trailingComma": "none",
55
"tabWidth": 2,

core/helper/is.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function isTag(target: any) {
55
}
66

77
export function isStyledComponent(target: any) {
8-
return typeof target === 'object' && 'styled' in target
8+
return typeof target === 'object' && target?.name?.includes('styled')
99
}
1010

1111
export function isVueComponent(target: any) {

core/styled.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
import {
2-
defineComponent,
3-
DefineSetupFnComponent,
4-
h,
5-
inject,
6-
onMounted,
7-
PropType,
8-
PublicProps,
9-
reactive,
10-
SlotsType,
11-
useSlots,
12-
watchEffect
13-
} from 'vue'
1+
import { defineComponent, DefineSetupFnComponent, h, inject, onMounted, PropType, PublicProps, reactive, SlotsType, watchEffect } from 'vue'
142
import domElements, { type SupportedHTMLElements } from '@/constants/domElements'
153
import { type ExpressionsType, generateClassName, generateComponentName, insertExpressions } from '@/utils'
164
import { injectStyle } from '@/utils/injectStyle'
@@ -68,14 +56,13 @@ function baseStyled(target: string | InstanceType<any>, propsDefinition: Record<
6856
styledClassNameMap[componentName] = className
6957

7058
return defineComponent(
71-
(props) => {
59+
(props, { slots }) => {
7260
const myAttrs = { ...attributes }
7361
const theme = reactive(inject<Record<string, string | number>>('$theme', {}))
7462
let context = {
7563
theme,
7664
...props
7765
}
78-
7966
myAttrs.class = className
8067

8168
watchEffect(() => {
@@ -92,9 +79,8 @@ function baseStyled(target: string | InstanceType<any>, propsDefinition: Record<
9279

9380
// Return the render function
9481
return () => {
95-
const slots = useSlots()
9682
return h(
97-
isVueComponent(target) ? target : props?.as || target,
83+
isVueComponent(target) ? h(target, { as: props.as }) : props.as ?? target,
9884
{
9985
...myAttrs
10086
},
@@ -110,9 +96,8 @@ function baseStyled(target: string | InstanceType<any>, propsDefinition: Record<
11096
},
11197
...propsDefinition
11298
},
113-
inheritAttrs: true,
114-
styled: true
115-
} as any
99+
inheritAttrs: true
100+
}
116101
)
117102
}
118103

docs/guide/advances/theming.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ the `ThemeProvider`'s scope can access this theme object.
1717

1818
```vue
1919
<script setup lang="ts">
20-
import { styled, ThemeProvider } from '@vue-styled-components/core'
20+
import { styled, ThemeProvider } from '@vvibe/vue-styled-components'
2121
2222
const StyledWrapper = styled.div`
2323
display: flex;
@@ -54,7 +54,7 @@ and see the updates reflected in your styled components.
5454

5555
```vue
5656
<script setup lang="ts">
57-
import { styled, ThemeProvider } from '@vue-styled-components/core'
57+
import { styled, ThemeProvider } from '@vvibe/vue-styled-components'
5858
import { ref } from 'vue'
5959
6060
const theme = ref<Record<string, string>>({ primary: 'blue' })
@@ -112,7 +112,7 @@ and use properties defined in the theme for their styles.
112112

113113
```vue
114114
<script setup lang="ts">
115-
import { ThemeProvider } from '@vue-styled-components/core'
115+
import { ThemeProvider } from '@vvibe/vue-styled-components'
116116
import { defineComponent, h, inject } from 'vue'
117117
118118
const Link = defineComponent(() => {

docs/guide/api/core.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ It is a factory function.
2121

2222
```vue
2323
<script setup lang="ts">
24-
import { styled } from '@vue-styled-components/core'
24+
import { styled } from '@vvibe/vue-styled-components'
2525
2626
const StyledDiv = styled('div', { color: String })`
2727
width: 100%;
@@ -50,7 +50,7 @@ const StyledDiv = styled('div', { color: String })`
5050

5151
```vue
5252
<script setup lang="ts">
53-
import { styled } from '@vue-styled-components/core'
53+
import { styled } from '@vvibe/vue-styled-components'
5454
5555
const StyledDiv = styled.div`
5656
width: 40px;
@@ -79,7 +79,7 @@ It is used for passing attributes to styled component.
7979

8080
```vue
8181
<script setup lang="ts">
82-
import { styled } from '@vue-styled-components/core'
82+
import { styled } from '@vvibe/vue-styled-components'
8383
8484
const InputWithValue = styled.input.attrs({ value: "I'm input with default value. 🥺" })`
8585
width: 100%;

docs/guide/api/helper.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A function to create a `style component` that can be used to handle global style
2121
```vue
2222
2323
<script setup>
24-
import { createGlobalStyle } from '@vue-styled-components/core'
24+
import { createGlobalStyle } from '@vvibe/vue-styled-components'
2525
2626
const GlobalStyle = createGlobalStyle`
2727
body {
@@ -51,7 +51,7 @@ A function to generate keyframes. It takes a template literal as an argument and
5151
```vue
5252
5353
<script setup lang="ts">
54-
import { styled, keyframes } from '@vue-styled-components/core'
54+
import { styled, keyframes } from '@vvibe/vue-styled-components'
5555
5656
const animation = keyframes`
5757
from {
@@ -89,7 +89,7 @@ A function to generate CSS from a template literal with interpolations.
8989
```vue
9090
9191
<script setup lang="ts">
92-
import { styled, css } from '@vue-styled-components/core'
92+
import { styled, css } from '@vvibe/vue-styled-components'
9393
9494
const mixin = css`
9595
color: red;
@@ -123,7 +123,7 @@ A function to add attributes to a `ComponentInstance` or `HTMLElements`.
123123
```vue
124124
125125
<script setup lang="ts">
126-
import { withAttrs } from '@vue-styled-components/core'
126+
import { withAttrs } from '@vvibe/vue-styled-components'
127127
128128
const DivWithAttrs = withAttrs('div', {
129129
class: 'div-with-attrs'

docs/guide/basic/animations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ a styled component.
88

99
```vue
1010
<script setup lang="ts">
11-
import { styled, keyframes } from '@vue-styled-components/core'
11+
import { styled, keyframes } from '@vvibe/vue-styled-components'
1212
1313
const rotate = keyframes`
1414
from {

docs/guide/basic/extending-styles.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ code reusability and maintainability.
1313

1414
```vue
1515
<script setup lang="ts">
16-
import { styled } from '@vue-styled-components/core'
16+
import { styled } from '@vvibe/vue-styled-components';
1717
1818
const BlueButton = styled.button`
1919
width: 120px;
@@ -24,11 +24,11 @@ const BlueButton = styled.button`
2424
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
2525
background-color: skyblue;
2626
font-weight: bold;
27-
`
27+
`;
2828
const RedButton = styled(BlueButton)`
2929
background-color: darkred;
3030
color: white;
31-
`
31+
`;
3232
</script>
3333
3434
<template>
@@ -52,7 +52,7 @@ For more advanced use cases, you can pass the `as` props to the styled component
5252

5353
```vue
5454
<script setup lang="ts">
55-
import { styled } from '@vue-styled-components/core'
55+
import { styled } from '@vvibe/vue-styled-components';
5656
5757
const BlueButton = styled.button`
5858
width: 120px;
@@ -63,15 +63,16 @@ const BlueButton = styled.button`
6363
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
6464
background-color: skyblue;
6565
font-weight: bold;
66-
`
66+
`;
6767
const RedButton = styled(BlueButton)`
6868
background-color: darkred;
6969
color: white;
70-
`
70+
`;
7171
const LinkButton = styled(BlueButton)`
7272
border: none;
73-
color: blue;
74-
`
73+
background-color: transparent;
74+
box-shadow: none;
75+
`;
7576
</script>
7677
7778
<template>

docs/guide/basic/passed-props.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ styled input.
1212
```vue
1313
<script setup lang="ts">
1414
import { ref } from 'vue'
15-
import { styled } from '@vue-styled-components/core'
15+
import { styled } from '@vvibe/vue-styled-components'
1616
1717
const borderColor = ref('darkred')
1818
const inputProps = { borderColor: String }

docs/guide/basic/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pnpm i vue-styled-components
3030

3131
```vue
3232
<script setup lang="ts">
33-
import { styled } from '@vue-styled-components/core'
33+
import { styled } from '@vvibe/vue-styled-components'
3434
3535
const StyledDiv = styled.div`
3636
display: flex;

docs/guide/basic/styling-any-component.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Using the `styled` function to style the `Link` component, you can achieve a `da
2525

2626
```vue
2727
<script setup lang="ts">
28-
import { styled } from '@vue-styled-components/core'
28+
import { styled } from '@vvibe/vue-styled-components'
2929
import Link from '/demo/Link.vue'
3030
3131
const StyledLink = styled(Link)`
@@ -49,7 +49,7 @@ a `blue link`.
4949

5050
```vue
5151
<script setup lang="ts">
52-
import { styled } from '@vue-styled-components/core'
52+
import { styled } from '@vvibe/vue-styled-components'
5353
5454
const StyledLink = styled.a`
5555
color: darkred !important;

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
"vitepress-theme-demoblock": "^3.0.7"
1818
},
1919
"dependencies": {
20-
"@vue-styled-components/core": "workspace:^"
20+
"@vvibe/vue-styled-components": "1.0.0-beta.1"
2121
}
2222
}

example/App.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ const mixin = css`
5252
const StyledComp7 = styled('button', { color: String })`
5353
${mixin}
5454
`
55+
const BlueButton = styled.button`
56+
width: 120px;
57+
height: 40px;
58+
margin-right: 8px;
59+
padding: 4px 8px;
60+
border-radius: 9999px;
61+
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
62+
background-color: skyblue;
63+
font-weight: bold;
64+
color: #fff;
65+
`
66+
const LinkButton = styled(BlueButton)`
67+
border: none;
68+
`
5569
</script>
5670

5771
<template>
@@ -61,6 +75,7 @@ const StyledComp7 = styled('button', { color: String })`
6175
<StyledComp5>12345</StyledComp5>
6276
<WithAttrsComp color="red">123</WithAttrsComp>
6377
<StyledComp7 color="blue">123</StyledComp7>
78+
<LinkButton as="a" href="#">Link Button</LinkButton>
6479
</ThemeProvider>
6580
</template>
6681

pnpm-lock.yaml

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)