|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <div>Hello world</div> |
| 4 | + <TextComponent class="babab"> I am a sample </TextComponent> |
| 5 | + <Heading1>Heading 1</Heading1> |
| 6 | + <H1 color="pink" flex="1" font-size="20px">H1</H1> |
| 7 | + <Thing> |
| 8 | + <div> |
| 9 | + hello |
| 10 | + <Header1>This will be green. <span>I will be red</span></Header1> world |
| 11 | + </div> |
| 12 | + </Thing> |
| 13 | + <Blue>Blue sentence</Blue> |
| 14 | + <HHEDING font-size="35px">Random sentence</HHEDING> |
| 15 | + <HEader12>Header 12</HEader12> |
| 16 | + <Input placeholder="hello world" /> |
| 17 | + <DynamicPropThemedH1 :theme="{ blue: 'blue' }"> |
| 18 | + Dynamic Prop Themed H1 |
| 19 | + </DynamicPropThemedH1> |
| 20 | + <ExpressionH2 :scale="2" class="legacy__class"> |
| 21 | + With Dynamic Functional expression |
| 22 | + </ExpressionH2> |
| 23 | + <Aside> Set me aside </Aside> |
| 24 | + </div> |
| 25 | +</template> |
| 26 | + |
| 27 | +<script lang="tsx" setup> |
| 28 | +import { defineComponent, h } from "vue" |
| 29 | +import styled from "../src" |
| 30 | +
|
| 31 | +const TextComponent = styled.h1` |
| 32 | + color: red; |
| 33 | + font-size: 34px; |
| 34 | + @media (min-width: 420px) { |
| 35 | + color: blue; |
| 36 | + } |
| 37 | +` |
| 38 | +
|
| 39 | +const fontSize = "20px" |
| 40 | +const Heading1 = styled.h1({ fontSize }) |
| 41 | +
|
| 42 | +const H1 = styled.h1( |
| 43 | + (props) => ({ |
| 44 | + color: props.color, |
| 45 | + }), |
| 46 | + (props) => ({ flex: props.flex }), |
| 47 | + { display: "flex" } |
| 48 | +) |
| 49 | +
|
| 50 | +const Header1 = styled.h1` |
| 51 | + font-size: ${fontSize}; |
| 52 | +` |
| 53 | +
|
| 54 | +const HEader12 = styled(Header1)` |
| 55 | + color: purple; |
| 56 | +` |
| 57 | +
|
| 58 | +const Thing = styled.div` |
| 59 | + display: flex; |
| 60 | + color: green; |
| 61 | + & div { |
| 62 | + & span { |
| 63 | + color: red; |
| 64 | + } |
| 65 | + } |
| 66 | +` |
| 67 | +const Blue = styled("h2")` |
| 68 | + font-size: ${() => fontSize}; |
| 69 | +` |
| 70 | +
|
| 71 | +const margin = (t, r, b, l) => { |
| 72 | + return (props) => ({ |
| 73 | + marginTop: t, |
| 74 | + marginRight: r, |
| 75 | + marginBottom: b, |
| 76 | + marginLeft: l, |
| 77 | + }) |
| 78 | +} |
| 79 | +
|
| 80 | +const HHEDING = styled.h1` |
| 81 | + background-color: hotpink; |
| 82 | + ${(props) => props.prop && { fontSize: "3rem" }}; |
| 83 | + ${margin(0, "auto", 0, "auto")}; |
| 84 | + color: green; |
| 85 | +` |
| 86 | +
|
| 87 | +const Input = styled("input")({ |
| 88 | + "::placeholder": { |
| 89 | + backgroundColor: "green", |
| 90 | + }, |
| 91 | +}) |
| 92 | +
|
| 93 | +const DynamicPropThemedH1 = styled("h1")` |
| 94 | + text-decoration: ${"underline"}; |
| 95 | + border-right: solid blue 54px; |
| 96 | + background: ${"white"}; |
| 97 | + color: ${"black"}; |
| 98 | + display: ${"block"}; |
| 99 | + border-radius: ${"3px"}; |
| 100 | + padding: ${"25px"}; |
| 101 | + width: ${"500px"}; |
| 102 | + z-index: ${100}; |
| 103 | + font-size: ${"18px"}; |
| 104 | + text-align: ${"center"}; |
| 105 | + border-left: ${(p) => p.theme.blue}; |
| 106 | +` |
| 107 | +
|
| 108 | +const fontSizeNo = 20 |
| 109 | +const ExpressionH1 = styled("h1")` |
| 110 | + font-size: ${fontSizeNo + "px"}; |
| 111 | +` |
| 112 | +
|
| 113 | +var Aside = styled.aside` |
| 114 | + padding: 3px; |
| 115 | + font-weight: bold; |
| 116 | +` |
| 117 | +const ExpressionH2 = styled(ExpressionH1)` |
| 118 | + font-size: ${({ scale }) => fontSizeNo * scale + "px"}; |
| 119 | +` |
| 120 | +</script> |
0 commit comments