Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt ::where selector to class variants for making styles overrideable #267

Merged
merged 2 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions scripts/postcss-optimize-default-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const plugin = () => {
const matched = rule.params.match(colorThemeMatcher)

if (matched) {
rule.params = 'all'

if (matched[1] === 'dark') {
rule.walkRules((rule) => {
postcssSelectorParser((selectorRoot) => {
Expand All @@ -29,13 +27,17 @@ const plugin = () => {
if (normalizedTagName === 'section') {
tag.parent.insertAfter(
tag,
postcssSelectorParser.className({ value: 'invert' })
postcssSelectorParser.pseudo({ value: ':where(.invert)' })
)
}
})
}).processSync(rule, { updateSelector: true })
})

// Append a rule of dark theme after the light theme
rule.next().after(rule.nodes)
}
rule.replaceWith(rule.nodes)
}
},
},
Expand Down
14 changes: 7 additions & 7 deletions themes/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ section {
padding: 78.5px;
width: 1280px;

&:where(.invert) {
--h1-color: #cee7ff;
--header-footer-color: #{rgba(#999, 0.75)};
--heading-strong-color: #7bf;
--paginate-color: #999;
}

> *:last-child,
&[data-footer] > :nth-last-child(2) {
margin-bottom: 0;
Expand All @@ -218,13 +225,6 @@ section {
color: var(--paginate-color);
}

&.invert {
--h1-color: #cee7ff;
--header-footer-color: #{rgba(#999, 0.75)};
--heading-strong-color: #7bf;
--paginate-color: #999;
}

&[data-color] {
h1,
h2,
Expand Down
6 changes: 3 additions & 3 deletions themes/gaia.scss
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ section {
margin-top: 0;
}

&.invert {
&:where(.invert) {
@include color-scheme($color-dark, $color-light, $color-secondary);
}

&.gaia {
&:where(.gaia) {
@include color-scheme($color-primary, $color-light, $color-secondary);
}

&.lead {
&:where(.lead) {
display: flex;
flex-flow: column nowrap;
justify-content: center;
Expand Down
8 changes: 6 additions & 2 deletions themes/uncover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ section {

@include color-scheme;

&:not(.invert) {
&:where(:not(.invert)) {
@import '~highlight.js/styles/color-brewer';
}

&.invert {
&:where(.invert) {
@include color-scheme(#202228, #fff, #60d0f0);
@import '~highlight.js/styles/codepen-embed';
}
Expand Down Expand Up @@ -196,6 +196,10 @@ section {
line-height: 1.15;
margin: 15px 0 30px;
text-align: left;

&::part(auto-scaling) {
max-height: 570px;
}
}

pre > code {
Expand Down
1 change: 1 addition & 0 deletions v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@

- New auto-scaling based on Web Components ([#96](https://github.com/marp-team/marp-core/issues/96), [#248](https://github.com/marp-team/marp-core/issues/248), [#263](https://github.com/marp-team/marp-core/pull/263))
- Match color schemes for `default` theme to the latest GitHub ([#266](https://github.com/marp-team/marp-core/issues/266))
- Adopt `::where()` selector to class variants for making styles overridable ([#244](https://github.com/marp-team/marp-core/issues/244), [#267](https://github.com/marp-team/marp-core/pull/267))