|
1 | | -<script setup lang="ts"> |
2 | | - // This starter template is using Vue 3 <script setup> SFCs |
3 | | - // Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup |
4 | | - import { ref } from "vue"; |
5 | | - import { ColorInput } from "tinycolor2"; |
6 | | - import { ColorPicker } from "../packages"; |
| 1 | +<template> |
| 2 | + <div :style="bg" class="bg">{{ color }}</div> |
7 | 3 |
|
8 | | - const color = ref<ColorInput>("red"); |
| 4 | + <div :style="bgline" class="bg"> {{ gradientColor }} </div> |
9 | 5 |
|
10 | | - const color1 = ref<ColorInput>("green"); |
| 6 | + <div class="main"> |
| 7 | + <div class="color-pickers"> |
| 8 | + <ColorPicker v-model:pureColor="color" /> |
| 9 | + <ColorPicker v-model:pureColor="color" shape="circle" /> |
| 10 | + <ColorPicker v-model:gradientColor="gradientColor" useType="gradient" /> |
| 11 | + </div> |
11 | 12 |
|
12 | | - setTimeout(() => (color.value = "431893"), 100); |
13 | | -</script> |
| 13 | + <div class="color-pickers"> |
| 14 | + <ColorPicker v-model:pureColor="color" is-widget /> |
| 15 | + <ColorPicker v-model:pureColor="color" is-widget pickerType="chrome" /> |
| 16 | + <ColorPicker |
| 17 | + v-model:pureColor="color" |
| 18 | + v-model:gradientColor="gradientColor" |
| 19 | + is-widget |
| 20 | + useType="both" |
| 21 | + /> |
14 | 22 |
|
15 | | -<template> |
16 | | - <img alt="Vue logo" src="./assets/logo.png" /> |
17 | | - {{ color }} |
18 | | - <div> |
19 | | - <div style="display: inline-block"> |
20 | | - <ColorPicker v-model:color="color" format="rgb" id="a1" round /> |
21 | | - </div> |
22 | | - <div style="display: inline-block; margin-left: 30px"> |
23 | | - <ColorPicker v-model:color="color1" picker-type="chrome" format="rgb" id="a2" /> |
| 23 | + <ColorPicker v-model:gradientColor="gradientColor" is-widget useType="gradient" /> |
24 | 24 | </div> |
25 | 25 | </div> |
26 | 26 | </template> |
27 | 27 |
|
| 28 | +<script setup lang="ts"> |
| 29 | + import { computed, ref } from "vue"; |
| 30 | +
|
| 31 | + const color = ref("blue"); |
| 32 | + const gradientColor = ref( |
| 33 | + "linear-gradient(90deg, rgba(255, 255, 255, 1) 0%, rgba(0, 0, 0, 1) 100%)" |
| 34 | + ); |
| 35 | +
|
| 36 | + const bg = computed(() => { |
| 37 | + return { background: color.value }; |
| 38 | + }); |
| 39 | + const bgline = computed(() => { |
| 40 | + return { background: gradientColor.value }; |
| 41 | + }); |
| 42 | +</script> |
| 43 | + |
28 | 44 | <style> |
29 | | - #app { |
| 45 | + body, |
| 46 | + html { |
| 47 | + margin: 0; |
| 48 | + padding: 0; |
30 | 49 | font-family: Avenir, Helvetica, Arial, sans-serif; |
31 | | - -webkit-font-smoothing: antialiased; |
32 | | - -moz-osx-font-smoothing: grayscale; |
33 | 50 | text-align: center; |
34 | | - color: #2c3e50; |
35 | | - margin-top: 60px; |
| 51 | + } |
| 52 | +
|
| 53 | + .main { |
| 54 | + padding: 40px 10%; |
| 55 | + } |
| 56 | +
|
| 57 | + .color-pickers { |
| 58 | + display: flex; |
| 59 | + flex-wrap: wrap; |
| 60 | + gap: 10px; |
| 61 | + margin-bottom: 20px; |
| 62 | + } |
| 63 | +
|
| 64 | + .bg { |
| 65 | + color: #fff; |
| 66 | + font-size: 24px; |
| 67 | + padding: 40px 0; |
36 | 68 | } |
37 | 69 | </style> |
0 commit comments