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

Remove card mode to align elevation #2792

Merged
merged 51 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b1f8f80
Remove old grid-specific card styling
RasmusKjeldgaard Jan 16, 2023
4e2b25e
Add flags example component
RasmusKjeldgaard Jan 18, 2023
991d943
Create default example with shared styles
RasmusKjeldgaard Jan 18, 2023
c5c5cdc
Add flag page with flag variant selector
RasmusKjeldgaard Jan 18, 2023
abedc8f
Add color example
RasmusKjeldgaard Jan 18, 2023
fb5eb7c
Add clickable example
RasmusKjeldgaard Jan 18, 2023
ee3cff6
Update module with examples
RasmusKjeldgaard Jan 18, 2023
a11125c
Remove unused example components
RasmusKjeldgaard Jan 18, 2023
bf68dd6
Add background image example
RasmusKjeldgaard Jan 18, 2023
b95ed9f
Update showcase with new examples
RasmusKjeldgaard Jan 18, 2023
079724f
Small line break changes in examples
RasmusKjeldgaard Jan 18, 2023
e331dc8
Update wording in showcase
RasmusKjeldgaard Jan 18, 2023
dacb876
Add disclosure example
RasmusKjeldgaard Jan 18, 2023
b7c183c
Add all showcase examples to parent popout example
RasmusKjeldgaard Jan 18, 2023
e9a2611
Add template property to background img example
RasmusKjeldgaard Jan 18, 2023
53030a3
Replace disclosure example with new example
RasmusKjeldgaard Jan 18, 2023
1e4d7ed
Edit description in disclosure example
RasmusKjeldgaard Jan 18, 2023
ec3bcb4
Better descriptions in showcase
RasmusKjeldgaard Jan 19, 2023
177a5aa
Adjust showcase
RasmusKjeldgaard Jan 23, 2023
dcd1cc5
Simplify card examples and add flag example comp
RasmusKjeldgaard Jan 16, 2023
8f0f1ad
Remove highlight concept and replace mode with flat boolean
RasmusKjeldgaard Jan 16, 2023
7de60bb
Update usage of elevation 8 to elevation 4
RasmusKjeldgaard Jan 16, 2023
9df5b6d
Revert premature z2 change
RasmusKjeldgaard Jan 16, 2023
738d649
Use new 'flat' input on card in cookbook
RasmusKjeldgaard Jan 16, 2023
25e2ace
WIP
RasmusKjeldgaard Jan 18, 2023
9f2ed2f
Remove highlighted css class
RasmusKjeldgaard Jan 20, 2023
72484fc
Add flat example to showcase
RasmusKjeldgaard Jan 20, 2023
a518f7d
Remove accidentally reintroduced old flags example
RasmusKjeldgaard Jan 20, 2023
5352cd1
Update text inside flat card
RasmusKjeldgaard Jan 20, 2023
b5b2426
Remove old grid-specific card styling
RasmusKjeldgaard Jan 16, 2023
b078b76
Add flags example component
RasmusKjeldgaard Jan 18, 2023
8b53279
Create default example with shared styles
RasmusKjeldgaard Jan 18, 2023
f28023e
Add flag page with flag variant selector
RasmusKjeldgaard Jan 18, 2023
f8c3289
Add color example
RasmusKjeldgaard Jan 18, 2023
ff8ba2e
Add clickable example
RasmusKjeldgaard Jan 18, 2023
ded0aef
Update module with examples
RasmusKjeldgaard Jan 18, 2023
e97f126
Remove unused example components
RasmusKjeldgaard Jan 18, 2023
6fb4bb8
Add background image example
RasmusKjeldgaard Jan 18, 2023
c6740d1
Update showcase with new examples
RasmusKjeldgaard Jan 18, 2023
591c62e
Small line break changes in examples
RasmusKjeldgaard Jan 18, 2023
c7d5d18
Update wording in showcase
RasmusKjeldgaard Jan 18, 2023
d813a25
Add disclosure example
RasmusKjeldgaard Jan 18, 2023
8707d4c
Add all showcase examples to parent popout example
RasmusKjeldgaard Jan 18, 2023
b444e98
Add template property to background img example
RasmusKjeldgaard Jan 18, 2023
02a6e70
Replace disclosure example with new example
RasmusKjeldgaard Jan 18, 2023
f8719a0
Edit description in disclosure example
RasmusKjeldgaard Jan 18, 2023
52fd41d
Better descriptions in showcase
RasmusKjeldgaard Jan 19, 2023
cd01db7
Adjust showcase
RasmusKjeldgaard Jan 23, 2023
b07789d
Merge branch 'enhancement/improve-card-documentation-2' into enhancem…
RasmusKjeldgaard Jan 23, 2023
019ca87
Add back accidentally removed styles
RasmusKjeldgaard Jan 23, 2023
d880721
Merge branch 'develop' into enhancement/2668-align-card-elevation-2
RasmusKjeldgaard Jan 23, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CardExampleDisclosureComponent } from './examples/disclosure';
import { CardExampleColorComponent } from './examples/color';
import { CardExampleDefaultComponent } from './examples/default';
import { CardExampleFlagComponent } from './examples/flag';
import { CardExampleFlatComponent } from './examples/flat';

const COMPONENT_DECLARATIONS = [
CardExampleComponent,
Expand All @@ -18,6 +19,7 @@ const COMPONENT_DECLARATIONS = [
CardExampleColorComponent,
CardExampleDisclosureComponent,
CardExampleBackgroundImageComponent,
CardExampleFlatComponent,
];

@NgModule({
Expand Down
20 changes: 20 additions & 0 deletions apps/cookbook/src/app/examples/card-example/examples/flat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component } from '@angular/core';

const config = {
selector: 'cookbook-card-example-flat',
template: `<kirby-card hasPadding="true" flat="true">
<strong>A flat card</strong>
<p>Use with caution.</p>
<p>In general the look and feel of the default card is preferred in most use cases as it elevates the card a bit from the background.
But if you need a flat look, here it is!</p>
</kirby-card>`,
};

@Component({
selector: config.selector,
template: config.template,
styleUrls: ['./card-example.shared.scss'],
})
export class CardExampleFlatComponent {
template: string = config.template;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h2>Examples</h2>
<h3>Badge with numbers</h3>
<p>Using a badge with a number can be a good way to indicate specific status on an element.</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-badge-example-number #badgeExampleNumber></cookbook-badge-example-number>
<cookbook-example-viewer [html]="badgeExampleNumber.template"> </cookbook-example-viewer>
</kirby-card>
Expand All @@ -41,7 +41,7 @@ <h3>Badge with text</h3>
Badges can also be used together with a text. Flags might in some cases be a better alternative.
</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-badge-example-text #badgeExampleText></cookbook-badge-example-text>
<cookbook-example-viewer [html]="badgeExampleText.template"> </cookbook-example-viewer>
</kirby-card>
Expand All @@ -53,7 +53,7 @@ <h3>Badge with icons</h3>
existence of an associated element (e.g. an attachment).
</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-badge-example-icon #badgeExampleIcon></cookbook-badge-example-icon><br />
<cookbook-example-viewer [html]="badgeExampleIcon.template"> </cookbook-example-viewer>
</kirby-card>
Expand All @@ -65,7 +65,7 @@ <h3>Small Badges</h3>
without any content. This can be useful to indicate status on an element.
</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-badge-example-small #badgeExampleSmall></cookbook-badge-example-small>
<cookbook-example-viewer [html]="badgeExampleSmall.template"> </cookbook-example-viewer>
</kirby-card>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { Component } from '@angular/core';
import exampleHtml from '../../examples/badge-example/badge-example.component.html?raw';
import {
ApiDescriptionProperty,
ApiDescriptionPropertyColumns,
} from '~/app/shared/api-description/api-description-properties/api-description-properties.component';

import exampleHtml from '../../examples/badge-example/badge-example.component.html?raw';

@Component({
selector: 'cookbook-badge-showcase',
templateUrl: './badge-showcase.component.html',
})
export class BadgeShowcaseComponent {
exampleHtml = exampleHtml;
_cardMode = 'flat';
_cardHasPadding = true;

_properties: ApiDescriptionProperty[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h2>Default</h2>
</cookbook-example-viewer>

<h2>State & Disclosure</h2>

<p>
Whenever a card can be interacted with it is a best practice to also add a disclosure indicator,
to show that it navigates to a new page, opens a modal or similar.
Expand Down Expand Up @@ -84,6 +85,16 @@ <h2>Background image</h2>
></cookbook-card-example-background-image>
</cookbook-example-viewer>

<h2>Flat</h2>
<p>
By default the card has a slightly elevated look with a shadow around its edges. This can be
removed by setting the flat input, but be aware that this option should not be used with a card
that can be interacted with (clickable, disclosure) as it lacks proper affordance.
</p>
<cookbook-example-viewer [html]="flatExample.template">
<cookbook-card-example-flat #flatExample></cookbook-card-example-flat>
</cookbook-example-viewer>

<kirby-divider [hasMargin]="true"></kirby-divider>

<h2>API Description</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ export class CardShowcaseComponent {
type: ['string'],
},
{
name: 'mode',
description:
'(Optional) Sets a custom elevation on the card. Default elevation = 2, flat = 0, highlighted = 4.',
name: 'flat',
description: '(Optional) Remove elevation on the card. Default elevation = 2, flat = 0.',
defaultValue: '',
type: ['flat', 'highlighted'],
type: ['boolean'],
},
{
name: 'hasPadding',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
labels, interactions, more complex datasets & custom options.
</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer [html]="simpleColumnExample.template">
<cookbook-chart-example-simple-column
#simpleColumnExample
Expand All @@ -35,7 +35,7 @@ <h3>Column Chart</h3>
<p>The column chart visualizes data from different categories as rectangles.</p>
<p>To render a column chart set <code>type</code> to <code>"column"</code>.</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer [html]="columnExample.template" [ts]="columnExample.codeSnippet">
<cookbook-chart-example-column #columnExample></cookbook-chart-example-column>
</cookbook-example-viewer>
Expand All @@ -46,7 +46,7 @@ <h3>Bar Chart</h3>
<p>The bar chart visualizes data from different categories as rectangles along the x-axis.</p>
<p>To render a bar chart set <code>type</code> to <code>'bar'</code>.</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer [html]="barExample.template">
<cookbook-chart-example-bar #barExample></cookbook-chart-example-bar>
</cookbook-example-viewer>
Expand All @@ -57,7 +57,7 @@ <h3>Line Chart</h3>
<p>The line chart visualizes data from different categories as a line along the x-axis.</p>
<p>To render a line chart set <code>type</code> to <code>'line'</code>.</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer [html]="lineExample.template">
<cookbook-chart-example-line #lineExample></cookbook-chart-example-line>
</cookbook-example-viewer>
Expand Down Expand Up @@ -104,7 +104,7 @@ <h3>Interacting with charts</h3>
>.
</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer
[html]="interactionExample.template"
[ts]="interactionExample.codeSnippet"
Expand All @@ -117,7 +117,7 @@ <h3>Interacting with charts</h3>
<h3 id="stacked-bar-and-column-charts">Stacked Bar & column charts</h3>
<p>Stacked charts can be created using a combination of custom options and datasets.</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer [html]="stackedExample.template" [ts]="stackedExample.codeSnippet">
<cookbook-chart-example-column-stacked #stackedExample>
</cookbook-chart-example-column-stacked>
Expand Down Expand Up @@ -153,7 +153,7 @@ <h2><a id="datasets">Datasets</a></h2>
used to draw a line:
</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer
[html]="multipleDatasetsExample.template"
[ts]="multipleDatasetsExample.codeSnippet"
Expand Down Expand Up @@ -220,7 +220,7 @@ <h2>Annotations</h2>
</p>

<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer
[html]="annotationsExample.template"
[ts]="annotationsExample.codeSnippet"
Expand All @@ -240,7 +240,7 @@ <h2>Line Chart with fill</h2>
<a href="https://www.chartjs.org/docs/latest/samples/area/line-datasets.html">Area charts</a>
</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer [html]="lineAreaExample.template" [ts]="lineAreaExample.codeSnippet">
<cookbook-chart-example-area-line #lineAreaExample></cookbook-chart-example-area-line>
</cookbook-example-viewer>
Expand Down Expand Up @@ -301,7 +301,7 @@ <h2>Accessibility</h2>
</p>

<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer
[html]="accessibilityExample.template"
[ts]="accessibilityExample.codeSnippet"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
templateUrl: './chart-showcase.component.html',
})
export class ChartShowcaseComponent {
_cardMode = 'flat';
_cardHasPadding = true;
_apiDescriptionProperties: ApiDescriptionProperty[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h3>Simple list with swipe actions</h3>
when selected. The delete action has been configured to display an icon.
</p>

<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer [html]="simpleExample.template" [ts]="simpleExample.codeSnippet">
<cookbook-item-sliding-simple-example #simpleExample></cookbook-item-sliding-simple-example>
</cookbook-example-viewer>
Expand All @@ -36,7 +36,7 @@ <h3>Conditional configuration of swipe actions</h3>
'delete' swipe action is conditionally disabled on a per item basis, based on whether it is
deleteable.
</p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer
[html]="conditionalExample.template"
[ts]="conditionalExample.codeSnippet"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ApiDescriptionProperty } from '~/app/shared/api-description/api-descrip
templateUrl: './item-sliding-showcase.component.html',
})
export class ItemSlidingShowcaseComponent {
_cardMode = 'flat';
_cardHasPadding = true;

_inputPropertiesApiDescription: ApiDescriptionProperty[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</small>

<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer [html]="stockExample.template" [ts]="stockExample.codeSnippet">
<cookbook-chart-example-stock #stockExample></cookbook-chart-example-stock>
</cookbook-example-viewer>
Expand All @@ -48,7 +48,7 @@ <h2>Stock Chart with multiple datasets</h2>
in the data labels will be suffixed with '%' as can be seen on the below example.
</p>
<p>
<kirby-card [mode]="_cardMode" [hasPadding]="_cardHasPadding">
<kirby-card [flat]="true" [hasPadding]="_cardHasPadding">
<cookbook-example-viewer
[html]="stockComparisonExample.template"
[ts]="stockComparisonExample.codeSnippet"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
templateUrl: './stock-chart-showcase.component.html',
})
export class StockChartShowcaseComponent {
_cardMode = 'flat';
_cardHasPadding = true;
_apiDescriptionProperties: ApiDescriptionProperty[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions libs/core/src/scss/_global-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ion-modal.kirby-overlay {
--background: var(--kirby-modal-background, #{utils.get-color('background-color')});
--border-radius: 0;
--height: auto;
--box-shadow: #{utils.get-elevation(8)};
--box-shadow: #{utils.get-elevation(4)};

&.kirby-modal-compact {
--border-radius: #{utils.$border-radius};
Expand Down Expand Up @@ -158,7 +158,7 @@ ion-modal.kirby-overlay {
&.kirby-alert {
--background: #{utils.get-color('background-color')};
--border-radius: #{utils.$border-radius};
--box-shadow: #{utils.get-elevation(8)};
--box-shadow: #{utils.get-elevation(4)};
--max-width: #{utils.$alert-max-width};
--height: auto;
}
Expand Down
3 changes: 2 additions & 1 deletion libs/core/src/scss/base/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ $breakpoints: (
****************************************************************************/
$elevations: (
2: (
0 1px 24px 0 rgb(28 28 28 / 4%),
0 5px 10px -10px rgb(28 28 28 / 30%),
0 0 5px 0 rgb(28 28 28 / 8%),
),
4: (
0 10px 15px -10px rgb(28 28 28 / 30%),
Expand Down
13 changes: 5 additions & 8 deletions libs/designsystem/card/src/card.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

&.kirby-color-brightness-dark {
@include themes.apply-dark-theme;

&[role='button'] {
@include interaction-state.apply-hover('xxs', $make-lighter: true);
@include interaction-state.apply-active('s', $make-lighter: true);
}
}

@include interaction-state.extend-content {
Expand Down Expand Up @@ -48,10 +53,6 @@
}
}

&.highlighted {
box-shadow: utils.get-elevation(4);
}

&.flat {
box-shadow: none;
}
Expand All @@ -62,10 +63,6 @@
@include interaction-state.apply-active('xxs');
@include interaction-state.apply-focus-visible($shadow: utils.get-elevation(2));

&.highlighted {
@include interaction-state.apply-focus-visible($shadow: utils.get-elevation(4));
}

&.interaction-state-make-lighter-and-louder {
@include interaction-state.apply-hover('xxs', $make-lighter: true);
@include interaction-state.apply-active('s', $make-lighter: true);
Expand Down
7 changes: 1 addition & 6 deletions libs/designsystem/card/src/card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,8 @@ export class CardComponent implements OnInit, OnDestroy {
}

@HostBinding('class.flat')
@Input()
flat: boolean = false;
@HostBinding('class.highlighted')
highlighted: boolean = false;
@Input() set mode(value: 'flat' | 'highlighted') {
this.flat = value === 'flat';
this.highlighted = value === 'highlighted';
}

@HostBinding('class.interaction-state-make-lighter-and-louder')
@Input()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ $button-width: (
min-width: unset;

&:not(:disabled) {
box-shadow: utils.get-elevation(8);
box-shadow: utils.get-elevation(4);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ $min-screen-width: 375px;
}

> button {
box-shadow: utils.get-elevation(8);
box-shadow: utils.get-elevation(4);
}
}

Expand Down Expand Up @@ -112,7 +112,7 @@ kirby-card {
max-height: $dropdown-max-height;
margin-block: utils.size('xxxs');
overflow-y: auto;
box-shadow: utils.get-elevation(8);
box-shadow: utils.get-elevation(4);
min-width: $min-screen-width-small - $margin-horizontal-total;
@include utils.media('>=small') {
min-width: $min-screen-width - $margin-horizontal-total;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ion-fab-button {

// end NOTE

--box-shadow: #{utils.get-elevation(8)};
--box-shadow: #{utils.get-elevation(4)};

@include interaction-state.apply-focus-visible {
outline: none;
Expand Down
Loading