mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-24 16:41:21 +08:00
This adds sets of CSS button variables that can be overridden in themes.
This won't change any default styles, but just provides a less
problematic method of customization.
The current suggested way of doing this is with SCSS like so:
```scss
.btn-default {
@include btn(
$text-color: var(--tertiary),
$bg-color: var(--secondary),
$icon-color: var(--tertiary-high),
$hover-text-color: var(--tertiary),
$hover-bg-color: var(--tertiary-very-low),
$hover-icon-color: var(--tertiary)
);
}
```
The trouble with this is that it brings along _all_ the btn mixin
styles, so you also end up re-setting things like this, in addition to
changing colors:
```scss
.btn-default {
display: inline-flex;
align-items: center;
justify-content: center;
margin: 0;
// and also the colors
}
```
That can problematic because it can override existing button styles
(e.g., if you already altered a single instance of margin). With these
new CSS custom properties, you can avoid this by doing:
```css
:root {
--d-button-default-text-color: var(--tertiary);
--d-button-default-text-color--hover: var(--tertiary);
--d-button-default-bg-color: var(--secondary);
--d-button-default-bg-color--hover: var(--tertiary-very-low);
--d-button-default-icon-color: var(--tertiary-high);
--d-button-default-icon-color--hover: var(--tertiary);
}
```
So now you can override the button colors without bringing along other
styles from the btn mixin.
I also removed an old `.btn.hidden` style, as we already apply
`!important` to the `.hidden` class elsewhere. Comments have also been
updated to pass our new linting rules.
|
||
|---|---|---|
| .. | ||
| sidebar/edit-navigation-menu | ||
| _index.scss | ||
| ace-editor.scss | ||
| add-pm-participants.scss | ||
| badges.scss | ||
| banner.scss | ||
| bookmark-list.scss | ||
| bookmark-menu.scss | ||
| bookmark-modal.scss | ||
| buttons.scss | ||
| calendar-date-time-input.scss | ||
| char-counter.scss | ||
| color-input.scss | ||
| composer-toggle-switch.scss | ||
| conditional-loading-section.scss | ||
| convert-to-public-topic-modal.scss | ||
| d-breadcrumbs.scss | ||
| d-multi-select.scss | ||
| d-page-header.scss | ||
| d-select.scss | ||
| d-stat-tiles.scss | ||
| d-toggle-switch.scss | ||
| date-input.scss | ||
| date-picker.scss | ||
| date-time-input-range.scss | ||
| date-time-input.scss | ||
| download-calendar.scss | ||
| drafts-dropdown-menu.scss | ||
| dropdown-menu.scss | ||
| emoji-picker.scss | ||
| file-size-input.scss | ||
| filter-input.scss | ||
| footer-nav.scss | ||
| form-template-field.scss | ||
| group-member-dropdown.scss | ||
| groups-form-membership-fields.scss | ||
| hashtag.scss | ||
| horizontal-overflow-nav.scss | ||
| iframed-html.scss | ||
| ignored-user-list.scss | ||
| keyboard_shortcuts.scss | ||
| load-more.scss | ||
| more-topics.scss | ||
| navs.scss | ||
| notifications-tracking.scss | ||
| offline-indicator.scss | ||
| pick-files-button.scss | ||
| post-list.scss | ||
| post-translations.scss | ||
| powered-by-discourse.scss | ||
| relative-time-picker.scss | ||
| signup-progress-bar.scss | ||
| svg.scss | ||
| tap-tile.scss | ||
| theme-card.scss | ||
| time-input.scss | ||
| time-shortcut-picker.scss | ||
| topic-map.scss | ||
| topic-query-filter.scss | ||
| user-card.scss | ||
| user-info.scss | ||
| user-status-message.scss | ||
| user-status-picker.scss | ||
| user-stream-item.scss | ||
| user-stream.scss | ||
| welcome-banner.scss | ||
| welcome-header.scss | ||
| widget-dropdown.scss | ||