@nanarino/stylus 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,114 @@
1
+ .{prefix}-checkbox
2
+
3
+ // --indent-checkbox 1.4em
4
+ // --color-checkbox var(--primary-6)
5
+ // --color-checkbox:disabled var(--primary-3)
6
+
7
+ min-height var(--line-height-body)
8
+ position relative
9
+ /** 設置行高后會未對齊 */
10
+ // line-height var(--line-height-body)
11
+ // font-size var(--font-size-body)
12
+ display inline-flex
13
+ // text-indent 1.4em // IOS中不支持 遂改用label的padding-left
14
+ // vertical-align middle
15
+ .{prefix}-input:where(input[type=checkbox])
16
+ border 0
17
+ width 16px
18
+ height 16px
19
+ top 0
20
+ bottom 0
21
+ margin auto 0
22
+ position absolute
23
+ z-index 1
24
+ opacity 0
25
+ cursor pointer
26
+ &:disabled
27
+ cursor not-allowed
28
+ /.{prefix}-input-wrapper
29
+ &:has(^[0..1])
30
+ gap 8px
31
+ ~/-label
32
+ padding-left var(--indent-checkbox, 1.4em)
33
+ min-width 2px
34
+ min-height 1em
35
+ position relative
36
+ display inline-flex
37
+ align-items center
38
+ &[for]
39
+ cursor pointer
40
+ /**
41
+ * 使用 `^[1..1]` 代替 `../` 减少编译后体积以及选择器冗余
42
+ */
43
+ ^[1..1]:focus-visible+&
44
+ outline 2px solid rgb(var(_get_var_by("color-input\*", wrapper), var(_get_var_by("outline-color-\*\:focus"))))
45
+ border-radius var(--border-radius-sm)
46
+ ^[1..1]:disabled+&
47
+ color rgb(var(--gray-6))
48
+ &[for]
49
+ cursor not-allowed
50
+ /**
51
+ * 外框
52
+ */
53
+ ~/-label::before
54
+ content ''
55
+ width 16px
56
+ height 16px
57
+ box-sizing border-box
58
+ border 2px solid rgb(var(--gray-4))
59
+ position absolute
60
+ left 0
61
+ background-color rgb(var(--white))
62
+ border-radius var(--border-radius-sm)
63
+ transition border-color .3s
64
+ ^[1..1]:not(:disabled):hover+&
65
+ border-color rgb(var(--color-checkbox, var(--primary-6)))
66
+ ^[1..1]:checked+&
67
+ border-color rgb(var(--color-checkbox, var(--primary-6)))
68
+ background-color @border-color
69
+ ^[1..1]:checked:disabled+&
70
+ border-color rgb(var(_get_var_by("color-checkbox\:disabled"), var(--primary-3)))
71
+ background-color @border-color
72
+ ^[1..1]:disabled+&
73
+ background-color rgb(var(--gray-1))
74
+ ^[1..1]:disabled:not(:checked)+&
75
+ background-color rgb(var(--gray-2))
76
+ ~/[data-indeterminate] &
77
+ padding 2px
78
+ background-color rgb(var(--color-checkbox, var(--primary-6)))
79
+ background-clip content-box
80
+ ~/[data-indeterminate] ^[-2..-2]:disabled+&
81
+ background-color rgb(var(_get_var_by("color-checkbox\:disabled"), var(--primary-3)))
82
+ /**
83
+ * 内框
84
+ */
85
+ ~/-label::after
86
+ content ''
87
+ text-align center
88
+ line-height 16px
89
+ box-sizing border-box
90
+ position absolute
91
+ left 3px
92
+ width 10px
93
+ height 10px
94
+
95
+ ^[1..1]:checked+&
96
+
97
+ ~/:where(:not([data-marker])) &
98
+ height 6px
99
+ margin-top -1px
100
+ transform rotate(-45deg)
101
+ clip-path path("M 0 1.5 \\
102
+ A 1.5 1.5 0 1 1 3 1 \\
103
+ L 3 3 \\
104
+ L 9 3 \\
105
+ A 1.5 1.5 0 1 1 8.5 6 \\
106
+ L 1.5 6 \\
107
+ A 1.5 1.5 0 0 1 0 4.5 \\
108
+ Z")
109
+ background-color rgb(var(--white))
110
+
111
+ ~/:where([data-marker="-"]) &
112
+ background rgb(var(--white))
113
+ height 2px
114
+ border-radius 2px
@@ -0,0 +1,65 @@
1
+ dropdown()
2
+ display grid
3
+ gap var(--gap-dialog-form, 8px)
4
+
5
+
6
+ dialog()
7
+ z-index 100
8
+ border 0
9
+ box-shadow var(--box-shadow-drop-bottom)
10
+ --box-shadow-color var(--gray-6)
11
+ background-color rgb(var(--background-color-dialog, var(--white)))
12
+
13
+ form[method=dialog]
14
+ dropdown()
15
+
16
+
17
+ .{prefix}-popover-wrapper
18
+ .{prefix}-dropdown-wrapper
19
+ width fit-content
20
+ position relative
21
+ .{prefix}-dropdown-wrapper
22
+ dialog:not(.{prefix}-dropdown)
23
+ visibility hidden
24
+ dialog:not(:popover-open)+.{prefix}-dropdown
25
+ display none
26
+ .{prefix}-dropdown
27
+ position absolute
28
+ left 50%
29
+ transform translateX(-50%)
30
+ top calc(100% + var(--gap-dialog-form, 8px))
31
+ padding var(--gap-dialog-form, 8px)
32
+ width max-content
33
+ margin auto
34
+ &:not(dialog)
35
+ dropdown()
36
+
37
+
38
+
39
+ .{prefix}-dropdown
40
+ .{prefix}-popover
41
+ dialog()
42
+ border-radius var(--border-radius-md)
43
+ inset unset
44
+ // 用户代理
45
+ // position fixed
46
+ &.sm
47
+ --gap-dialog-form 4px
48
+ .{prefix}-popover
49
+ padding var(--padding-dialog, var(--gap-dialog-form, 8px))
50
+
51
+
52
+ .{prefix}-dialog
53
+ dialog()
54
+ border-radius var(--border-radius-lg)
55
+ padding var(--padding-dialog, 16px 24px)
56
+ // 用户代理
57
+ // .show() -> position absolute
58
+ // .showModal() -> position fixed
59
+
60
+ &[open]::backdrop
61
+ // cursor not-allowed
62
+ pointer-events none
63
+ backdrop-filter brightness(.8) blur(1px)
64
+ /:root[data-theme=dark] &
65
+ backdrop-filter brightness(1.25) blur(1px)
@@ -0,0 +1,26 @@
1
+ .{prefix}-form-item
2
+ display flex
3
+ gap 8px
4
+ margin-bottom 16px
5
+ align-items center
6
+ &:where(label)
7
+ width fit-content
8
+ &:where([data-inline])
9
+ display inline-flex
10
+
11
+ .{prefix}-form-item-message
12
+ // visibility hidden
13
+ color rgb(var(--primary-6))
14
+ position absolute
15
+ left 0
16
+ bottom -1.5em
17
+ font-size var(--font-size-base)
18
+ line-height var(--line-height-base)
19
+
20
+ .{prefix}-input-wrapper:where([data-validate])
21
+ &:where(:has(:focus:invalid))
22
+ for i in range(1 10)
23
+ {_get_var_by('primary', i)} var(_get_var_by('danger', i))
24
+ &:where(:not(:has(:focus:invalid)))
25
+ .{prefix}-form-item-message
26
+ visibility hidden
@@ -0,0 +1,183 @@
1
+ input_stat(tag)
2
+
3
+ box-sizing border-box
4
+ border none
5
+ outline 2px solid transparent
6
+ border-radius var(--border-radius-md)
7
+
8
+ font-size var(--font-size-body)
9
+ line-height var(--line-height-body)
10
+
11
+ caret-color rgb(var(_get_var_by(color, tag)))
12
+
13
+ background-color rgb(var(--gray-2))
14
+ &:hover
15
+ &:focus-visible
16
+ box-shadow var(--box-shadow-drop-bottom)
17
+ &:focus-visible
18
+ outline-color rgb(var(_get_var_by(color, tag)))
19
+ transition outline-color .3s, box-shadow .3s
20
+
21
+ &[disabled]
22
+ cursor not-allowed
23
+ background-color rgb(var(--gray-1))
24
+ color rgb(var(--gray-6))
25
+ &:hover
26
+ box-shadow none
27
+
28
+ &::-webkit-input-placeholder
29
+ color rgb(var(--gray-5))
30
+ font-size var(--font-size-body)
31
+ line-height var(--line-height-body)
32
+
33
+
34
+ .{prefix}-textarea:where(textarea)
35
+
36
+ // --padding-textarea 5px 12px
37
+
38
+ --color-textarea var(_get_var_by("color-input\*", wrapper), var(_get_var_by("outline-color-\*\:focus")))
39
+
40
+ display inline-flex
41
+ flex-direction column
42
+ padding var(--padding-textarea, 5px 12px)
43
+
44
+ &.sm
45
+ --padding-textarea 1px 12px
46
+ &.lg
47
+ --padding-textarea 8px 12px
48
+ --font-size-body var(--font-size-h5)
49
+ --line-height-body var(--line-height-h5)
50
+
51
+ input_stat(textarea)
52
+
53
+ &:where([data-primary])
54
+ --color-textarea var(--primary-6)
55
+
56
+
57
+ .{prefix}-input
58
+
59
+ // --padding-vertical-input 4px
60
+ // --padding-horizontal-input 12px
61
+
62
+ --color-input var(_get_var_by("color-input\*", wrapper), var(_get_var_by("outline-color-\*\:focus")))
63
+
64
+ &:where(input:not([type]))
65
+ &:where(input[type=text])
66
+ &:where(input[type=search])
67
+ &:where(input[type=number])
68
+ &:where(input[type=password])
69
+ &:where(input[type=email])
70
+ &:where(input[type=tel])
71
+ &:where(input[type=url])
72
+ &:where(input[type=date])
73
+ &:where(input[type=time])
74
+ &:where(input[type=month])
75
+ &:where(input[type=week])
76
+ &:where(input[type=datetime-local])
77
+ &:where(input[type=datetime])
78
+ flex 1
79
+ padding var(--padding-vertical-input, 4px) var(--padding-horizontal-input, 12px)
80
+
81
+ &.sm
82
+ --padding-vertical-input 0
83
+
84
+ &.lg
85
+ --padding-vertical-input 7px
86
+ --font-size-body var(--font-size-h5)
87
+ --line-height-body var(--line-height-h5)
88
+
89
+ input_stat(input)
90
+
91
+ &:where([data-primary])
92
+ --color-input var(--primary-6)
93
+
94
+ /.{prefix}-input-wrapper
95
+ &:has(^[0..1])
96
+ background-color rgb(var(--gray-2))
97
+ &:has(.{prefix}-input-prefix)
98
+ & ^[0..1]
99
+ padding-left calc(var(--padding-horizontal-input, 12px) + var(--font-size-body))
100
+ &:has(.{prefix}-input-suffix)
101
+ & ^[0..1]
102
+ padding-right calc(var(--padding-horizontal-input, 12px) + var(--font-size-body))
103
+
104
+
105
+ .{prefix}-input-wrapper
106
+
107
+ display inline-flex
108
+ min-height var(--line-height-body)
109
+ align-items center
110
+ position relative
111
+ border 2px none rgb(var(_get_var_by("color-input\*", wrapper), var(--gray-2)))
112
+ border-radius var(--border-radius-md)
113
+
114
+ /**
115
+ * 输入框前缀后缀的按钮
116
+ */
117
+ buttons = button,
118
+ '[type=button]',
119
+ '[type=reset]',
120
+ '[type=submit]'
121
+
122
+ &:where([data-primary])
123
+ &:where([data-validate])
124
+
125
+ {_get_var_by("color-input\*", wrapper)} var(--primary-6)
126
+
127
+ for tag in buttons
128
+ &:has({tag}:not(.{prefix}-input-prefix):not(.{prefix}-input-suffix))
129
+ background-color rgb(var(_get_var_by("color-input\*", wrapper)))
130
+
131
+ // 校驗后樣式由用戶自訂是:invalid或響應式框架控制更靈活
132
+ // &:has(:invalid)
133
+ // {_get_var_by("color-input\*", wrapper)} var(--danger-6)
134
+
135
+ &>*
136
+ display inline-flex
137
+ align-items center
138
+
139
+ for tag in buttons
140
+ {tag}
141
+ cursor pointer
142
+ border-radius calc(var(--border-radius-md) - 2px)
143
+ outline 2px solid transparent
144
+ &:focus-visible
145
+ outline-color rgb(var(_get_var_by("color-input\*", wrapper), var(--black)))
146
+ ~/:where([data-primary]) ^[-1..-1]
147
+ color rgb(var(--white))
148
+
149
+ /**
150
+ * 这是祛除button的代理样式
151
+ */
152
+ padding 6px
153
+ border none
154
+ background none
155
+ &[disabled]
156
+ cursor not-allowed
157
+
158
+ .{prefix}-input-prefix
159
+ .{prefix}-input-suffix
160
+ // cursor pointer
161
+ position absolute
162
+ top 0
163
+ bottom 0
164
+ margin auto 0
165
+ z-index 1
166
+ color rgb(var(_get_var_by("color-input\*", wrapper), var(--black)))
167
+
168
+ // ~/[data-primary] ^[-1..-1]
169
+ // color rgb(var(_get_var_by("color-input\*", wrapper)))
170
+
171
+ /**
172
+ * 这是祛除button的代理样式 前面已经处理 除了padding不同
173
+ */
174
+ padding 0
175
+ // border none
176
+ // background none
177
+ // &[disabled]
178
+ // cursor not-allowed
179
+
180
+ .{prefix}-input-prefix
181
+ left calc(var(--padding-horizontal-input, 12px) / 2)
182
+ .{prefix}-input-suffix
183
+ right calc(var(--padding-horizontal-input, 12px) / 2)
@@ -0,0 +1,121 @@
1
+ .{prefix}-menu
2
+ // --color-menu var(--primary-6)
3
+ // --color-menu-item var(--black)
4
+ // --color-menu-item:hover var(--color-menu, var(--primary-6))
5
+ // --color-menu-item:active var(--white)
6
+ // --background-color-menu-item "from transparent r g b / alpha"
7
+ // --background-color-menu-item:hover "from transparent r g b / alpha"
8
+ // --background-color-menu-item:active var(--color-menu, var(--primary-6))
9
+ // --padding-vertical-menu-item 0.5em
10
+ // --padding-horizontal-menu-item 1em
11
+
12
+ margin 0 1em
13
+ padding 0
14
+ display flex
15
+ flex-direction column
16
+ gap 0.5em
17
+
18
+ &:where(ul)
19
+ &:where(menu)
20
+ list-style none
21
+ &:where(details)
22
+ margin 0
23
+ &:not([open])
24
+ gap 0
25
+ &>summary
26
+ &::-webkit-details-marker
27
+ display none
28
+ &::-moz-list-bullet
29
+ display none
30
+ &::marker
31
+ display none
32
+ // 在Safari中使用 `::before` 的元素不支持 `text-indent`
33
+ // 请使用 `&::after`
34
+ summary
35
+ &-submenu
36
+ display flex
37
+ flex-direction column
38
+ gap @gap
39
+ &-submenu
40
+ &:where([data-folded])
41
+ /**
42
+ * 收起时 无间距
43
+ */
44
+ gap 0
45
+ &-title
46
+ display flex
47
+ justify-content space-between
48
+ align-items center
49
+ cursor alias
50
+ line-height var(--line-height-body)
51
+ padding \
52
+ var(--padding-vertical-menu-item, .5em) \
53
+ var(--padding-horizontal-menu-item, 1em)
54
+ &-arrow
55
+ position relative
56
+ display inline-block
57
+ width 10px
58
+ transform translateY(-50%)
59
+ transition margin-top .3s
60
+ &:before
61
+ &:after
62
+ position absolute
63
+ width 6px
64
+ height 1.5px
65
+ background-color currentColor
66
+ border-radius 2px
67
+ transition transform .3s
68
+ content ""
69
+
70
+ ~/:where(details)[open] &
71
+ &
72
+ &:before
73
+ transform rotate(-45deg) translate(2.5px)
74
+ &:after
75
+ transform rotate(45deg) translate(-2.5px)
76
+
77
+ ~/:where(details):not([open]) &
78
+ ^[1][data-folded] &
79
+ margin-top -5px
80
+ &:before
81
+ transform rotate(45deg) translate(2.5px)
82
+ &:after
83
+ transform rotate(-45deg) translate(-2.5px)
84
+
85
+ &-item
86
+ position relative
87
+ height calc(var(--line-height-body) + 2 * var(--padding-vertical-menu-item, .5em))
88
+ line-height var(--line-height-body)
89
+ text-indent var(--padding-horizontal-menu-item, 1em)
90
+ display flex
91
+ align-items center
92
+ background-color rgb(var(--background-color-menu-item, from transparent r g b \/ alpha))
93
+ color rgb(var(--color-menu-item, var(--black)))
94
+ border-radius var(--border-radius-md)
95
+
96
+ ~/-item-link
97
+ position absolute
98
+ inset 0
99
+ display flex
100
+ align-items center
101
+ cursor pointer
102
+ text-decoration none
103
+ color currentColor
104
+ border-radius @border-radius // 这个是为了 `a:focus-visible` 能有圆角
105
+
106
+ &:where([data-active])
107
+ &:where([data-selected])
108
+ cursor auto
109
+ background-color rgb(var(_get_var_by("background-color-menu-item\:active"), var(--color-menu, var(--primary-6))))
110
+ color rgb(var(_get_var_by("color-menu-item\:active"), var(--white)))
111
+
112
+ &:not(^[0]-item[data-active]):not(^[0]-item[data-selected]):hover
113
+ background-color rgb(var(_get_var_by("background-color-menu-item\:hover"), from transparent r g b \/ alpha))
114
+ color rgb(var(_get_var_by("color-menu-item\:hover"), var(--color-menu, var(--primary-6))))
115
+
116
+ ~/-submenu:where([data-folded]) ^[0]
117
+ /**
118
+ * 收起时 0高度
119
+ */
120
+ flex-basis 0
121
+ overflow hidden
@@ -0,0 +1,51 @@
1
+ .{prefix}-message-queue
2
+ top 16px
3
+ left 0
4
+ right 0
5
+
6
+ z-index 10000
7
+ position fixed
8
+ height 0
9
+ overflow visible
10
+ display flex
11
+ flex-direction column
12
+ align-items center
13
+
14
+ color rgb(var(--gray-10))
15
+
16
+
17
+ .{prefix}-message
18
+
19
+ --background-color-message var(--white)
20
+ --color-message var(--black)
21
+
22
+ border-radius var(--border-radius-md)
23
+ padding 8px
24
+ color rgb(var(--color-message))
25
+ background-color rgb(var(--background-color-message))
26
+ box-shadow var(--box-shadow-drop-bottom)
27
+ margin 4px
28
+
29
+
30
+ .{prefix}-paragraph
31
+ max-width 60vw
32
+ margin 0
33
+
34
+ ^[1..1]>^[0]-prefix
35
+ /**
36
+ * <svg> 在 <use> 的情况下需要给定宽和高
37
+ * 只给其中一个 另一个会复制本体的 而不是等比例缩放
38
+ */
39
+ width 16px
40
+ height 16px
41
+ vertical-align middle
42
+ &:where([data-primary])
43
+ color rgb(var(--primary-6))
44
+ &+*
45
+ vertical-align middle
46
+
47
+
48
+ &:where([data-primary])
49
+ --color-message var(--white)
50
+ --background-color-message var(--primary-5)
51
+ --box-shadow-color var(--primary-4)
@@ -0,0 +1,71 @@
1
+ // details.{prefix}-panel
2
+ .{prefix}-panel
3
+ // --color-panel var(--primary-1)
4
+
5
+ font-size var(--font-size-body)
6
+ line-height var(--line-height-body)
7
+ /**
8
+ * 不使用主题
9
+ */
10
+ &:where(:not([data-primary]))
11
+ --color-panel var(--white)
12
+
13
+ &>summary
14
+ display flex
15
+ justify-content space-between
16
+ align-items center
17
+ background rgb(var(--color-panel, var(--primary-1)))
18
+ padding 8px
19
+ padding-left 18px
20
+ border-left 8px solid rgb(var(--color-panel, var(--primary-1)))
21
+ position relative
22
+ color inherit
23
+ list-style none
24
+ &::-webkit-details-marker
25
+ display none
26
+ &::-moz-list-bullet
27
+ display none
28
+ &::marker
29
+ display none
30
+ &::before
31
+ // content url("/docs/icons/direction/outline/caret-right.svg")
32
+ content ''
33
+ position absolute
34
+ width 18px
35
+ height 18px
36
+ top 0
37
+ bottom 0
38
+ left 0
39
+ margin auto 0
40
+
41
+ /**
42
+ * https://stackoverflow.com/questions/34859160/coloring-svg-content-url-with-css
43
+ */
44
+ ~/:where(:not([data-marker])) ^[1..-1]
45
+ mask var(--mask-panel-marker, url("data:image/svg+xml;utf8,<svg width='48' height='48' viewBox='0 0 48 48' fill='none' xmlns='http://www.w3.org/2000/svg' stroke='currentColor' stroke-width='4'><path d='M34.8287 23.0629C35.4292 23.5433 35.4292 24.4566 34.8287 24.937L17.9496 38.4402C17.1639 39.0688 16 38.5094 16 37.5032L16 10.4967C16 9.49048 17.1639 8.93107 17.9496 9.55964L34.8287 23.0629Z' fill='currentColor'/></svg>")) \
46
+ no-repeat \
47
+ center center \
48
+ \/ \
49
+ 12px 12px
50
+
51
+ ~/:where([data-marker='>']) ^[1..-1]
52
+ mask url("data:image/svg+xml;utf8,<svg width='48' height='48' viewBox='0 0 48 48' fill='none' xmlns='http://www.w3.org/2000/svg' stroke='currentColor' stroke-width='4'><path d='M16 39.5127L31.5563 23.9563C31.5563 23.9563 20.6944 13.0944 16 8.4'/></svg>") \
53
+ no-repeat \
54
+ center center \
55
+ \/ \
56
+ 12px 12px
57
+
58
+ background-color currentColor
59
+ transition transform .3s
60
+
61
+ ~/[open] ^[-1..-1]
62
+ margin-bottom 4px
63
+ &::before
64
+ transform rotate(90deg)
65
+
66
+ summary+*
67
+ display grid
68
+ background rgb(var(--color-panel, var(--primary-1)))
69
+ padding 8px 12px
70
+ color inherit
71
+
@@ -0,0 +1,30 @@
1
+ .{prefix}-pre
2
+ /**
3
+ * 行内的code样式 另见 ./tag&kbd.styl
4
+ */
5
+ overflow-x auto
6
+
7
+ // --background-color-pre var(--gray-1)
8
+ // --background-color-pre-dark var(--gray-1)
9
+ background-color rgb(var(--background-color-pre, var(--gray-1)) \/ .8)
10
+ /:root[data-theme=dark] &
11
+ background-color rgb(var(--background-color-pre-dark, var(--gray-1)) \/ .8)
12
+
13
+ padding calc(var(--font-offset-parent) + .5em) 1em
14
+ margin 1rem 0
15
+ border-radius var(--border-radius-md)
16
+
17
+ &>.{prefix}-code
18
+ white-space inherit
19
+ font-size var(--font-size-1)
20
+ line-height var(--font-size-3)
21
+ background-color unset
22
+ padding unset
23
+ border unset
24
+ color unset
25
+ *
26
+ // --color-code var(--gray-8)
27
+ // --color-code-dark var(--gray-8)
28
+ color rgb(var(--color-code, var(--gray-8)))
29
+ /:root[data-theme=dark] &
30
+ color rgb(var(--color-code-dark, var(--gray-8)))