Skip to content

Commit b3b3a70

Browse files
committed
Merge branch 'v4-dev' of https://github.com/coreui/coreui into v4-dev-sync
# Conflicts: # scss/_buttons.scss # scss/_variables.scss # scss/sidebar/_sidebar-narrow.scss # scss/sidebar/_sidebar.scss
2 parents a61a17e + ace0c6a commit b3b3a70

File tree

16 files changed

+294
-360
lines changed

16 files changed

+294
-360
lines changed

docs/content/4.0/getting-started/rtl.md

Lines changed: 9 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ We recommend getting familiar with CoreUI for Bootstrap first by reading through
1212

1313
You may also want to read up on [the RTLCSS project](https://rtlcss.com/), as it powers our approach to RTL.
1414

15-
{{< callout warning >}}
16-
### Experimental feature
17-
18-
The RTL feature is still **experimental** and will probably evolve according to user feedback. Spotted something or have an improvement to suggest? [Open an issue]({{< param repo >}}/issues/new), we'd love to get your insights.
19-
{{< /callout >}}
20-
2115
## Required HTML
2216

2317
There are two strict requirements for enabling RTL in Bootstrap-powered pages.
@@ -67,43 +61,20 @@ You can see the above requirements reflected in this modified RTL starter templa
6761

6862
## Approach
6963

70-
Our approach to building RTL support into CoreUI for Bootstrap comes with two important decisions that impact how we write and use our CSS:
64+
Our approach to building RTL support into CoreUI comes with two important decisions that impact how we write and use our CSS:
7165

72-
1. **First, we decided to build it with the [RTLCSS](https://rtlcss.com/) project.** This gives us some powerful features for managing changes and overrides when moving from LTR to RTL. It also allows us to build two versions of CoreUI for Bootstrap from one codebase.
66+
1. **First, as in CoreUI 3 we decided to build it with our own mixins** This gives us full control and allows us to generate LTR and RTL separately, or if needed one stylesheet with both versions without any style's duplicates.
7367

74-
2. **Second, we've renamed a handful of directional classes to adopt a logical properties approach.** Most of you have already interacted with logical properties thanks to our flex utilities—they replace direction properties like `left` and `right` in favor `start` and `end`. That makes the class names and values appropriate for LTR and RTL without any overhead.
68+
2. **Second, in CoreUI 3 we introduced a handful of directional classes ex. `mfs-auto`, but in CoreUI 4 we've simplified them ex. `ms-auto`, and renamed all directional classes to adopt a logical properties approach.** Most of you have already interacted with logical properties thanks to our flex utilities—they replace direction properties like `left` and `right` in favor `start` and `end`. That makes the class names and values appropriate for LTR and RTL without any overhead.
7569

7670
For example, instead of `.ml-3` for `margin-left`, use `.ms-3`.
7771

7872
Working with RTL, through our source Sass or compiled CSS, shouldn't be much different from our default LTR though.
7973

8074
## Customize from source
8175

82-
When it comes to [customization]({{< docsref "/customize/sass" >}}), the preferred way is to take advantage of variables, maps, and mixins. This approach works the same for RTL, even if it's post-processed from the compiled files, thanks to [how RTLCSS works](https://rtlcss.com/learn/getting-started/why-rtlcss/).
83-
84-
### Custom RTL values
85-
86-
Using [RTLCSS value directives](https://rtlcss.com/learn/usage-guide/value-directives/), you can make a variable output a different value for RTL. For example, to decrease the weight for `$font-weight-bold` throughout the codebase, you may use the `/*rtl: {value}*/` syntax:
87-
88-
```scss
89-
$font-weight-bold: 700 #{/* rtl:600 */} !default;
90-
```
91-
92-
Which would ouput to the following for our default CSS and RTL CSS:
93-
94-
```css
95-
/* coreui.css */
96-
dt {
97-
font-weight: 700 /* rtl:600 */;
98-
}
99-
100-
/* coreui.rtl.css */
101-
dt {
102-
font-weight: 600;
103-
}
104-
```
105-
106-
### Alternative font stack
76+
When it comes to [customization]({{< docsref "/customize/sass" >}}), the preferred way is to take advantage of variables, maps, and mixins.
77+
<!-- TODO: find solution ### Alternative font stack
10778
10879
In the case you're using a custom font, be aware that not all fonts support the non-Latin alphabet. To switch from Pan-European to Arabic family, you may need to use `/*rtl:insert: {value}*/` in your font stack to modify the names of font families.
10980
@@ -130,47 +101,19 @@ $font-family-sans-serif:
130101
sans-serif,
131102
// Emoji fonts
132103
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
133-
```
104+
``` -->
134105

135106
### LTR and RTL at the same time
136107

137-
Need both LTR and RTL on the same page? Thanks to [RTLCSS String Maps](https://rtlcss.com/learn/usage-guide/string-map/), this is pretty straightforward. Wrap your `@import`s with a class, and set a custom rename rule for RTLCSS:
108+
Need both LTR and RTL on the same page? All you have to do is set following variables:
138109

139110
```scss
140-
/* rtl:begin:options: {
141-
"autoRename": true,
142-
"stringMap":[
143-
"name": "ltr-rtl",
144-
"priority": 100,
145-
"search": ["ltr"],
146-
"replace": ["rtl"],
147-
"options": {
148-
"scope": "*",
149-
"ignoreCase": false
150-
}
151-
]
152-
} */
153-
.ltr {
154-
@import "../node_modules/bootstrap/scss/bootstrap";
155-
}
156-
/*rtl:end:options*/
111+
$enable-ltr: true;
112+
$enable-rtl: true;
157113
```
158114

159115
After running Sass then RTLCSS, each selector in your CSS files will be prepended by `.ltr`, and `.rtl` for RTL files. Now you're able to use both files on the same page, and simply use `.ltr` or `.rtl` on your components wrappers to use one or the other direction.
160116

161-
{{< callout warning >}}
162-
#### Edge cases and known limitations
163-
164-
While this approach is understandable, please pay attention to the following:
165-
166-
1. When switching `.ltr` and `.rtl`, make sure you add `dir` and `lang` attributes accordingly.
167-
2. Loading both files can be a real performance bottleneck: consider some [optimization]({{< docsref "/customize/optimize" >}}), and maybe try to [load one of those files asynchronously](https://www.filamentgroup.com/lab/load-css-simpler/).
168-
3. Nesting styles this way will prevent our `form-validation-state()` mixin from working as intended, thus require you tweak it a bit by yourself. [See #31223](https://github.com/twbs/bootstrap/issues/31223).
169-
{{< /callout >}}
170-
171-
## The breadcrumb case
172-
173-
The [breadcrumb separator]({{< docsref "/components/breadcrumb" >}}/#changing-the-separator) is the only case requiring its own brand new variable— namely `$breadcrumb-divider-flipped` —defaulting to `$breadcrumb-divider`.
174117

175118
## Additional resources
176119

docs/layouts/partials/sidebar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</a>
2727

2828
{{- if $group.pages }}
29-
<ul class="nav-group-items sidebar-nav-sm">
29+
<ul class="nav-group-items compact">
3030
{{- range $doc := $group.pages -}}
3131
{{- $doc_slug := $doc.title | urlize -}}
3232
{{- $is_active := and $is_active_group (eq $page_slug $doc_slug) -}}

scss/_alert.scss

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
position: relative;
77
padding: $alert-padding-y $alert-padding-x;
88
margin-bottom: $alert-margin-bottom;
9-
border: $alert-border-width solid transparent;
9+
color: var(--#{$variable-prefix}alert-color);
10+
@include gradient-bg(var(--#{$variable-prefix}alert-bg));
11+
border: $alert-border-width solid var(--#{$variable-prefix}alert-border-color, transparent);
1012
@include border-radius($alert-border-radius);
1113
}
1214

@@ -19,6 +21,7 @@
1921
// Provide class for links that match alerts
2022
.alert-link {
2123
font-weight: $alert-link-font-weight;
24+
color: var(--#{$variable-prefix}alert-link-color);
2225
}
2326

2427

@@ -44,13 +47,13 @@
4447
// Generate contextual modifier classes for colorizing the alert.
4548

4649
@each $state, $map in $alert-variants {
47-
$background: var(--#{$variable-prefix}alert-background, map-get($map, "background"));
48-
$border: var(--#{$variable-prefix}alert-border-color, map-get($map, "border"));
49-
$color: var(--#{$variable-prefix}alert-color, contrast-ratio-correction(map-get($map, "color"), map-get($map, "background"), abs($alert-color-scale), $state));
50-
$link-color: var(--#{$variable-prefix}alert-link-color, map-get($map, "link-color"));
50+
$background: map-get($map, "background");
51+
$border-color: map-get($map, "border-color");
52+
$color: contrast-ratio-correction(map-get($map, "color"), map-get($map, "background"), abs($alert-color-scale), $state);
53+
$link-color: map-get($map, "link-color");
5154

5255
.alert-#{$state} {
53-
@include alert-variant($background, $border, $color, $link-color);
56+
@include alert-variant($background, $border-color, $color, $link-color);
5457
}
5558
}
5659
// scss-docs-end alert-modifiers

scss/_buttons.scss

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,75 @@
77
font-family: $btn-font-family;
88
font-weight: $btn-font-weight;
99
line-height: $btn-line-height;
10-
color: var(--#{$variable-prefix}body-color, $body-color);
10+
color: var(--#{$variable-prefix}btn-color, $body-color);
1111
text-align: center;
1212
text-decoration: if($link-decoration == none, null, none);
1313
white-space: $btn-white-space;
1414
vertical-align: middle;
1515
cursor: if($enable-button-pointers, pointer, null);
1616
user-select: none;
17-
background-color: transparent;
18-
border: $btn-border-width solid transparent;
17+
@include gradient-bg(var(--#{$variable-prefix}btn-bg, transparent));
18+
border: $btn-border-width solid var(--#{$variable-prefix}btn-border-color, transparent);
19+
@include box-shadow(var(--#{$variable-prefix}btn-box-shadow, $btn-box-shadow));
1920
@include button-size($btn-padding-y, $btn-padding-x, $btn-font-size, $btn-border-radius);
2021
@include transition($btn-transition);
2122
@include elevation(1, ("[class*='link']", "[class*='outline']", "[class*='ghost']", "[class*='transparent']"));
2223

2324
&:hover {
24-
color: var(--#{$variable-prefix}body-color, $body-color);
25+
color: var(--#{$variable-prefix}btn-hover-color, $body-color);
26+
@include gradient-bg(var(--#{$variable-prefix}btn-hover-bg));
2527
text-decoration: if($link-hover-decoration == underline, none, null);
28+
border-color: var(--#{$variable-prefix}btn-hover-border-color, transparent);
2629
@include elevation(2, ("[class*='link']", "[class*='outline']", "[class*='ghost']", "[class*='transparent']"));
2730
}
2831

2932
.btn-check:focus + &,
3033
&:focus {
34+
color: var(--#{$variable-prefix}btn-hover-color);
35+
@include gradient-bg(var(--#{$variable-prefix}btn-hover-bg));
36+
border-color: var(--#{$variable-prefix}btn-hover-border-color, transparent);
3137
outline: 0;
32-
box-shadow: $btn-focus-box-shadow;
38+
// box-shadow: $btn-focus-box-shadow; // TODO: check this solution
39+
@if $enable-shadows {
40+
@include box-shadow($btn-box-shadow, 0 0 0 $btn-focus-width var(--#{$variable-prefix}btn-shadow));
41+
} @else {
42+
// Avoid using mixin so we can pass custom focus shadow properly
43+
box-shadow: 0 0 0 $btn-focus-width var(--#{$variable-prefix}btn-shadow);
44+
}
3345
}
3446

3547
.btn-check:checked + &,
3648
.btn-check:active + &,
3749
&:active,
38-
&.active {
50+
&.active,
51+
.show > &.dropdown-toggle {
52+
color: var(--#{$variable-prefix}btn-active-color);
53+
background-color: var(--#{$variable-prefix}btn-active-bg);
54+
// Remove CSS gradients if they're enabled
55+
background-image: if($enable-gradients, none, null);
56+
border-color: var(--#{$variable-prefix}btn-active-border-color, transparent);
3957
@include box-shadow($btn-active-box-shadow);
4058

4159
&:focus {
42-
@include box-shadow($btn-focus-box-shadow, $btn-active-box-shadow);
60+
// @include box-shadow($btn-focus-box-shadow, $btn-active-box-shadow); // TODO: check this solution
61+
@if $enable-shadows {
62+
@include box-shadow($btn-active-box-shadow, 0 0 0 $btn-focus-width var(--#{$variable-prefix}btn-shadow));
63+
} @else {
64+
// Avoid using mixin so we can pass custom focus shadow properly
65+
box-shadow: 0 0 0 $btn-focus-width var(--#{$variable-prefix}btn-shadow);
66+
}
4367
}
4468
}
4569

4670
&:disabled,
4771
&.disabled,
4872
fieldset:disabled & {
73+
color: var(--#{$variable-prefix}btn-disabled-color);
4974
pointer-events: none;
75+
background-color: var(--#{$variable-prefix}btn-disabled-bg);
76+
// Remove CSS gradients if they're enabled
77+
background-image: if($enable-gradients, none, null);
78+
border-color: var(--#{$variable-prefix}btn-disabled-border-color, transparent);
5079
opacity: $btn-disabled-opacity;
5180
@include box-shadow(none);
5281
}
@@ -61,19 +90,19 @@
6190
@each $state, $map in $button-variants {
6291
.btn-#{$state} {
6392
@include button-variant(
64-
$background: var(--#{$variable-prefix}btn-background, map-get($map, "background")),
65-
$border-color: var(--#{$variable-prefix}btn-border-color, map-get($map, "border-color")),
66-
$color: var(--#{$variable-prefix}btn-color, map-get($map, "color")),
67-
$hover-background: var(--#{$variable-prefix}btn-hover-background, map-get($map, "hover-background")),
68-
$hover-border-color: var(--#{$variable-prefix}btn-hover-border, map-get($map, "hover-border-color")),
69-
$hover-color: var(--#{$variable-prefix}btn-hover-color, map-get($map, "hover-color")),
70-
$active-background: var(--#{$variable-prefix}btn-active-background, map-get($map, "active-background")),
71-
$active-border-color: var(--#{$variable-prefix}btn-active-border, map-get($map, "active-border-color")),
72-
$active-color: var(--#{$variable-prefix}btn-active-color, map-get($map, "active-color")),
73-
$disabled-background: var(--#{$variable-prefix}btn-disabled-background, map-get($map, "disabled-background")),
74-
$disabled-border-color: var(--#{$variable-prefix}btn-disabled-border, map-get($map, "disabled-border-color")),
75-
$disabled-color: var(--#{$variable-prefix}btn-disabled-color, map-get($map, "disabled-color")),
76-
$shadow: var(--#{$variable-prefix}btn-shadow, map-get($map, "shadow"))
93+
$background: map-get($map, "background"),
94+
$border-color: map-get($map, "border-color"),
95+
$color: map-get($map, "color"),
96+
$hover-background: map-get($map, "hover-background"),
97+
$hover-border-color: map-get($map, "hover-border-color"),
98+
$hover-color: map-get($map, "hover-color"),
99+
$active-background: map-get($map, "active-background"),
100+
$active-border-color: map-get($map, "active-border-color"),
101+
$active-color: map-get($map, "active-color"),
102+
$disabled-background: map-get($map, "disabled-background"),
103+
$disabled-border-color: map-get($map, "disabled-border-color"),
104+
$disabled-color: map-get($map, "disabled-color"),
105+
$shadow: map-get($map, "shadow")
77106
);
78107
}
79108
}
@@ -83,15 +112,15 @@
83112
@each $state, $map in $button-outline-ghost-variants {
84113
.btn-outline-#{$state} {
85114
@include button-outline-variant(
86-
$color: var(--#{$variable-prefix}btn-color, map-get($map, "color")),
87-
$hover-background: var(--#{$variable-prefix}btn-hover-background, map-get($map, "hover-background")),
88-
$hover-border-color: var(--#{$variable-prefix}btn-hover-border-color, map-get($map, "hover-border-color")),
89-
$hover-color: var(--#{$variable-prefix}btn-hover-color, map-get($map, "hover-color")),
90-
$active-background: var(--#{$variable-prefix}btn-active-background, map-get($map, "active-background")),
91-
$active-border-color: var(--#{$variable-prefix}btn-active-border-color, map-get($map, "active-border-color")),
92-
$active-color: var(--#{$variable-prefix}btn-active-color, map-get($map, "active-color")),
93-
$disabled-color: var(--#{$variable-prefix}btn-disabled-color, map-get($map, "disabled-color")),
94-
$shadow: var(--#{$variable-prefix}btn-shadow, map-get($map, "shadow"))
115+
$color: map-get($map, "color"),
116+
$hover-background: map-get($map, "hover-background"),
117+
$hover-border-color: map-get($map, "hover-border-color"),
118+
$hover-color: map-get($map, "hover-color"),
119+
$active-background: map-get($map, "active-background"),
120+
$active-border-color: map-get($map, "active-border-color"),
121+
$active-color: map-get($map, "active-color"),
122+
$disabled-color: map-get($map, "disabled-color"),
123+
$shadow: map-get($map, "shadow")
95124
);
96125
}
97126
}
@@ -101,15 +130,15 @@
101130
@each $state, $map in $button-outline-ghost-variants {
102131
.btn-ghost-#{$state} {
103132
@include button-ghost-variant(
104-
$color: var(--#{$variable-prefix}btn-color, map-get($map, "color")),
105-
$hover-background: var(--#{$variable-prefix}btn-hover-background, map-get($map, "hover-background")),
106-
$hover-border-color: var(--#{$variable-prefix}btn-hover-border-color, map-get($map, "hover-border-color")),
107-
$hover-color: var(--#{$variable-prefix}btn-hover-color, map-get($map, "hover-color")),
108-
$active-background: var(--#{$variable-prefix}btn-active-background, map-get($map, "active-background")),
109-
$active-border-color: var(--#{$variable-prefix}btn-active-border-color, map-get($map, "active-border-color")),
110-
$active-color: var(--#{$variable-prefix}btn-active-color, map-get($map, "active-color")),
111-
$disabled-color: var(--#{$variable-prefix}btn-disabled-color, map-get($map, "disabled-color")),
112-
$shadow: var(--#{$variable-prefix}btn-shadow, map-get($map, "shadow"))
133+
$color: map-get($map, "color"),
134+
$hover-background: map-get($map, "hover-background"),
135+
$hover-border-color: map-get($map, "hover-border-color"),
136+
$hover-color: map-get($map, "hover-color"),
137+
$active-background: map-get($map, "active-background"),
138+
$active-border-color: map-get($map, "active-border-color"),
139+
$active-color: map-get($map, "active-color"),
140+
$disabled-color: map-get($map, "disabled-color"),
141+
$shadow: map-get($map, "shadow")
113142
);
114143
}
115144
}

scss/_functions.scss

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003
184184
@function alert-color-map($color) {
185185
@return (
186186
"background": shift-color($color, $alert-bg-scale),
187-
"border": shift-color($color, $alert-border-scale),
187+
"border-color": shift-color($color, $alert-border-scale),
188188
"color": shift-color($color, $alert-color-scale),
189189
"link-color": shade-color(shift-color($color, $alert-color-scale), 20%)
190190
);
@@ -239,6 +239,28 @@ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003
239239
}
240240
// scss-docs-end list-group-color-functions
241241

242+
// scss-docs-start table-color-functions
243+
@function table-color-map($background) {
244+
$table-bg: $background;
245+
$color: color-contrast(opaque($body-bg, $background));
246+
$striped-bg: mix($color, $background, percentage($table-striped-bg-factor));
247+
$active-bg: mix($color, $background, percentage($table-active-bg-factor));
248+
$hover-bg: mix($color, $background, percentage($table-hover-bg-factor));
249+
250+
@return (
251+
"bg": $background,
252+
"color": $color,
253+
"border-color": mix($color, $background, percentage($table-border-factor)),
254+
"striped-bg": $striped-bg,
255+
"striped-color": color-contrast($striped-bg),
256+
"active-bg": $active-bg,
257+
"active-color": color-contrast($active-bg),
258+
"hover-bg": $hover-bg,
259+
"hover-color": color-contrast($hover-bg)
260+
);
261+
}
262+
// scss-docs-end table-color-functions
263+
242264
// Return valid calc
243265
@function add($value1, $value2, $return-calc: true) {
244266
@if $value1 == null {

scss/_list-group.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
&:active {
3636
color: var(--#{$variable-prefix}list-group-action-active-color, $list-group-action-active-color);
3737
background-color: var(--#{$variable-prefix}list-group-action-active-bg, $list-group-action-active-bg);
38+
border-color: var(--#{$variable-prefix}list-group-action-active-border-color);
3839
}
3940
}
4041

@@ -152,9 +153,9 @@
152153
// Organizationally, this must come after the `:hover` states.
153154

154155
@each $state, $map in $list-group-variants {
155-
$background: var(--#{$variable-prefix}list-group-background, map-get($map, "background"));
156-
$background-hover: var(--#{$variable-prefix}list-group-background-hover, map-get($map, "background-hover"));
157-
$color: var(--#{$variable-prefix}list-group-color, contrast-ratio-correction(map-get($map, "color"), map-get($map, "background"), abs($alert-color-scale), $state));
156+
$background: map-get($map, "background");
157+
$background-hover: map-get($map, "background-hover");
158+
$color: contrast-ratio-correction(map-get($map, "color"), map-get($map, "background"), abs($alert-color-scale), $state);
158159

159160
@include list-group-item-variant($state, $background, $background-hover, $color);
160161
}

0 commit comments

Comments
 (0)