Skip to content

Commit 683597b

Browse files
committed
fix: box tranparency setting improved
1 parent 01e53e5 commit 683597b

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

components/Box.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { resolveColor } from '../layoutHelper'
44
const props = defineProps({
55
shape: {
66
type: String,
7-
default: 's-s-2-0',
7+
default: 's-s-2-100',
88
},
99
color: {
1010
type: String,
@@ -76,15 +76,11 @@ const style = computed(() => {
7676
// add custom class
7777
s += props.custom
7878
79-
// bg opacity
80-
s += ` opacity-${parts[3]} `
81-
82-
console.log(s)
8379
return s
8480
})
8581
8682
const trans = computed(() => {
87-
const val = 100 - parseInt(props.shape.split('-')[3])
83+
const val = parseInt(props.shape.split('-')[3])
8884
return `${val}%`
8985
})
9086
</script>
@@ -93,7 +89,7 @@ const trans = computed(() => {
9389
</template>
9490
<style scoped>
9591
.binder {
96-
--new-color: color-mix(in srgb, var(--neversink-bg-color), transparent v-bind(trans));
92+
--new-color: color-mix(in srgb, var(--neversink-bg-color), v-bind(trans) transparent);
9793
border-color: var(--neversink-border-color);
9894
background-color: var(--new-color);
9995
color: var(--neversink-text-color);

docs/components/box.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ Draws an empty or filled box. Useful for highlighting and grouping things.
88

99
The `Box` component is used to just draw a rectangle. It has the following props:
1010

11-
- `shape` (optional) the shape of the box. There are four values connected with a kebob style notation. The first element is the shape which can be `s` (square), `r` (rounded) or `f` (full) which is practically a circle. The second element is the border type which can be `s` (solid), `d` (dashed) or `o` (dotted). The third element is the border radius in pixels. The fourth element is the opacity of the fill (0 = transparent, 100=opaque).
12-
For example, the default is 's-s-2-0' which is a rounded rectangle with a 2px border and transparent fill. A few examples appear below.
11+
- `shape` (optional) the shape of the box. There are four values connected with a kebob style notation. The first element is the shape which can be `s` (square), `r` (rounded) or `f` (full) which is practically a circle. The second element is the border type which can be `s` (solid), `d` (dashed) or `o` (dotted). The third element is the border radius in pixels. The fourth element is the opacity of the fill (0 = opaque, 100=transparent). For example, the default is 's-s-2-100' which is a square rectangle with a 2px solid border and transparent fill. A few examples appear below.
1312
- `size` (optional) the size of the square. The default is '150px'.
1413
- `color` (optional) the color of the shape. It uses the color schemes in the theme. The default is 'white' (which means a black border and white fill).
15-
- `custom` (optional) any custom classes you want to add to the box. The default is none.
14+
- `custom` (optional) any custom classes you want to add to the box. The default is none. For example, opacity only applies to the fill not the border but you can change that using `custom` classes.
1615

1716
```md
1817
<Box v-drag />
@@ -33,18 +32,18 @@ But of course you can customise it:
3332
<Box shape='r-d-8-0' width='200px' custom='m-10 ' />
3433

3534
```md
36-
<Box shape='f-o-5-50' color='sky-light' custom='m-10' />
35+
<Box shape='f-o-5-0' color='sky-light' custom='m-10' />
3736
```
3837

39-
<Box shape='f-o-5-50' color='sky-light' custom='m-10' />
38+
<Box shape='f-o-5-0' color='sky-light' custom='m-10' />
4039

4140
more transparent:
4241

4342
```md
44-
<Box shape='f-o-5-10' color='sky-light' custom='m-10' />
43+
<Box shape='f-o-5-75' color='sky-light' custom='m-10' />
4544
```
4645

47-
<Box shape='f-o-5-10' color='sky-light' custom='m-10' />
46+
<Box shape='f-o-5-75' color='sky-light' custom='m-10' />
4847

4948
If can include text as well using a slot
5049

uno.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ export default defineConfig({
194194
'm-10',
195195
'w-150px',
196196
'h-150px',
197+
'z-0',
198+
'z-100',
197199
] /* for the docs */,
198200
],
199201
transformers: [transformerDirectives()],

0 commit comments

Comments
 (0)