Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
feat(theming): reduce specificity of default-theme selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
rschmukler committed Jun 3, 2015
1 parent 8d17301 commit 8468c60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/services/theming/theming.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ function parseRules(theme, colorType, rules) {
if (hueName !== 'default') {
newRule = newRule.replace(themeNameRegex, '.md-' + theme.name + '-theme.md-' + hueName);
}

// Don't apply a selector rule to the default theme, making it easier to override
// styles of the base-component
if (theme.name == 'default') {
newRule = newRule.replace(/\.md-default-theme/g, '');
}
generatedRules.push(newRule);
});

Expand Down
8 changes: 8 additions & 0 deletions src/core/services/theming/theming.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,19 @@ describe('$mdThemingProvider', function() {
themingProvider._parseRules(testTheme, 'primary', '').join('');
}).toThrow();
});

it('drops the default theme name from the selectors', function() {
expect(themingProvider._parseRules(
defaultTheme, 'primary', '.md-THEME_NAME-theme.md-button { }'
).join('')).toContain('.md-button { }');
});

it('replaces THEME_NAME', function() {
expect(themingProvider._parseRules(
testTheme, 'primary', '.md-THEME_NAME-theme {}'
).join('')).toContain('.md-test-theme {}');
});

describe('parses foreground text and shadow', function() {
it('for a light theme', function() {
testTheme.dark(false);
Expand Down

3 comments on commit 8468c60

@robertmesserle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rschmukler Just a heads up: this caused a lot of visual bugs in the docs site.

@TalPasi
Copy link

@TalPasi TalPasi commented on 8468c60 Jun 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit introduces a problem detailed in #3128

@mckenzielong
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to #3128: I think this is also broke default theming on progress-circular (seems like the directive in general, so md-select async too.)

Please sign in to comment.