Skip to content

Commit 491dc81

Browse files
committed
Use CSS Custom Property for brand color
1 parent 1197250 commit 491dc81

File tree

8 files changed

+69
-19
lines changed

8 files changed

+69
-19
lines changed

addon/components/docs-header/link/template.hbs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@
2828
{{#link-to route
2929
class=(concat
3030
'docs-px-4 docs-py-5 docs-transition docs-uppercase docs-text-xxs
31-
docs-font-bold docs-no-underline docs-text-grey-darkest '
32-
(if (and (not isActive) (not (eq route 'index'))) 'hover:docs-text-brand')
33-
(if (and isActive (not (eq route 'index'))) 'docs-text-brand')
31+
docs-font-bold docs-no-underline '
32+
(if (not (eq route 'index'))
33+
(if isActive
34+
'docs-text-brand'
35+
'docs-text-grey-darkest hover:docs-text-brand'
36+
)
37+
'docs-text-grey-darkest'
38+
)
3439
)
3540
data-test-id=data-test-id
3641
}}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
We use CSS Custom Properties so addons can customize their brand theme, but we need to provide a fallback for browsers that don't support them yet (IE). This is the way we do it.
3+
4+
If we get access to the PostCSS pipeline in the future we could use a plugin like this: https://github.com/postcss/postcss-custom-properties
5+
*/
6+
.docs-bg-brand {
7+
background-color: #E04E39 !important;
8+
@apply docs-bg-brand-var !important;
9+
}
10+
.hover\:docs-bg-brand:hover {
11+
background-color: #E04E39 !important;
12+
@apply docs-bg-brand-var !important;
13+
}
14+
.focus\:docs-bg-brand:focus {
15+
background-color: #E04E39 !important;
16+
@apply docs-bg-brand-var !important;
17+
}
18+
19+
.docs-text-brand {
20+
color: #E04E39 !important;
21+
@apply docs-text-brand-var !important;
22+
}
23+
.hover\:docs-text-brand:hover {
24+
color: #E04E39 !important;
25+
@apply docs-text-brand-var !important;
26+
}
27+
.focus\:docs-text-brand:focus {
28+
color: #E04E39 !important;
29+
@apply docs-text-brand-var !important;
30+
}
31+
32+
.docs-border-brand {
33+
border-color: #E04E39 !important;
34+
@apply docs-border-brand-var !important;
35+
}
36+
.hover\:docs-border-brand:hover {
37+
border-color: #E04E39 !important;
38+
@apply docs-border-brand-var !important;
39+
}
40+
.focus\:docs-border-brand:focus {
41+
border-color: #E04E39 !important;
42+
@apply docs-border-brand-var !important;
43+
}

addon/tailwind/config/colors.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default {
3535

3636
'yellow': '#ffed4a',
3737

38-
'brand': '#E04E39'
38+
// See the ntoe in tailwind/compnents/docs-brand-colors.css
39+
'brand-var': 'var(--brand-primary, #E04E39)'
3940

4041
};

test-apps/new-addon/tests/acceptance/smoke-test-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ module('Acceptance | boot test', function(hooks) {
1111
assert.equal(currentURL(), '/');
1212
});
1313

14-
test('styles are properly loaded', async function(assert) {
14+
test('the --brand-primary css variable works', async function(assert) {
1515
await visit('/');
1616

1717
let hero = find('.docs-bg-brand');
1818
let fontSize = window.getComputedStyle(hero).getPropertyValue("background-color");
1919

20-
assert.equal(fontSize, 'rgb(224, 78, 57)');
20+
assert.equal(fontSize, 'rgb(0, 128, 0)');
2121
});
2222
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:root {
2+
--brand-primary: green;
3+
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
{{docs-hero
2-
logo='ember'
3-
slimHeading='New'
4-
strongHeading='Addon'
5-
byline='A simple addon.'}}
1+
{{docs-header}}
62

73
{{outlet}}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{docs-hero
2+
logo='ember'
3+
slimHeading='New'
4+
strongHeading='Addon'
5+
byline='A simple addon.'}}
6+
7+
# Home
8+
9+
Testing a {{docs-link 'link' 'index'}}.

yarn.lock

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10815,21 +10815,14 @@ topo@2.x.x:
1081510815
dependencies:
1081610816
hoek "4.x.x"
1081710817

10818-
tough-cookie@>=0.12.0, tough-cookie@>=2.3.3, tough-cookie@^2.2.0, tough-cookie@^2.3.4, tough-cookie@~2.4.3:
10818+
tough-cookie@>=0.12.0, tough-cookie@>=2.3.3, tough-cookie@^2.2.0, tough-cookie@^2.3.4, tough-cookie@~2.3.3, tough-cookie@~2.4.0, tough-cookie@~2.4.3:
1081910819
version "2.4.3"
1082010820
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781"
1082110821
integrity sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==
1082210822
dependencies:
1082310823
psl "^1.1.24"
1082410824
punycode "^1.4.1"
1082510825

10826-
tough-cookie@~2.3.3:
10827-
version "2.3.4"
10828-
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655"
10829-
integrity sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==
10830-
dependencies:
10831-
punycode "^1.4.1"
10832-
1083310826
tr46@^1.0.1:
1083410827
version "1.0.1"
1083510828
resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09"

0 commit comments

Comments
 (0)