Skip to content

Commit 2b8077d

Browse files
committed
feat: add Style component
1 parent e55bd63 commit 2b8077d

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/components/EStyle.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineComponent, h } from 'vue'
2+
3+
export default defineComponent({
4+
name: 'EStyle',
5+
setup(_, { slots }) {
6+
return () => h('style', {}, slots.default?.())
7+
},
8+
})

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ export { default as ESection } from './ESection'
1515
export { default as ETailwind } from './ETailwind'
1616
export { default as EText } from './EText'
1717
export { default as EMarkdown } from './EMarkdown'
18+
export { default as EStyle } from './EStyle'

tests/Style.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { h } from 'vue'
3+
import { EHead, EStyle, useRender } from '../src'
4+
5+
describe('render', () => {
6+
it('renders the <Style> component', async () => {
7+
const component = h(EStyle, `.pager.inactive {display: none;}`)
8+
9+
const actualOutput = await useRender(component)
10+
11+
expect(actualOutput.html).toMatchInlineSnapshot(
12+
'"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><style>.pager.inactive {display: none;}</style>"',
13+
)
14+
})
15+
16+
it('renders the <Head> with <Style> component with title', async () => {
17+
const component = h(EHead, undefined, {
18+
default: () => h(EStyle, `.pager.inactive {display: none;}`),
19+
})
20+
21+
const actualOutput = await useRender(component)
22+
23+
expect(actualOutput.html).toMatchInlineSnapshot(
24+
'"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style>.pager.inactive {display: none;}</style></head>"',
25+
)
26+
})
27+
})

0 commit comments

Comments
 (0)