@nopon-web/styles 0.0.3 → 0.0.5

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.
package/_config.scss CHANGED
@@ -1,5 +1,7 @@
1
- $namespace: 's' !default;
2
- $state-prefix: 'is' !default;
3
- $common-separator: '-' !default;
4
- $element-separator: '__' !default;
5
- $modifier-separator: '--' !default;
1
+ $namespace: "s" !default;
2
+ $common-separator: "-" !default;
3
+ $element-separator: "__" !default;
4
+ $modifier-separator: "--" !default;
5
+ $state-prefix: "is" !default;
6
+ $theme-prefix: "theme" !default;
7
+ $theme-name: "" !default;
package/_function.scss CHANGED
@@ -1,28 +1,55 @@
1
- @use 'sass:string';
2
- @use './_variables' as var;
3
- @use '_config' as config;
1
+ @use "sass:string";
2
+ @use "./_variables" as var;
3
+ @use "_config" as config;
4
4
 
5
- // bem('block', 'element', 'modifier') => 's_block__element--modifier'
6
- @function bem($block, $element: '', $modifier: '') {
5
+ // bem("block", "element", "modifier") => "s_block__element--modifier"
6
+ @function bem($block, $element: "", $modifier: "") {
7
7
  $name: config.$namespace + config.$common-separator + $block;
8
8
 
9
- @if $element != '' {
9
+ @if $element != "" {
10
10
  $name: $name + config.$element-separator + $element;
11
11
  }
12
12
 
13
- @if $modifier != '' {
13
+ @if $modifier != "" {
14
14
  $name: $name + config.$modifier-separator + $modifier;
15
15
  }
16
16
 
17
17
  @return $name;
18
18
  }
19
19
 
20
+ @function when($state) {
21
+ $state-selector: config.$state-prefix + config.$common-separator + $state;
22
+
23
+ @return ".#{$state-selector}";
24
+ }
25
+
26
+ @function join-class($parts...) {
27
+ $result: "";
28
+
29
+ @each $part in $parts {
30
+ @if $part != null and $part != "" {
31
+ @if $result == "" {
32
+ $result: $part;
33
+ } @else {
34
+ $result: $result + config.$common-separator + $part;
35
+ }
36
+ }
37
+ }
38
+
39
+ @return $result;
40
+ }
41
+
42
+ // 最小尺寸单位转换
43
+ @function u($value) {
44
+ @return calc(#{$value} * var(--size-unit));
45
+ }
46
+
20
47
  @function get-image($image) {
21
48
  // 已经是合法CSS值的情况
22
- @if string.index($image, 'url(') or
23
- string.index($image, 'gradient(') or
24
- string.index($image, 'var(') or
25
- string.index($image, 'data:')
49
+ @if string.index($image, "url(") or
50
+ string.index($image, "gradient(") or
51
+ string.index($image, "var(") or
52
+ string.index($image, "data:")
26
53
  {
27
54
  @return $image;
28
55
  }
package/_mixin.scss CHANGED
@@ -1,43 +1,44 @@
1
- @use 'sass:map';
1
+ @use "sass:map";
2
2
 
3
- @use '_config' as *;
4
- @use '_variables' as var;
5
- @use '_function' as func;
3
+ @use "_config" as *;
4
+ @use "_variables" as var;
5
+ @use "_function" as func;
6
6
 
7
- @forward '_config';
8
- @forward '_variables';
9
- @forward '_function';
7
+ @forward "_config";
8
+ @forward "_variables";
9
+ @forward "_function";
10
10
 
11
11
  // BEM
12
+ $B: null;
12
13
  $__bem-context: null;
13
14
 
14
15
  @mixin b($block) {
15
- $B: $namespace + $common-separator + $block;
16
+ $B: $namespace + $common-separator + $block !global;
16
17
 
17
18
  .#{$B} {
18
- $__bem-context: 'block' !global;
19
+ $__bem-context: "block" !global;
19
20
  @content;
20
21
  $__bem-context: null !global;
21
22
  }
22
23
  }
23
24
 
24
25
  @mixin e($element) {
25
- @if $__bem-context != 'block' {
26
- @error 'e() can only be used inside b()';
26
+ @if $__bem-context != "block" {
27
+ @error "e() can only be used inside b()";
27
28
  }
28
29
 
29
30
  @each $E in $element {
30
- &#{$element-separator + $E} {
31
- $__bem-context: 'element' !global;
31
+ .#{$B + $element-separator + $E} {
32
+ $__bem-context: "element" !global;
32
33
  @content;
33
- $__bem-context: 'block' !global;
34
+ $__bem-context: "block" !global;
34
35
  }
35
36
  }
36
37
  }
37
38
 
38
39
  @mixin m($modifier) {
39
- @if $__bem-context != 'block' and $__bem-context != 'element' {
40
- @error 'm() can only be used inside b() or e()';
40
+ @if $__bem-context != "block" and $__bem-context != "element" {
41
+ @error "m() can only be used inside b() or e()";
41
42
  }
42
43
 
43
44
  @each $M in $modifier {
@@ -47,11 +48,41 @@ $__bem-context: null;
47
48
  }
48
49
  }
49
50
 
51
+ @mixin t($names: null) {
52
+ @if $__bem-context != "block" {
53
+ @error "t() can only be used inside b()";
54
+ }
55
+
56
+ // 解析 themes 列表
57
+ $themes: ();
58
+ @if $names == null {
59
+ @if $theme-name == null or $theme-name == "" {
60
+ @error "$theme-name must be set globally or passed to @include t().";
61
+ }
62
+ $themes: ($theme-name);
63
+ } @else {
64
+ $themes: $names;
65
+ }
66
+
67
+ // 逐个生成 theme 选择器
68
+ @each $theme in $themes {
69
+ @if $theme == null or $theme == "" {
70
+ @error "Invalid theme name in @include t().";
71
+ }
72
+
73
+ $T: $theme-prefix + $common-separator + $theme;
74
+
75
+ &.#{$B + $modifier-separator + $T} {
76
+ @content;
77
+ }
78
+ }
79
+ }
80
+
50
81
  @mixin when($state) {
51
82
  $state-selector: $state-prefix + $common-separator + $state;
52
83
 
53
84
  @at-root {
54
- #{if(&, '&.#{$state-selector}', '.#{$state-selector}')} {
85
+ #{if(&, "&.#{$state-selector}", ".#{$state-selector}")} {
55
86
  @content;
56
87
  }
57
88
  }
@@ -68,7 +99,7 @@ $__bem-context: null;
68
99
  left: 50%;
69
100
  }
70
101
 
71
- transform: translate(#{if($x, '-50%', '0')}, #{if($y, '-50%', '0')});
102
+ transform: translate(#{if($x, "-50%", "0")}, #{if($y, "-50%", "0")});
72
103
  }
73
104
 
74
105
  @mixin set-z-index($number) {
@@ -85,19 +116,6 @@ $__bem-context: null;
85
116
  background-image: func.get-image($image);
86
117
  }
87
118
 
88
- @mixin bg-border($width, $height, $image, $border: ('width': 0, 'image-slice': 0), $fill: true) {
89
- $border-width: map.get($border, 'width');
90
- $border-image-slice: map.get($border, 'image-slice');
91
-
92
- width: $width;
93
- height: $height;
94
- border-image-source: func.get-image($image);
95
- border-style: solid;
96
- box-sizing: border-box;
97
- border-width: $border-width;
98
- border-image-slice: #{$border-image-slice}#{if($fill, ' fill', '')};
99
- }
100
-
101
119
  @mixin bg-text($image) {
102
120
  background-clip: text;
103
121
  -webkit-background-clip: text;
@@ -106,16 +124,39 @@ $__bem-context: null;
106
124
  background-image: func.get-image($image);
107
125
  }
108
126
 
109
- @mixin text-stroke($size: 1px, $color: #000, $blur: 0) {
110
- text-shadow: #{$size} #{$size} #{$blur} #{$color}, -#{$size} #{$size} #{$blur} #{$color},
111
- #{$size} -#{$size} #{$blur} #{$color}, -#{$size} -#{$size} #{$blur} #{$color};
127
+ @mixin frame-border($frame) {
128
+ $image: map.get($frame, image);
129
+ $inset: map.get($frame, inset);
130
+ $slice: map.get($frame, slice);
131
+ $fill: map.get($frame, fill);
132
+ $repeat: map.get($frame, repeat, stretch);
133
+
134
+ @if not $image or not $inset or not $slice {
135
+ @error "frame-border: image / inset / slice are required";
136
+ }
137
+
138
+ box-sizing: border-box;
139
+ border-style: solid;
140
+ border-width: $inset;
141
+ border-image-source: func.get-image($image);
142
+ border-image-slice: #{$slice}#{if($fill, " fill", "")};
143
+ border-image-repeat: $repeat;
144
+ }
145
+
146
+ @mixin text-stroke($size, $color: #000, $blur: 0) {
147
+ text-shadow:
148
+ #{$size} #{$size} #{$blur} #{$color},
149
+ -#{$size} #{$size} #{$blur} #{$color},
150
+ #{$size} -#{$size} #{$blur} #{$color},
151
+ -#{$size} -#{$size} #{$blur} #{$color};
112
152
  }
113
153
 
114
- @mixin text-shadow($size: 14px, $color: #000, $offset-x: 2px, $offset-y: 2px) {
154
+ @mixin text-shadow($size, $color: #000, $offset-x: func.u(2), $offset-y: #{u(2)}) {
115
155
  position: relative;
116
156
  z-index: 0;
117
157
  font-size: 0;
118
158
  line-height: 1;
159
+ font-size: #{func.u(10)};
119
160
 
120
161
  > * {
121
162
  font-size: $size;
@@ -134,169 +175,3 @@ $__bem-context: null;
134
175
  transform: translate(calc(-50% + #{$offset-x}), calc(-50% + #{$offset-y}));
135
176
  }
136
177
  }
137
-
138
- /// 通用列表布局封装
139
- /// 支持 grid / flex 两种布局
140
- /// @param $options - 可选配置
141
- /// ------------------------------------------------------------------------
142
- /// HTML 模板示例:
143
- // <ul class="b-e--list">
144
- // <li class="b-e--item">
145
- // <div class="b-e--media">
146
- // <div class="b-e--picture">
147
- // <div class="b-e--picture_bg picture">
148
- // <img src="">
149
- // </div>
150
- // <div class="b-e--picture_wrapper picture">
151
- // <img class="b-e--picture_content"
152
- // src="">
153
- // </div>
154
- // <div class="b-e--picture_decoration picture">
155
- // <img src="">
156
- // </div>
157
- // <div class="b-e--picture_cover picture">
158
- // <img src="">
159
- // </div>
160
- // </div>
161
- // </div>
162
- // <div class="b-e--content">
163
- // <div class="b-e--content_text">
164
- // <span class="text"></span>
165
- // </div>
166
- // </div>
167
- // </li>
168
- // </ul>
169
- /// ------------------------------------------------------------------------
170
- @mixin extend-list($options: ()) {
171
- // --- 默认参数 ---
172
- $defaults: (
173
- 'namespace-block': 'b',
174
- 'namespace-element': 'e',
175
- // 布局模式
176
- 'display': grid,
177
- // 是否换行
178
- 'wrap': false,
179
- // 列数
180
- 'col': 4,
181
- // 间距
182
- 'gap': 10px,
183
- // 图片宽高比
184
- 'picture-ratio': 100%,
185
- // 图片宽度
186
- 'picture-width': 100%,
187
- // 图片高度
188
- 'picture-height': 100%,
189
- );
190
-
191
- // 合并配置
192
- $config: map.merge($defaults, $options);
193
-
194
- // 变量定义
195
- $block: map.get($config, 'namespace-block');
196
- $element: map.get($config, 'namespace-element');
197
- $display: map.get($config, 'display');
198
- $wrap: map.get($config, 'wrap');
199
- $col: map.get($config, 'col');
200
- $gap: map.get($config, 'gap');
201
- $picture-ratio: map.get($config, 'picture-ratio');
202
- $picture-width: map.get($config, 'picture-width');
203
- $picture-height: map.get($config, 'picture-height');
204
-
205
- // --- 列表容器 ---
206
- .#{$block}-#{$element}--list {
207
- --col: #{$col};
208
- --gap: #{$gap};
209
- --picture-ratio: #{$picture-ratio};
210
- --picture-width: #{$picture-width};
211
- --picture-height: #{$picture-height};
212
- display: $display;
213
-
214
- // flex 布局
215
- @if $display ==flex {
216
- margin: 0 calc(var(--gap) / -2);
217
-
218
- // 换行
219
- @if $wrap {
220
- flex-wrap: wrap;
221
- }
222
- }
223
-
224
- // grid 布局(默认)
225
- @if $display ==grid {
226
- gap: var(--gap);
227
-
228
- // 换行
229
- @if $wrap {
230
- grid-template-columns: repeat(var(--col), minmax(0, 1fr));
231
- } @else {
232
- grid-auto-flow: column;
233
- grid-auto-columns: calc((100% - (var(--col) - 1) * var(--gap)) / var(--col));
234
- }
235
- }
236
-
237
- @if $wrap ==false {
238
- overflow-x: scroll;
239
- }
240
-
241
- .#{$block}-#{$element}--item:only-child {
242
- grid-column: 1 / calc(var(--col) + 1);
243
- width: calc(100% / var(--col));
244
- margin: 0 auto;
245
- }
246
- }
247
-
248
- // --- 列表项 ---
249
- .#{$block}-#{$element}--item {
250
- position: relative;
251
- font-size: 0;
252
-
253
- @if $display ==flex {
254
- flex-shrink: 0;
255
- width: calc(100% / var(--col));
256
- padding: calc(var(--gap) / 2);
257
- }
258
- }
259
-
260
- // --- 图片 ---
261
- .#{$block}-#{$element}--picture {
262
- position: relative;
263
-
264
- &_bg {
265
- width: 100%;
266
- height: 100%;
267
- @include absolute-center(true, true);
268
- z-index: 0;
269
- }
270
-
271
- &_wrapper {
272
- position: relative;
273
- height: 0;
274
- padding-bottom: var(--picture-ratio);
275
- }
276
-
277
- &_content {
278
- max-width: var(--picture-width);
279
- max-height: var(--picture-height);
280
- @include absolute-center(true, true);
281
- }
282
-
283
- &_decoration {
284
- position: absolute;
285
- top: 0;
286
- right: 0;
287
- z-index: 1;
288
- }
289
-
290
- &_cover {
291
- @include absolute-center(true, true);
292
- z-index: 2;
293
- width: 100%;
294
- height: 100%;
295
- }
296
- }
297
-
298
- // --- 内容区 ---
299
- .#{$block}-#{$element}--content {
300
- text-align: center;
301
- }
302
- }
package/_variables.scss CHANGED
@@ -1,2 +1,9 @@
1
+ // 🔤 尺寸基准值,控制设计稿与真实页面的缩放比例
2
+ $size-root: 16 !default;
3
+ // 🔤 最小单位:等效于 1px:
4
+ // - 当使用 rem 方案:1px = calc(1 / var(--size-root) * 1rem)
5
+ // - 当使用 vw 方案:1px = calc(1 / var(--size-root) * 100vw)
6
+ $size-unit: calc(1 / var(--size-root) * 1rem) !default;
7
+
1
8
  // 层级
2
9
  $z-index-base: 1000;
@@ -1,3 +1,5 @@
1
+ @use "../mixin" as *;
2
+
1
3
  @keyframes like-floating {
2
4
  from {
3
5
  transform: translateY(0) scale(0.5);
@@ -8,8 +10,8 @@
8
10
  }
9
11
  }
10
12
 
11
- .animation {
12
- &-like_floating {
13
+ @include b(animation) {
14
+ &.#{join-class("like", "floating")} {
13
15
  animation-name: like-floating;
14
16
  animation-duration: 1s;
15
17
  animation-timing-function: ease-out;
@@ -0,0 +1,32 @@
1
+ @use "../mixin" as *;
2
+
3
+ @include b(popup) {
4
+ &.#{bem(dialog)} {
5
+ --popup-padding: 0;
6
+ --popup-width: var(--dialog-width, 50%);
7
+ }
8
+ }
9
+
10
+ @include b(dialog) {
11
+ --dialog-width: 30%;
12
+ --dialog-padding-header: #{u(10)};
13
+ --dialog-padding-body: #{u(15)};
14
+ --dialog-padding-footer: #{u(10)};
15
+
16
+ @include e(header) {
17
+ padding: var(--dialog-padding-header);
18
+
19
+ @include m(title) {
20
+ font-size: var(--text-lg);
21
+ }
22
+ }
23
+
24
+ @include e(body) {
25
+ padding: var(--dialog-padding-body);
26
+ overflow: hidden;
27
+ }
28
+
29
+ @include e(footer) {
30
+ padding: var(--dialog-padding-footer);
31
+ }
32
+ }
@@ -0,0 +1,59 @@
1
+ @use "../mixin" as *;
2
+
3
+ /*!
4
+ Example HTML:
5
+
6
+ <div class="frame-box">
7
+ <div class="frame-box__bg"></div>
8
+ <div class="frame-box__wrapper">
9
+ <div class="frame-box__body">
10
+ Content
11
+ </div>
12
+ </div>
13
+ <div class="frame-box__frame"></div>
14
+ <div class="frame-box__header">
15
+ <span class="frame-box__header--title">Title</span>
16
+ </div>
17
+ </div>
18
+ */
19
+
20
+ @include b(join-class("frame", "box")) {
21
+ position: relative;
22
+ box-sizing: border-box;
23
+ font-size: 0;
24
+
25
+ @include e(bg) {
26
+ width: 100%;
27
+ height: 100%;
28
+ @include absolute-center(true, true);
29
+ z-index: 0;
30
+ pointer-events: none;
31
+ }
32
+
33
+ @include e(wrapper) {
34
+ position: relative;
35
+ z-index: 1;
36
+ margin: 0 auto;
37
+ }
38
+
39
+ @include e(frame) {
40
+ width: 100%;
41
+ height: 100%;
42
+ @include absolute-center(true, true);
43
+ z-index: 2;
44
+ pointer-events: none;
45
+ }
46
+
47
+ @include e(header) {
48
+ @include absolute-center(true, false);
49
+ top: 0;
50
+ z-index: 3;
51
+ display: flex;
52
+ justify-content: center;
53
+ align-items: center;
54
+
55
+ @include m(title) {
56
+ white-space: nowrap;
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,64 @@
1
+ // 布局网格
2
+ @use "../mixin" as *;
3
+
4
+ @include b("grid") {
5
+ --col: 4;
6
+ --gap: #{u(0)};
7
+ --display: grid;
8
+ display: var(--display);
9
+
10
+ /* ========= grid 布局 ========= */
11
+ @include when("grid") {
12
+ --display: grid;
13
+ gap: var(--gap);
14
+
15
+ // 换行
16
+ @include when("wrap") {
17
+ grid-template-columns: repeat(var(--col), minmax(0, 1fr));
18
+ }
19
+
20
+ &:not(#{when("wrap")}) {
21
+ grid-auto-flow: column;
22
+ grid-auto-columns: calc((100% - (var(--col) - 1) * var(--gap)) / var(--col));
23
+ overflow-x: scroll;
24
+ }
25
+ }
26
+
27
+ /* ========= flex布局 ========= */
28
+ @include when("flex") {
29
+ --display: flex;
30
+ gap: var(--gap);
31
+
32
+ // 自动宽度
33
+ &:not(#{when("auto")}) {
34
+ > {
35
+ @include b("cell") {
36
+ flex-shrink: 0;
37
+ width: calc((100% - (var(--col) - 1) * var(--gap)) / var(--col));
38
+ }
39
+ }
40
+ }
41
+
42
+ // 换行
43
+ @include when("wrap") {
44
+ flex-wrap: wrap;
45
+ }
46
+
47
+ &:not(#{when("wrap")}) {
48
+ overflow-x: scroll;
49
+ }
50
+ }
51
+
52
+ /* ========= 单个 cell 居中 ========= */
53
+ @include when(join-class("only", "center")) {
54
+ > {
55
+ @include b("cell") {
56
+ &:only-child {
57
+ grid-column: 1 / calc(var(--col) + 1);
58
+ width: calc(100% / var(--col));
59
+ margin: 0 auto;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
@@ -1,9 +1,7 @@
1
- // 图标
2
- .icon {
3
- display: inline-block;
4
- vertical-align: middle;
1
+ @use "../mixin" as *;
5
2
 
6
- &.picture {
7
- font-size: 0;
8
- }
9
- }
3
+ @include b("icon") {
4
+ display: inline-block;
5
+ vertical-align: middle;
6
+ color: inherit;
7
+ }
@@ -1,18 +1,48 @@
1
- @use '../mixin' as *;
1
+ @use "../mixin" as *;
2
2
 
3
- @include b('image') {
3
+ @include b("image") {
4
4
  --aspect-ratio: 1;
5
+ position: relative;
5
6
 
6
- > img {
7
+ // 背景
8
+ @include e("bg") {
9
+ @include absolute-center(true, true);
10
+ z-index: 0;
7
11
  width: 100%;
8
12
  height: 100%;
13
+ display: flex;
14
+ align-items: center;
15
+ justify-content: center;
9
16
  }
10
17
 
11
- @include when('ratio') {
18
+ // 图片内容
19
+ @include e("content") {
12
20
  position: relative;
13
- aspect-ratio: var(--aspect-ratio);
21
+ z-index: 1;
22
+ width: 100%;
23
+ height: 100%;
24
+ object-fit: contain;
25
+ }
26
+
27
+ // 遮罩
28
+ @include e("overlay") {
29
+ @include absolute-center(true, true);
30
+ z-index: 3;
31
+ width: 100%;
32
+ height: 100%;
33
+ }
34
+
35
+ // 装饰
36
+ @include e("decoration") {
37
+ position: absolute;
38
+ z-index: 2;
39
+ top: 0;
40
+ right: 0;
41
+ }
14
42
 
15
- > img {
43
+ @include when("ratio") {
44
+ @include e("content") {
45
+ aspect-ratio: var(--aspect-ratio);
16
46
  object-fit: cover;
17
47
  }
18
48
  }
@@ -0,0 +1,11 @@
1
+ @use "./animation.scss";
2
+ @use "./dialog.scss";
3
+ @use "./frame-box.scss";
4
+ @use "./grid.scss";
5
+ @use "./icon.scss";
6
+ @use "./image.scss";
7
+ @use "./popup.scss";
8
+ @use "./progress.scss";
9
+ @use "./scroll-bar.scss";
10
+ @use "./table.scss";
11
+ @use "./text.scss";
@@ -1,48 +1,63 @@
1
- .popup {
2
- overflow: hidden;
3
-
4
- &.no-scroll {
5
- .popup-wrapper {
6
- display: flex;
7
- flex-direction: column;
8
- }
1
+ @use "../mixin" as *;
2
+
3
+ @include b(popup) {
4
+ --popup-width: 30%;
5
+ --popup-height: auto;
6
+ --popup-padding: calc(20 * var(--size-unit));
7
+ --popup-bg: linear-gradient(0deg, var(--color-base-50), var(--color-base-50));
8
+ --popup-z-index: 1;
9
+ --popup-close-inset: #{u(4)} #{u(4)} auto auto;
10
+
11
+ position: fixed;
12
+ top: 0;
13
+ left: 0;
14
+ width: 100%;
15
+ height: 100%;
16
+ pointer-events: none;
17
+ @include set-z-index(var(--popup-z-index));
18
+
19
+ @include e(wrapper) {
20
+ @include bg(var(--popup-width), var(--popup-height), var(--popup-bg));
21
+ position: relative;
22
+ padding: var(--popup-padding);
23
+ pointer-events: auto;
24
+ }
9
25
 
10
- .popup-body {
11
- flex: 1;
12
- }
26
+ @include e(close) {
27
+ position: absolute;
28
+ inset: var(--popup-close-inset);
29
+ z-index: 1;
13
30
  }
14
- }
15
31
 
16
- .popup-wrapper {
17
- height: 100%;
18
- }
32
+ // 默认居中
33
+ &:not(#{when(ttb)}, #{when(rtl)}, #{when(btt)}, #{when(ltr)}) {
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: center;
37
+ }
19
38
 
20
- .popup-header--title {
21
- width: 100%;
22
- display: flex;
23
- align-items: center;
24
- justify-content: center;
25
- }
39
+ @include when(ttb) {
40
+ --popup-width: 100%;
41
+ }
26
42
 
27
- .popup-body {
28
- position: relative;
29
- overflow-y: scroll;
30
- }
43
+ @include when(rtl) {
44
+ display: flex;
45
+ justify-content: flex-end;
31
46
 
32
- .popup-footer {
33
- text-align: center;
34
- }
47
+ @include e(wrapper) {
48
+ height: 100%;
49
+ }
50
+ }
35
51
 
36
- .popup-footer--button_list {
37
- display: flex;
38
- justify-content: space-around;
39
- margin: 0 auto;
40
- }
52
+ @include when(btt) {
53
+ --popup-width: 100%;
54
+ display: flex;
55
+ align-items: flex-end;
56
+ }
41
57
 
42
- // 自定义
43
- .footer-custom {
44
- position: sticky;
45
- left: 0;
46
- bottom: 0;
47
- width: 100%;
58
+ @include when(ltr) {
59
+ @include e(wrapper) {
60
+ height: 100%;
61
+ }
62
+ }
48
63
  }
@@ -0,0 +1,115 @@
1
+ @use "../mixin" as *;
2
+
3
+ /*!
4
+ Example HTML:
5
+
6
+ <div class="s-progress">
7
+ <div class="s-progress__wrapper">
8
+ <div class="s-progress__segments">
9
+ <div class="s-progress__segment is-active" style="--progress-segment-width: calc(100% - 0%)">
10
+ <div class="s-progress__segment--wrapper">
11
+ <div class="s-progress__segment--point"></div>
12
+ <div class="s-progress__segment--content"><span class="s-text">100%</span></div>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ <div class="s-progress__bar">
17
+ <div class="s-progress__bar--outer"><div class="s-progress__bar--inner"></div></div>
18
+ </div>
19
+ </div>
20
+ </div>
21
+
22
+ */
23
+
24
+ @include b(progress) {
25
+ --progress-width: 100%;
26
+ --progress-value: 0%; // 进度值
27
+ --progress-segment-point-width: #{u(30)}; // 节点大小
28
+ --progress-segment-point-transform: translateX(50%); // 节点中心偏移
29
+ --progress-segment-point-bg: linear-gradient(0deg, var(--color-base-500), var(--color-base-500)); // 节点背景
30
+ --progress-segment-point-bg-active: linear-gradient(0deg, var(--theme-color-500), var(--theme-color-500)); // 节点背景
31
+ --progress-segment-content-transform: translateX(50%); // 内容中心偏移
32
+
33
+ --progress-bar-height: #{u(20)}; // 进度条高度
34
+ --progress-bar-radius: #{u(10)}; // 进度条(内外)圆角
35
+ --progress-bar-outer-bg: linear-gradient(0deg, var(--color-base-250), var(--color-base-250)); // 外背景
36
+ --progress-bar-outer-padding: 0; // 外边距
37
+ --progress-bar-inner-bg: linear-gradient(0deg, var(--theme-color-500), var(--theme-color-500)); // 内背景
38
+ overflow-x: scroll;
39
+
40
+ @include e(wrapper) {
41
+ width: var(--progress-width);
42
+ position: relative;
43
+ min-height: var(--progress-segment-point-width);
44
+ }
45
+
46
+ // 片段
47
+ @include e(segments) {
48
+ display: flex;
49
+ justify-content: flex-start;
50
+ }
51
+
52
+ @include e(segment) {
53
+ position: relative;
54
+ z-index: 1;
55
+ width: var(--progress-segment-width, 0%);
56
+
57
+ @include m(wrapper) {
58
+ display: flex;
59
+ flex-direction: column;
60
+ align-items: flex-end;
61
+ }
62
+
63
+ @include m(point) {
64
+ border-radius: 100%;
65
+ @include bg(
66
+ var(--progress-segment-point-width),
67
+ var(--progress-segment-point-width),
68
+ var(--progress-segment-point-bg)
69
+ );
70
+ transform: var(--progress-segment-point-transform);
71
+ }
72
+
73
+ @include m(content) {
74
+ transform: var(--progress-segment-content-transform);
75
+ }
76
+
77
+ @include when("active") {
78
+ .#{bem("progress", "segment", "point")} {
79
+ @include bg(
80
+ var(--progress-segment-point-width),
81
+ var(--progress-segment-point-width),
82
+ var(--progress-segment-point-bg-active)
83
+ );
84
+ }
85
+ }
86
+ }
87
+
88
+ // 进度条
89
+ @include e(bar) {
90
+ width: 100%;
91
+ position: absolute;
92
+ top: calc(var(--progress-segment-point-width) / 2);
93
+ left: 0;
94
+ z-index: 0;
95
+ transform: translateY(-50%);
96
+
97
+ @include m(outer) {
98
+ width: 100%;
99
+ padding: var(--progress-bar-outer-padding);
100
+ border-radius: var(--progress-bar-radius);
101
+ @include bg(100%, var(--progress-bar-height), var(--progress-bar-outer-bg));
102
+ }
103
+
104
+ @include m(inner) {
105
+ height: 100%;
106
+ border-radius: var(--progress-bar-radius);
107
+ @include bg(var(--progress-value, 0%), 100%, var(--progress-bar-inner-bg));
108
+ }
109
+ }
110
+
111
+ @include when(rtl) {
112
+ --progress-segment-point-transform: translateX(-50%);
113
+ --progress-segment-content-transform: translateX(-50%);
114
+ }
115
+ }
@@ -1,30 +1,23 @@
1
1
  .table {
2
- --grid-padding: 0.2rem 0;
2
+ --grid-padding: #{u(2)} 0;
3
3
  --grid-width: auto;
4
4
  --bg-thead: rgba(0, 0, 0, 0.2);
5
- --color-border: rgba(255, 255, 255, 0.2);
5
+ --color-border: #ffffff33;
6
6
  width: 100%;
7
7
  font-size: 0;
8
8
  border-spacing: 0;
9
9
  border-collapse: separate;
10
- border: 0.02rem solid var(--color-border);
10
+ border: #{u(2)} solid var(--color-border);
11
11
  overflow: hidden;
12
12
 
13
13
  thead {
14
14
  background-color: var(--bg-thead);
15
15
 
16
16
  .text {
17
- font-size: 0.3rem;
18
17
  font-weight: bold;
19
18
  }
20
19
  }
21
20
 
22
- tbody {
23
- .text {
24
- font-size: 0.28rem;
25
- }
26
- }
27
-
28
21
  tr {
29
22
  width: 100%;
30
23
  display: flex;
@@ -38,7 +31,7 @@
38
31
  flex: 1 0 var(--grid-width);
39
32
  padding: var(--grid-padding);
40
33
  border: solid var(--color-border);
41
- border-width: 0 0.02rem 0.02rem 0;
34
+ border-width: 0 #{u(2)} #{u(2)} 0;
42
35
  }
43
36
 
44
37
  .text {
@@ -1,15 +1,43 @@
1
- .text {
1
+ @use "../mixin" as *;
2
+
3
+ @include b("text") {
2
4
  display: inline-block;
3
5
  line-height: 1;
4
6
  vertical-align: middle;
5
7
 
6
- &.paragraph {
7
- line-height: 1.5;
8
- }
9
-
10
- &.ellipsis {
8
+ @include when("ellipsis") {
9
+ width: 100%;
11
10
  white-space: nowrap;
12
11
  text-overflow: ellipsis;
13
12
  overflow: hidden;
14
13
  }
14
+
15
+ @include when("h1") {
16
+ font-size: var(--text-3xl);
17
+ }
18
+
19
+ @include when("h2") {
20
+ font-size: var(--text-2xl);
21
+ }
22
+
23
+ @include when("h3") {
24
+ font-size: var(--text-xl);
25
+ }
26
+
27
+ @include when("h4") {
28
+ font-size: var(--text-lg);
29
+ }
30
+
31
+ @include when("h5") {
32
+ font-size: var(--text-base);
33
+ }
34
+
35
+ @include when("h6") {
36
+ font-size: var(--text-sm);
37
+ }
38
+
39
+ @include when("p") {
40
+ display: block;
41
+ line-height: 1.5;
42
+ }
15
43
  }
package/index.scss CHANGED
@@ -1,2 +1,2 @@
1
- @use './normalize.css';
2
- @use './base.scss';
1
+ @use "./normalize.css";
2
+ @use "./base.scss";
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
- {
2
- "name": "@nopon-web/styles",
3
- "version": "0.0.3",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": "",
10
- "license": "ISC",
11
- "description": "",
12
- "publishConfig": {
13
- "access": "public"
14
- }
15
- }
1
+ {
2
+ "name": "@nopon-web/styles",
3
+ "version": "0.0.5",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "ISC",
11
+ "description": "",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ }
15
+ }
package/theme.scss CHANGED
@@ -1,5 +1,5 @@
1
- @use 'sass:map';
2
- @use './_variables' as var;
1
+ @use "sass:map";
2
+ @use "./_variables" as var;
3
3
 
4
4
  // -----------------------------
5
5
  // 🎨 颜色设计变量命名规范
@@ -40,8 +40,6 @@ $color-danger-500: #ff7b7b;
40
40
  // 参考标准: https://developer.mozilla.org/en-US/docs/Web/CSS/font-size#values
41
41
  // xx-small、x-small、small、medium、large、x-large、xx-large、xxx-large(基于用户默认字体大小(medium)的绝对大小关键字)
42
42
 
43
- $size-root: 16; // 🔤 尺寸基准值,控制设计稿与真实页面的缩放比例
44
-
45
43
  $text-small-map: (
46
44
  // 14px
47
45
  0: 0.875,
@@ -107,7 +105,7 @@ $text-large-map: (
107
105
  --color-danger-500: #{$color-danger-500};
108
106
 
109
107
  // 🔤 尺寸基准值,控制设计稿与真实页面的缩放比例
110
- --size-root: #{$size-root};
108
+ --size-root: #{var.$size-root};
111
109
 
112
110
  // 🔤 最小单位:等效于 1px:
113
111
  // - 当使用 rem 方案:1px = calc(1 / var(--size-root) * 1rem)
@@ -1,41 +0,0 @@
1
- /*!
2
- Example HTML:
3
-
4
- <div class="box-card">
5
- <div class="box-wrapper">
6
- <div class="box-header">
7
- <span class="box-title">Title</span>
8
- </div>
9
- <div class="box-body">Content</div>
10
- </div>
11
- </div>
12
- */
13
-
14
- @use '../mixin' as mixin;
15
-
16
- .box-card {
17
- position: relative;
18
- font-size: 0;
19
- }
20
-
21
- .box-wrapper {
22
- margin: 0 auto;
23
- }
24
-
25
- .box-header {
26
- @include mixin.absolute-center(true, false);
27
- top: 0;
28
- display: flex;
29
- align-items: center;
30
- }
31
-
32
- .box-title {
33
- white-space: nowrap;
34
- }
35
-
36
- .box-body--bg {
37
- width: 100%;
38
- @include mixin.absolute-center(true, false);
39
- top: 0;
40
- z-index: -1;
41
- }
@@ -1,40 +0,0 @@
1
- @use '../mixin' as mixin;
2
-
3
- .picture {
4
- position: relative;
5
- --frame-width: 0.02rem;
6
-
7
- > img {
8
- width: 100%;
9
- height: 100%;
10
- object-fit: contain;
11
- }
12
-
13
- // 图片内容
14
- .picture-content {
15
- &--center {
16
- @include mixin.absolute-center(true, true);
17
- }
18
-
19
- &--bottom {
20
- @include mixin.absolute-center(true, false);
21
- bottom: 0;
22
- }
23
- }
24
-
25
- // 图片边框
26
- .picture-frame {
27
- width: 100%;
28
- height: 100%;
29
- @include mixin.absolute-center(true, true);
30
- z-index: 1;
31
-
32
- + img {
33
- position: relative;
34
- width: calc(100% - var(--frame-width) * 2);
35
- height: calc(100% - var(--frame-width) * 2);
36
- margin: var(--frame-width);
37
- z-index: 0;
38
- }
39
- }
40
- }
package/components.scss DELETED
@@ -1,3 +0,0 @@
1
- @use './components/icon.scss';
2
- @use './components/picture.scss';
3
- @use './components/text.scss';