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

Add basic clean-theme support and update card, frame patterns #89

Merged
merged 1 commit into from
Jun 15, 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
23 changes: 23 additions & 0 deletions src/pattern-library/components/patterns/MoleculePatterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export default function MoleculePatterns() {
<div className="hyp-u-border">Child content in a frame.</div>
</div>
</PatternExample>
<PatternExample details="content in a frame: clean theme">
<div className="theme-clean">
<div className="hyp-frame">
Content within a frame in the clean theme. The frame itself has
no borders when in the clean theme.
</div>
</div>
</PatternExample>
</PatternExamples>
</Pattern>

Expand Down Expand Up @@ -59,6 +67,21 @@ export default function MoleculePatterns() {
</div>
</div>
</PatternExample>
<PatternExample details="Clean theme">
<div className="theme-clean">
<div className="hyp-card">
<div>
This is some text in a card in the clean theme. There are no
borders or box-shadows.
</div>
<div className="hyp-actions">
<IconButton title="User" icon="profile" />
<IconButton title="Edit" icon="edit" />
<IconButton title="Delete" icon="trash" />
</div>
</div>
</div>
</PatternExample>
</PatternExamples>
</Pattern>

Expand Down
11 changes: 11 additions & 0 deletions src/pattern-library/components/patterns/PanelPatterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ export default function SharedPanelPatterns() {
This panel has an optional icon in the header.
</Panel>
</PatternExample>
<PatternExample details="A panel in the clean theme">
<div className="theme-clean" style="width:100%">
<Panel
icon="edit"
title="Panel with clean-theme styling"
onClose={() => alert('close clicked')}
>
This panel has an optional icon in the header.
</Panel>
</div>
</PatternExample>
</PatternExamples>
</Pattern>
</PatternPage>
Expand Down
43 changes: 43 additions & 0 deletions styles/mixins/_themes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* This mixin allows other mixins to declare rules that should only apply
* when a particular theme is active.
*
* The only known theme at present is the "clean" theme and it only applies
* to the client (Sidebar, Notebook) application.
*
* The client application provides relatively minimalistic support for a
* "clean" theme by applying a `theme-clean` class to the application container
* element.
*
* For example, let's say that the clean-theme variant of a pattern called
* `banana` should not have any borders applied. Its mixin can be written:
*
* @mixin banana {
* border: 1px solid pink;
* @include theme('clean') {
* border: none;
* }
* }
*
* .hyp-banana {
* @include banana;
* }
*
* This would result in CSS:
*
* .hyp-banana {
* border: 1px solid pink;
* }
*
* .theme-clean .hyp-banana {
* border: none;
* }
*
* Note: As implemented here, theming increases specificity. Rules defined in
* theming cannot be overridden with utility classes as currently structured.
*/
@mixin theme($theme-name) {
.theme-#{$theme-name} & {
@content;
}
}
15 changes: 13 additions & 2 deletions styles/mixins/patterns/_molecules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@use '../atoms';
@use '../layout';
@use '../themes';

$-border-radius: var.$border-radius;
$-color-background: var.$color-background;
Expand All @@ -14,11 +15,17 @@ $-color-background: var.$color-background;
/**
* Give an element a border, background color and internal vertical spacing
*/
@mixin frame($with-hover: false) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Derp. This argument was unused.


@mixin frame {
@include layout.block;
@include atoms.border;
border-radius: $-border-radius;
background-color: $-color-background;

@include themes.theme('clean') {
// A frame should not have any borders in the clean theme.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both this comment and the one further down in this module are "x is 5"-type comments, but the point I'm trying to make is that we should document theme deviations and their intent.

border: none;
}
}

/**
Expand All @@ -36,9 +43,13 @@ $-color-background: var.$color-background;
@include atoms.shadow($active: true);
}
}

width: 100%;

// TODO: Add clean-theme affordances
@include themes.theme('clean') {
// A card should have no shadows at all in the clean theme.
box-shadow: none;
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions styles/mixins/patterns/_organisms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@use '../atoms';
@use '../layout';
@use '../themes';

@use 'molecules';

Expand All @@ -15,6 +16,12 @@ $-color-brand: var.$color-brand;
@mixin panel {
@include molecules.card;

@include themes.theme('clean') {
// Cards won't have borders in the clean theme, but in the case of panels,
// we want some borders for delineation
@include atoms.border;
}

& > header,
&__header {
@include layout.row($align: center);
Expand Down