@nulllogic/scssleon 1.0.4 → 1.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.
@@ -1,38 +1,96 @@
1
1
  @use 'sass:map';
2
2
  @use 'sass:meta';
3
+ @use 'sass:list';
4
+ @use 'sass:string';
3
5
 
4
6
  @use 'properties';
5
- @use 'wrapper';
6
7
 
7
8
  @use '../../functions' as functions;
8
9
 
9
10
  @mixin generate-component($component, $class, $config, $theme, $options : ()) {
10
11
  $theme-component: '';
11
12
 
13
+ $color_scheme: functions.get-config($config, 'color-scheme');
14
+ $is_wrapper_enabled: functions.get-config($config, 'enable.wrapper');
15
+ $wrapper_class: functions.get-config($config, 'wrapper');
16
+
12
17
  // Checking, if the component was previously defined inside theme's components
13
18
  @if (meta.type-of($component) == 'string') {
14
19
  /* Loading component settings and styling */
15
20
  $theme-component: functions.get-theme(
16
- $theme,
17
- 'components' + '.' + $component
21
+ $theme,
22
+ 'components' + '.' + $component
18
23
  );
19
24
  } @else {
20
25
  $theme-component: $component;
21
26
  }
22
27
 
23
- %#{$class} {
24
- @include properties.generate-properties($class, $theme-component, $config, $options);
25
- }
28
+ @each $scheme in string.split(functions.get-config($config, 'color-scheme'), ' ') {
29
+
30
+ @if $scheme == 'light' {
31
+ @if ($is_wrapper_enabled) {
32
+ #{$wrapper_class} {
33
+ .#{$class} {
34
+ @include properties.generate-properties($class, $theme-component, $config, map.deep-merge((
35
+ scheme: $scheme,
36
+ ), $options));
37
+ }
38
+ }
39
+ } @else {
40
+ .#{$class} {
41
+ @include properties.generate-properties($class, $theme-component, $config, map.deep-merge((
42
+ scheme: $scheme,
43
+ ), $options));
44
+ }
45
+ }
46
+ }
47
+
48
+ @if $scheme == 'dark' {
49
+ @if ($is_wrapper_enabled) {
50
+ #{$wrapper_class}[data-theme="#{$scheme}"] {
51
+ .#{$class}:where([data-theme="#{$scheme}"], [data-theme="#{$scheme}"] *) {
52
+ @include properties.generate-properties($class, $theme-component, $config, map.deep-merge((
53
+ scheme: $scheme,
54
+ ), $options));
55
+ }
56
+ }
26
57
 
27
- @include wrapper.generate-wrapper($config) {
28
- .#{$class} {
29
- @extend %#{$class};
58
+ } @else {
59
+ .#{$class}:where([data-theme="#{$scheme}"], [data-theme="#{$scheme}"] *) {
60
+ @include properties.generate-properties($class, $theme-component, $config, map.deep-merge((
61
+ scheme: $scheme,
62
+ ), $options));
63
+ }
64
+
65
+ }
30
66
  }
31
67
  }
32
68
  }
33
69
 
34
- //@mixin generate-components($component, $class, $config, $theme) {
70
+ @mixin generate-components($components, $config, $theme) {
71
+
72
+ // Get components
73
+ @each $component in $components {
74
+ // Component options param check
75
+ @if(list.length($component) > 2) {
76
+ @include generate-component(
77
+ list.nth($component, 1),
78
+ list.nth($component, 2),
79
+ $config: $config,
80
+ $theme: $theme,
81
+ $options: list.nth($component, 3),
82
+ )
83
+ } @else {
84
+ @include generate-component(
85
+ list.nth($component, 1),
86
+ list.nth($component, 2),
87
+ $config: $config,
88
+ $theme: $theme,
89
+ )
90
+ }
91
+ }
92
+ }
35
93
 
36
- @mixin get-structure ($component) {
94
+ @mixin get-structure($component) {
37
95
  @debug $component;
38
96
  }
@@ -1,57 +1,97 @@
1
1
  @use "sass:meta";
2
2
  @use "sass:string";
3
3
  @use "sass:map";
4
+ @use "sass:list";
4
5
 
5
6
  @use "../../functions" as functions;
6
7
  @use "../../mixins/generators/color-sheme" as mixin;
7
8
 
8
9
  @mixin generate-css-properties($tag, $property, $value, $config, $options : ()) {
9
- $prefix: functions.get-config($config, "prefix");
10
10
 
11
- @if(functions.get-config($options, 'add_pseudo_tag') != nil and functions.get-config($options, 'add_pseudo_tag') == false) {
12
- --#{$prefix}-#{functions.replace($property, '--', '')}: #{meta.inspect(
11
+ $prefix: functions.get-config($config, 'prefix');
12
+
13
+ $variable_options_custom_name: functions.get-config($options, 'variable.name');
14
+ $variable_options_exclude: functions.get-config($options, 'variable.exclude');
15
+
16
+ $variable_name: $tag;
17
+
18
+ $exclude: false;
19
+
20
+ @if ($variable_options_custom_name != nil) {
21
+ $variable_name: $variable_options_custom_name;
22
+ }
23
+
24
+ @if ($variable_options_exclude != nil) {
25
+
26
+ @if (meta.type-of($variable_options_exclude) == list) {
27
+ @each $variable_to_exclude in $variable_options_exclude {
28
+ @if string.index($property, --#{$variable_to_exclude}) {
29
+ $exclude: true
30
+ }
31
+ }
32
+ }
33
+
34
+ @if (meta.type-of($variable_options_exclude) == string) {
35
+ @if string.index($property, --#{$variable_options_exclude}) {
36
+ $exclude: true
37
+ }
38
+ }
39
+ }
40
+
41
+ @if ($exclude != true) {
42
+ --#{$prefix}-#{$variable_name}-#{functions.replace($property, '--', '')}: #{meta.inspect(
13
43
  $value
14
44
  )};
15
45
  } @else {
16
- --#{$prefix}-#{$tag}-#{functions.replace($property, '--', '')}: #{meta.inspect(
46
+ --#{$prefix}-#{functions.replace($property, '--', '')}: #{meta.inspect(
17
47
  $value
18
48
  )};
19
49
  }
50
+
20
51
  }
21
52
 
22
- @mixin generate-css-variables($tag, $property, $value, $config) {
23
- $prefix: functions.get-config($config, "prefix");
53
+ @mixin generate-css-variables($tag, $property, $value, $config, $options) {
54
+ $prefix: functions.get-config($config, 'prefix');
55
+
56
+ $variable_options_custom_name: functions.get-config($options, 'variable.name');
57
+ $variable_options_exclude: functions.get-config($options, 'variable.exclude');
58
+
59
+ $variable_name : $tag;
60
+
61
+ @if ($variable_options_custom_name != nil) {
62
+ $variable_name: $variable_options_custom_name;
63
+ }
64
+
65
+ @if (meta.type-of($value) == 'string' and string.index($value, 'var(--') == 1) {
24
66
 
25
- @if (meta.type-of($value) == "string" and string.index($value, "var(--") == 1) {
26
67
  #{$property}: #{meta.inspect(
27
- functions.replace($value, "--", "--" + $prefix + "-" + $tag + "-")
28
- )};
29
- } @else if (meta.type-of($value) == "string" and string.index($value, "var(global(") == 1) {
68
+ functions.replace($value, '--', '--' + $prefix + '-' + $variable_name + '-')
69
+ )};
70
+
71
+ } @else if (meta.type-of($value) == 'string' and string.index($value, 'var(global(') == 1) {
72
+
30
73
  #{$property}: #{meta.inspect(
31
74
  functions.replace(
32
75
  string.slice($value, 0, string.length($value) - 1),
33
- "global(--",
34
- "--" + $prefix + "-root-"
76
+ 'global(--',
77
+ '--' + $prefix + '-root-'
35
78
  )
36
79
  )};
80
+
37
81
  } @else {
82
+
38
83
  #{$property}: #{meta.inspect($value)};
84
+
39
85
  }
40
86
  }
41
87
 
42
- @mixin generate-colors($tag, $value, $config) {
43
- $prefix: functions.get-config($config, "prefix");
88
+ @mixin generate-colors($tag, $value, $config, $options, $requested_color : 'light') {
89
+ $prefix: functions.get-config($config, 'prefix');
44
90
 
45
91
  @each $color, $color-properties in $value {
46
- @each $scheme in string.split(functions.get-config($config, "color-scheme"), " ") {
47
- @if $scheme == $color {
48
- @include mixin.generate-color-scheme($color) {
49
- @each $color-property, $color-value in $color-properties {
50
- --#{$prefix}-#{$tag}-#{functions.replace($color-property, '--', '')}: #{meta.inspect(
51
- $color-value
52
- )};
53
- }
54
- }
92
+ @if ($color == $requested_color) {
93
+ @each $color-property, $color-value in $color-properties {
94
+ @include generate-css-properties($tag, $color-property, $color-value, $config, $options);
55
95
  }
56
96
  }
57
97
  }
@@ -64,16 +104,28 @@
64
104
  }
65
105
 
66
106
  @mixin generate-responsive($tag, $properties, $config) {
67
- $breakpoints: functions.get-config($config, "breakpoints");
107
+ $breakpoints: functions.get-config($config, 'breakpoints');
108
+
109
+ @each $property, $value in $properties {
110
+ $has-matched-breakpoint: false;
111
+
112
+ @each $breakpoint, $width in $breakpoints {
113
+ @if ($property == $breakpoint) {
114
+ $has-matched-breakpoint: true;
115
+ }
116
+ }
68
117
 
69
- @each $breakpoint, $value in $breakpoints {
70
- $property: map.get($properties, $breakpoint);
118
+ @if ($has-matched-breakpoint) {
119
+ $width: map.get($breakpoints, $property);
71
120
 
72
- @if $property != null {
73
- @media (min-width: $value) {
74
- @include generate-properties($tag, $property, $config);
121
+ @media (min-width: $width) {
122
+ @include generate-properties($tag, $value, $config);
75
123
  }
124
+
125
+ } @else {
126
+ @warn '❗️Invalid breakpoint '#{$property}'.';
76
127
  }
128
+
77
129
  }
78
130
  }
79
131
 
@@ -86,45 +138,78 @@
86
138
  }
87
139
  }
88
140
 
89
- @mixin generate-animation($tag, $value, $config, $options) {
141
+ @mixin generate-print($tag, $value, $config, $options) {
142
+ //@TODO
143
+ }
90
144
 
145
+ @mixin generate-animation($tag, $value, $config, $options) {
146
+ @each $name, $properties in $value {
147
+ // Check, if _animation is not empty ;;
148
+ @if (meta.type-of($properties) != 'list') {
149
+ @keyframes #{$name} {
150
+ @each $offset, $offset-value in $properties {
151
+ #{$offset} {
152
+ @include generate-properties($tag, $offset-value, $config, $options);
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
91
158
  }
92
159
 
93
160
  @mixin generate-properties($tag, $properties, $config, $options : ()) {
94
- $prefix: functions.get-config($config, "prefix");
161
+ $prefix: functions.get-config($config, 'prefix');
162
+ $is_scheme_dark: functions.get-config($options, 'scheme') != nil and functions.get-config($options, 'scheme') == 'dark';
163
+
164
+ @if (not $is_scheme_dark) {
165
+ @each $property, $value in $properties {
166
+ // Variables
167
+ // Looking for "--" symbols in the beginning of the property
168
+ // Example: --flex-direction : row
169
+ @if (
170
+ meta.type-of($property) == 'string' and string.index($property, "--") == 1
171
+ ) {
172
+ @include generate-css-properties($tag, $property, $value, $config, $options);
173
+ }
95
174
 
96
- @each $property, $value in $properties {
97
- // Variables
98
- // Looking for "--" symbols in the beginning of the property
99
- // Example: --flex-direction : row
100
- @if (
101
- meta.type-of($property) == "string" and string.index($property, "--") == 1
102
- ) {
103
- @include generate-css-properties($tag, $property, $value, $config, $options);
104
- }
175
+ // Colors
176
+ @else if ($property == '_colors') {
177
+ @include generate-colors($tag, $value, $config, $options, 'light');
178
+ }
105
179
 
106
- // Colors
107
- @else if ($property == "_colors") {
108
- @include generate-colors($tag, $value, $config);
109
- }
180
+ // Responsive
181
+ @else if ($property == '_responsive') {
182
+ @include generate-responsive($tag, $value, $config);
183
+ }
110
184
 
111
- // Responsive
112
- @else if ($property == "_responsive") {
113
- @include generate-responsive($tag, $value, $config);
114
- }
185
+ // Sub classes
186
+ @else if ($property == "_subclasses") {
187
+ @each $class, $class_properties in $value {
188
+ @include generate-subclasses($tag, $class, $class_properties, $config, $options);
189
+ }
190
+ }
115
191
 
116
- // Sub classes
117
- @else if ($property == "_subclasses") {
118
- @each $class, $class_properties in $value {
119
- @include generate-subclasses($tag, $class, $class_properties, $config, $options);
192
+ // At-rules
193
+ @else if ($property == '_atrule') {
194
+ @include generate-atrule($tag, $value, $config, $options);
195
+ }
196
+
197
+ // Animations
198
+ @else if ($property == '_animations') {
199
+ @include generate-animation($tag, $value, $config, $options);
200
+ } @else {
201
+ @include generate-css-variables($tag, $property, $value, $config, $options);
120
202
  }
121
203
  }
122
- // At-rules
123
- @else if ($property == "_atrule") {
124
- @include generate-atrule($tag, $value, $config, $options);
125
- }
126
- @else {
127
- @include generate-css-variables($tag, $property, $value, $config);
204
+ } @else {
205
+ @each $property, $value in $properties {
206
+ @if ($property == '_colors') {
207
+ @include generate-colors($tag, $value, $config, $options, 'dark');
208
+ } @else if ($property == '_subclasses') {
209
+ @each $class, $class_properties in $value {
210
+ @include generate-subclasses($tag, $class, $class_properties, $config, $options);
211
+ }
212
+ }
128
213
  }
129
214
  }
130
215
  }
@@ -1,6 +1,7 @@
1
1
  @charset "UTF-8";
2
- @use "./mixins" as mixins;
3
- @use "./functions" as functions;
2
+
3
+ @forward './mixins';
4
+ @forward './functions';
4
5
 
5
6
  /*
6
7
  * ------------------------------------------------------------------
@@ -27,7 +28,7 @@ Main configuration - initial configuration requirement
27
28
  // Those two variables will be used to store configuration settings and theme settings
28
29
  // You can easily customize any available options to fit your needs
29
30
  $config: (
30
- prefix: "xii",
31
+ prefix: 'xii',
31
32
  enable: (
32
33
  wrapper: false,
33
34
  ),
@@ -41,14 +42,15 @@ $theme: (
41
42
 
42
43
  // ↓ Config
43
44
  // Override default config | @example
44
- @use "config" as config with (
45
+ @use 'config' as config with (
45
46
  $config: $config
46
47
  );
47
48
 
48
49
  // ↓ Theme
49
50
  /* Override default settings in the theme | @example */
50
- @use "themes/default" as theme with (
51
+ @use 'themes/default' as theme with (
51
52
  $theme: $theme,
53
+ $config: config.$config,
52
54
  );
53
55
 
54
56
  // Getting updated variables
@@ -61,13 +63,13 @@ $theme: theme.$theme;
61
63
  */
62
64
 
63
65
  // ↓ Root
64
- @use "root" with (
66
+ @use 'root' with (
65
67
  $config: $config,
66
68
  $theme: $theme
67
69
  );
68
70
 
69
71
  // ↓ Great reset
70
- @use "reset" with (
72
+ @use 'reset' with (
71
73
  $config: $config,
72
74
  $theme: $theme
73
75
  );
@@ -75,70 +77,70 @@ $theme: theme.$theme;
75
77
  // ↓ Base
76
78
  // Special utility, that will dynamically generate CSS
77
79
  // properties for HTML tags, specified in theme
78
- @use "base" with (
80
+ @use 'base' with (
79
81
  $config: $config,
80
82
  $theme: $theme
81
83
  );
82
84
 
83
85
  // ↓ Amazing content
84
86
  // Special class `.content` to allow formatting of the default html tags
85
- @use "content" with (
87
+ @use 'content' with (
86
88
  $config: $config,
87
89
  $theme: $theme
88
90
  );
89
91
 
90
92
  // ↓ Container
91
- @use "components/container" with (
93
+ @use 'components/container' with (
92
94
  $config: $config,
93
95
  $theme: $theme
94
96
  );
95
97
 
96
98
  // ↓ Card
97
- @use "components/card" with (
99
+ @use 'components/card' with (
98
100
  $config: $config,
99
101
  $theme: $theme
100
102
  );
101
103
 
102
104
  // ↓ Badge
103
- @use "components/badge" with (
105
+ @use 'components/badge' with (
104
106
  $config: $config,
105
107
  $theme: $theme
106
108
  );
107
109
 
108
110
  // ↓ Form
109
- @use "components/form" with (
111
+ @use 'components/form' with (
110
112
  $config: $config,
111
113
  $theme: $theme
112
114
  );
113
115
 
114
116
  // ↓ Buttons
115
- @use "components/button" with (
117
+ @use 'components/button' with (
116
118
  $config: $config,
117
119
  $theme: $theme
118
120
  );
119
- @use "components/button_group" with (
121
+ @use 'components/button_group' with (
120
122
  $config: $config,
121
123
  $theme: $theme
122
124
  );
123
125
 
124
- ////@use "components/icon";
125
- //@use "components/button";
126
- ////@use "components/button-group";
126
+ ////@use 'components/icon';
127
+ //@use 'components/button';
128
+ ////@use 'components/button-group';
127
129
 
128
130
  // ↓ Breadcrumbs
129
- @use "components/breadcrumb" with (
131
+ @use 'components/breadcrumb' with (
130
132
  $config: $config,
131
133
  $theme: $theme
132
134
  );
133
135
 
134
136
  // ↓ Alert
135
- @use "components/alert" with (
137
+ @use 'components/alert' with (
136
138
  $config: $config,
137
139
  $theme: $theme
138
140
  );
139
141
 
140
142
  // ↓ Accordion
141
- @use "components/accordion" with (
143
+ @use 'components/accordion' with (
142
144
  $config: $config,
143
145
  $theme: $theme
144
146
  );
@@ -150,60 +152,66 @@ $theme: theme.$theme;
150
152
  //);
151
153
 
152
154
  // ↓ Overlay
153
- @use "components/overlay" with (
155
+ @use 'components/overlay' with (
154
156
  $config: $config,
155
157
  $theme: $theme
156
158
  );
157
159
 
158
160
  // ↓ Pagination
159
- @use "components/pagination" with (
161
+ @use 'components/pagination' with (
160
162
  $config: $config,
161
163
  $theme: $theme
162
164
  );
163
165
 
164
166
  // ↓ Placeholder
165
- @use "components/placeholder" with (
167
+ @use 'components/placeholder' with (
166
168
  $config: $config,
167
169
  $theme: $theme
168
170
  );
169
171
 
170
172
  // ↓ Modal
171
- @use "components/modal" with (
173
+ @use 'components/modal' with (
172
174
  $config: $config,
173
175
  $theme: $theme
174
176
  );
175
177
 
176
178
  // ↓ Loader
177
- @use "components/loader" with (
179
+ @use 'components/loader' with (
178
180
  $config: $config,
179
181
  $theme: $theme
180
182
  );
181
183
 
182
184
  // ↓ Nav
183
- @use "components/nav" with (
185
+ @use 'components/nav' with (
184
186
  $config: $config,
185
187
  $theme: $theme
186
188
  );
187
189
 
188
190
  // ↓ Navigation bar
189
- @use "components/navbar" with (
191
+ @use 'components/navbar' with (
190
192
  $config: $config,
191
193
  $theme: $theme
192
194
  );
193
195
 
194
196
  // ↓ Sidecap
195
- @use "components/sidecap" with (
197
+ @use 'components/sidecap' with (
198
+ $config: $config,
199
+ $theme: $theme
200
+ );
201
+
202
+ // ↓ Tooltip
203
+ @use 'components/tooltip' with (
196
204
  $config: $config,
197
205
  $theme: $theme
198
206
  );
199
207
 
200
208
  // ↓ Helpers
201
- @use "helpers/clearfix";
202
- @use "helpers/screen_reader";
203
- @use "helpers/text_truncate";
209
+ @use 'helpers/clearfix';
210
+ @use 'helpers/screen_reader';
211
+ @use 'helpers/text_truncate';
204
212
 
205
213
  // ↓ Utilities
206
- @use "utilities/api" with (
214
+ @use 'utilities/api' with (
207
215
  $config: $config,
208
216
  $theme: $theme
209
217
  );