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

Feature dark mode toggle #358

Merged
merged 7 commits into from
Nov 4, 2020
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
1 change: 1 addition & 0 deletions addons/rose/addon/components/rose/dropdown/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
button=(component "rose/dropdown/button" style=this.style)
item=(component "rose/anonymous" class="rose-dropdown-item")
separator=(component "rose/anonymous" tagName="hr" class="rose-dropdown-separator")
section=(component "rose/dropdown/section" style=this.style)
)}}
</div>

Expand Down
10 changes: 9 additions & 1 deletion addons/rose/addon/components/rose/dropdown/index.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import { boolean } from '@storybook/addon-knobs';
A simple dropdown component with support for links and buttons.

<Preview>
<Story name="Basic Dropdown" height="5rem">{{
<Story name="Basic Dropdown" height="7rem">{{
template: hbs`
<Rose::Dropdown @text="Choose One&hellip;" @icon="user-organization" @showCaret={{showCaret}} as |dropdown|>
<dropdown.link @route="index">Menu item</dropdown.link>
<dropdown.link @route="about">Menu item</dropdown.link>
<dropdown.separator />
<dropdown.button>Button menu item</dropdown.button>
<dropdown.separator />
<dropdown.section @title="Dropdown Section Title">
<dropdown.link @route="index">Menu item</dropdown.link>
</dropdown.section>
</Rose::Dropdown>
`,
context: {
Expand Down Expand Up @@ -65,6 +69,10 @@ A simple dropdown component with support for links and buttons.
<dropdown.link @route="index">Menu item</dropdown.link>
<dropdown.link @route="about">Menu item</dropdown.link>
<dropdown.button>Button menu item</dropdown.button>
<dropdown.separator />
<dropdown.section @title="Dropdown Section Title">
<dropdown.link @route="index">Menu item</dropdown.link>
</dropdown.section>
</Rose::Dropdown>
```

Expand Down
12 changes: 12 additions & 0 deletions addons/rose/addon/components/rose/dropdown/section/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<section class="rose-dropdown-section" aria-labelledby={{concat "dropdown-section-title-" this.id}}>
{{#if @title}}
<h2
id={{concat "dropdown-section-title-" this.id}}
class="rose-dropdown-section-title"
>
{{@title}}
</h2>
{{/if}}

{{yield}}
</section>
14 changes: 14 additions & 0 deletions addons/rose/addon/components/rose/dropdown/section/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Component from '@glimmer/component';
import { generateComponentID } from '../../../../utilities/component-auto-id';
import { action } from '@ember/object';

export default class RoseDialogComponent extends Component {

// =attributes

/**
* @type {string}
*/
id = generateComponentID();

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{yield (hash
radio=(component 'rose/form/radio/radio' name=@name selectedValue=@selectedValue disabled=@disabled)
radio=(component 'rose/form/radio/radio' name=@name selectedValue=@selectedValue disabled=@disabled changed=@changed)
)}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
import { hbs } from 'ember-cli-htmlbars';
import { action } from '@storybook/addon-actions';
import { text, boolean, select } from '@storybook/addon-knobs';

<Meta title="Rose|Form/Radio/Group" component="Form/Radio/Group" />
Expand All @@ -13,6 +14,7 @@ Renders a form radiofield group.
@disabled={{false}}
@name={{name}}
@selectedValue="disagree"
@changed={{fn}}
as |radioGroup|
>
<radioGroup.radio
Expand All @@ -36,6 +38,7 @@ Renders a form radiofield group.
@disabled={{disabled}}
@name={{name}}
@selectedValue={{selectedValue}}
@changed={{changed}}
as |radioGroup|
>
<radioGroup.radio
Expand Down Expand Up @@ -73,6 +76,7 @@ Renders a form radiofield group.
secondFieldValue: text('second value', 'maybe'),
thirdFieldLabel: text('third label', 'Disagree'),
thirdFieldValue: text('third value', 'disagree'),
changed: action('changed')
}
}}</Story>
</Preview>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
@name={{@name}}
@value={{@value}}
@groupValue={{@selectedValue}}
@disabled={{@disabled}}/>
@disabled={{@disabled}}
@changed={{@changed}} />

<label class="rose-form-radio-label" for={{this.id}}>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Renders a form radiofield.
@value="yes-agree"
@selectedValue="yes-agree"
@disabled={{false}}
@changed={{fn}}
/>
```

Expand Down
23 changes: 19 additions & 4 deletions addons/rose/addon/styles/rose/components/card/_link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@
$xxxs: sizing.rems(xxxs); // 2

.rose-card-link {

--background-color-light: transparent;
--background-color-dark: var(--ui-gray-subtler-6);

--background-color: var(--background-color-light);

.ember-application.rose-theme-light & {
--background-color: var(--background-color-light);
}

@media (prefers-color-scheme: dark) {
--background-color: var(--background-color-dark);
}

.ember-application.rose-theme-dark & {
--background-color: var(--background-color-dark);
}

@include type.type(s);
border: sizing.rems(xxxxs) solid var(--ui-gray-subtler-2);
border-radius: sizing.rems(xxxs);
Expand All @@ -15,10 +33,7 @@ $xxxs: sizing.rems(xxxs); // 2
margin: 0 sizing.rems(m) sizing.rems(m) 0;
box-shadow: 0 $xxxs $xxxs rgba(var(--stark-components), var(--opacity-4)),
0 $xxxs $xxxs rgba(var(--stark-components), var(--opacity-4));

@media (prefers-color-scheme: dark) {
background-color: var(--ui-gray-subtler-6);
}
background-color: var(--background-color);

a {
text-decoration: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,27 @@

$xs: sizing.rems(xs); // 8
$xxs: sizing.rems(xxs); // 4
$chevron: "data:image/svg+xml;utf-8,<svg viewBox='0 0 24 24' fill='%231b1f26' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z'></path></svg>";
$chevronWhite: "data:image/svg+xml;utf-8,<svg viewBox='0 0 24 24' fill='%23ffffff' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z'></path></svg>";
$chevron: url("data:image/svg+xml;utf-8,<svg viewBox='0 0 24 24' fill='%231b1f26' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z'></path></svg>");
$chevronWhite: url("data:image/svg+xml;utf-8,<svg viewBox='0 0 24 24' fill='%23ffffff' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z'></path></svg>");

.rose-dropdown {
--background-image-light: #{$chevron};
--background-image-dark: #{$chevronWhite};

--background-image: var(--background-image-light);

.ember-application.rose-theme-light & {
--background-image: var(--background-image-light);
}

@media (prefers-color-scheme: dark) {
--background-image: var(--background-image-dark);
}

.ember-application.rose-theme-dark & {
--background-image: var(--background-image-dark);
}

position: relative;
display: inline-block;

Expand Down Expand Up @@ -59,14 +76,10 @@ $chevronWhite: "data:image/svg+xml;utf-8,<svg viewBox='0 0 24 24' fill='%23fffff

&.show-caret {
padding-right: sizing.rems(xl);
background-image: url($chevron);
background: var(--background-image);
background-repeat: no-repeat;
background-position: right sizing.rems(m) center;
background-size: sizing.rems(m);

@media (prefers-color-scheme: dark) {
background-image: url($chevronWhite);
}
}

// Hide default twistie triangle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
@import 'button';
@import 'link';
@import 'item';
@import 'section';
13 changes: 13 additions & 0 deletions addons/rose/addon/styles/rose/components/dropdown/_section.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@use '../../variables/sizing';
@use '../../utilities/type';

.rose-dropdown-section {
.rose-dropdown-section-title {
@include type.type(s, bold);
padding: 0 sizing.rems(s);
margin: 0;
$line-height: 36 / 14;
line-height: $line-height;
color: var(--ui-gray)
}
}
24 changes: 19 additions & 5 deletions addons/rose/addon/styles/rose/components/header/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,29 @@
@import 'dropdown';

.rose-header {

--box-shadow-light: none;
--box-shadow-dark: inset 0 -#{sizing.rems(xxxxs)} 0 var(--ui-border-subtler-1);

--box-shadow: var(--box-shadow-light);

.ember-application.rose-theme-light & {
--box-shadow: var(--box-shadow-light);
}

@media (prefers-color-scheme: dark) {
--box-shadow: var(--box-shadow-dark);
}

.ember-application.rose-theme-dark & {
--box-shadow: var(--box-shadow-dark);
}

display: grid;
grid-template-areas: 'brand nav utilities';
grid-template-columns: 0.01fr auto 1fr;
background: var(--black);
box-shadow: inset 0 -#{sizing.rems(xxxxs)} 0 var(--ui-border-subtler-1);

@media (prefers-color-scheme: light) {
box-shadow: none;
}
box-shadow: var(--box-shadow);
}

@media (max-width: media.width(small)) {
Expand Down
28 changes: 21 additions & 7 deletions addons/rose/addon/styles/rose/variables/_opacity.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

// Light Mode
:root {
@mixin light-mode {
--opacity-5: 0.025;
--opacity-4: 0.05;
--opacity-3: 0.1;
Expand All @@ -15,12 +15,26 @@
// Dark Mode
// Subtler opacities look better in dark mode, so these are halved compared to
// light mode.
@mixin dark-mode {
--opacity-5: 0.0125;
--opacity-4: 0.0125;
--opacity-3: 0.025;
--opacity-2: 0.025;
--opacity-1: 0.125;
}

// Light mode is the default, hence it is applied to `html` by default
.ember-application,
.ember-application.rose-theme-light {
@include light-mode;
}

@media (prefers-color-scheme: dark) {
:root {
--opacity-5: 0.0125;
--opacity-4: 0.0125;
--opacity-3: 0.025;
--opacity-2: 0.025;
--opacity-1: 0.125;
.ember-application {
@include dark-mode;
}
}

.ember-application.rose-theme-dark {
@include dark-mode;
}
Loading