Skip to content

Commit d7cb071

Browse files
tmorehousejacobmllr95
authored andcommitted
feat(tooltip): add in SCSS support for specifying tooltip variant background color level (bootstrap-vue#3653)
* chore: add in support for specifying tooltip variant background color level * Update _tooltip.scss * Update _variables.scss * Update README.md * Update README.md * Update README.md * Update _popover.scss * Update README.md
1 parent ae9ee27 commit d7cb071

File tree

4 files changed

+93
-10
lines changed

4 files changed

+93
-10
lines changed

docs/markdown/reference/color-variants/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ These variants translate to class names `table-<variant>`.
8080

8181
When the table has the `dark` prop set, the variants translate to the `bg-<variant>` classes.
8282

83+
### Popover variants
84+
85+
All the **base variants**
86+
87+
These translate to BootstrapVue custom class names `b-popover-<variant>`.
88+
89+
### Tooltip variants
90+
91+
All the **base variants**
92+
93+
These translate to BootstrapVue custom class names `b-tooltip-<variant>`.
94+
95+
### Toast variants
96+
97+
All the **base variants**
98+
99+
These translate to BootstrapVue custom class names `b-toast-<variant>`.
100+
83101
## Using variant classes
84102

85103
You may also use the underlying class names directly on elements (and some components) via the
@@ -90,3 +108,62 @@ standard HTML `class="..."` attribute.
90108
When creating custom variants, follow the Bootstrap v4 variant CSS class naming scheme and they will
91109
become available to the various components that use that scheme (i.e. create a custom CSS class
92110
`btn-purple` and `purple` becomes a valid variant to use on `<b-button>`).
111+
112+
Alternatively, you can create new variant theme colors by supplying custom Bootstrap SCSS them color
113+
maps. The default theme color map is (from `bootstrap/scss/_variables.scss`):
114+
115+
```scss
116+
// Base grayscale colors definitions
117+
$white: #fff !default;
118+
$gray-100: #f8f9fa !default;
119+
$gray-200: #e9ecef !default;
120+
$gray-300: #dee2e6 !default;
121+
$gray-400: #ced4da !default;
122+
$gray-500: #adb5bd !default;
123+
$gray-600: #6c757d !default;
124+
$gray-700: #495057 !default;
125+
$gray-800: #343a40 !default;
126+
$gray-900: #212529 !default;
127+
$black: #000 !default;
128+
129+
// Base colors definitions
130+
$blue: #007bff !default;
131+
$indigo: #6610f2 !default;
132+
$purple: #6f42c1 !default;
133+
$pink: #e83e8c !default;
134+
$red: #dc3545 !default;
135+
$orange: #fd7e14 !default;
136+
$yellow: #ffc107 !default;
137+
$green: #28a745 !default;
138+
$teal: #20c997 !default;
139+
$cyan: #17a2b8 !default;
140+
141+
// Theme color default definitions
142+
$primary: $blue !default;
143+
$secondary: $gray-600 !default;
144+
$success: $green !default;
145+
$info: $cyan !default;
146+
$warning: $yellow !default;
147+
$danger: $red !default;
148+
$light: $gray-100 !default;
149+
$dark: $gray-800 !default;
150+
151+
// This table defines the theme colors (variant names)
152+
$theme-colors: () !default;
153+
$theme-colors: map-merge(
154+
(
155+
'primary': $primary,
156+
'secondary': $secondary,
157+
'success': $success,
158+
'info': $info,
159+
'warning': $warning,
160+
'danger': $danger,
161+
'light': $light,
162+
'dark': $dark
163+
),
164+
$theme-colors
165+
);
166+
```
167+
168+
Refer to the [Theming section](/docs/reference/theming) for details on customizing Bootstrap and
169+
BootstrapVue styles.

src/_variables.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ $b-toast-bg-level: $alert-bg-level !default;
2222
$b-toast-border-level: $alert-border-level !default;
2323
$b-toast-color-level: $alert-color-level !default;
2424

25-
// --- Tooltip variants ---
25+
// --- Enable tooltip variants ---
2626
$bv-enable-tooltip-variants: true !default;
2727

28-
// --- Popover variant levels wrt theme color value ---
28+
// --- Tooltip background variant level wrt theme color value ---
29+
$bv-tooltip-bg-level: 0 !default;
30+
31+
// --- Enable popover variants ---
2932
$bv-enable-popover-variants: true !default;
33+
34+
// --- Popover variant levels wrt theme color value ---
3035
$bv-popover-bg-level: $alert-bg-level !default;
3136
$bv-popover-border-level: $alert-border-level !default;
3237
$bv-popover-color-level: $alert-color-level !default;

src/components/popover/_popover.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$po-header-color: color-yiq($po-header-bg);
99
$po-arrow-color: $po-bg-color;
1010
$po-arrow-color-bottom: $po-header-bg;
11-
$po-arrow-outer-color: fade-in($po-border-color, .05);
11+
$po-arrow-outer-color: fade-in($po-border-color, 0.05);
1212

1313
&.popover {
1414
background-color: $po-bg-color;

src/components/tooltip/_tooltip.scss

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@
22
@if $bv-enable-tooltip-variants {
33
@each $color, $value in $theme-colors {
44
.tooltip.b-tooltip-#{$color} {
5-
$tip-text-color: color-yiq($value);
5+
$tip-bg-color: theme-color-level($color, $bv-tooltip-bg-level);
6+
$tip-text-color: color-yiq($tip-bg-color);
67

78
&.bs-tooltip-top {
89
.arrow::before {
9-
border-top-color: $value;
10+
border-top-color: $tip-bg-color;
1011
}
1112
}
1213

1314
&.bs-tooltip-right {
1415
.arrow::before {
15-
border-right-color: $value;
16+
border-right-color: $tip-bg-color;
1617
}
1718
}
1819

1920
&.bs-tooltip-bottom {
2021
.arrow::before {
21-
border-bottom-color: $value;
22+
border-bottom-color: $tip-bg-color;
2223
}
2324
}
2425

2526
&.bs-tooltip-left {
2627
.arrow::before {
27-
border-left-color: $value;
28+
border-left-color: $tip-bg-color;
2829
}
2930
}
3031

@@ -44,8 +45,8 @@
4445
}
4546

4647
.tooltip-inner {
47-
color: color-yiq($value);
48-
background-color: $value;
48+
color: $tip-text-color;
49+
background-color: $tip-bg-color;
4950
}
5051
}
5152
}

0 commit comments

Comments
 (0)