feat(card): add ionic theme tokens, update design (#29757)

## What is the new behavior?
- Reviewed tokens used for `ion-card` on Ionic Theme.
- Removed border on ion-card.
- Changed default shape to round.
- Added ionic theme partials for `ion-title`, `ion-subtitle`, `ion-header` and `ion-content`.

## Other information
[Sample Screen](https://ionic-framework-hyyi9k1ti-ionic1.vercel.app/src/components/card/test/theme-ionic)

---------

Co-authored-by: Brandy Carney <brandyscarney@gmail.com>
Co-authored-by: ionitron <hi@ionicframework.com>
This commit is contained in:
Bernardo Cardoso
2024-08-09 20:21:41 +01:00
committed by GitHub
parent 8fb813686f
commit 210f724ae7
39 changed files with 179 additions and 73 deletions

View File

@ -465,10 +465,13 @@ ion-card,prop,shape,"rectangular" | "round" | "soft" | undefined,'round',false,t
ion-card,prop,target,string | undefined,undefined,false,false ion-card,prop,target,string | undefined,undefined,false,false
ion-card,prop,theme,"ios" | "md" | "ionic",undefined,false,false ion-card,prop,theme,"ios" | "md" | "ionic",undefined,false,false
ion-card,prop,type,"button" | "reset" | "submit",'button',false,false ion-card,prop,type,"button" | "reset" | "submit",'button',false,false
ion-card,css-prop,--background,ionic
ion-card,css-prop,--background,ios ion-card,css-prop,--background,ios
ion-card,css-prop,--background,md ion-card,css-prop,--background,md
ion-card,css-prop,--border-radius,ionic
ion-card,css-prop,--border-radius,ios ion-card,css-prop,--border-radius,ios
ion-card,css-prop,--border-radius,md ion-card,css-prop,--border-radius,md
ion-card,css-prop,--color,ionic
ion-card,css-prop,--color,ios ion-card,css-prop,--color,ios
ion-card,css-prop,--color,md ion-card,css-prop,--color,md
ion-card,part,native ion-card,part,native

View File

@ -0,0 +1,6 @@
// Card Content
// --------------------------------------------------
ion-card-content {
position: relative;
}

View File

@ -0,0 +1,27 @@
@use "./card-content.common.scss";
@use "../../themes/ionic/ionic.globals.scss" as globals;
// Ionic Card Content
// --------------------------------------------------
.card-content-ionic {
@include globals.padding(globals.$ionic-space-400);
display: flex;
flex-direction: column;
font-size: globals.$ionic-font-size-350;
line-height: globals.$ionic-line-height-600;
gap: globals.$ionic-space-200;
img {
@include globals.margin(globals.$ionic-space-200, 0, globals.$ionic-space-200, 0);
}
}
ion-card-header + .card-content-ionic {
padding-top: 0;
}

View File

@ -1,4 +1,4 @@
@import "./card-content"; @import "./card-content.native";
@import "./card-content.ios.vars"; @import "./card-content.ios.vars";
// iOS Card Header // iOS Card Header

View File

@ -1,4 +1,4 @@
@import "./card-content"; @import "./card-content.native";
@import "./card-content.md.vars"; @import "./card-content.md.vars";
// Material Design Card Content // Material Design Card Content

View File

@ -1,3 +1,4 @@
@use "./card-content.common.scss";
@import "../../themes/native/native.globals"; @import "../../themes/native/native.globals";
// Card Content // Card Content
@ -5,5 +6,4 @@
ion-card-content { ion-card-content {
display: block; display: block;
position: relative;
} }

View File

@ -12,7 +12,7 @@ import { getIonTheme } from '../../global/ionic-global';
styleUrls: { styleUrls: {
ios: 'card-content.ios.scss', ios: 'card-content.ios.scss',
md: 'card-content.md.scss', md: 'card-content.md.scss',
ionic: 'card-content.md.scss', ionic: 'card-content.ionic.scss',
}, },
}) })
export class CardContent implements ComponentInterface { export class CardContent implements ComponentInterface {

View File

@ -1,4 +1,4 @@
@import "../../themes/native/native.globals"; @use "../../themes/functions.color" as color;
// Card Header // Card Header
// -------------------------------------------------- // --------------------------------------------------
@ -17,6 +17,6 @@
} }
:host(.ion-color) { :host(.ion-color) {
background: current-color(base); background: color.current-color(base);
color: current-color(contrast); color: color.current-color(contrast);
} }

View File

@ -0,0 +1,10 @@
@use "./card-header.common";
@use "../../themes/ionic/ionic.globals.scss" as globals;
// Ionic Card Header
// --------------------------------------------------
:host {
@include globals.padding(globals.$ionic-space-400);
gap: globals.$ionic-space-050;
}

View File

@ -1,4 +1,5 @@
@import "./card-header"; @import "./card-header.common";
@import "../../themes/native/native.globals";
@import "./card-header.ios.vars"; @import "./card-header.ios.vars";
// iOS Card Header // iOS Card Header

View File

@ -1,4 +1,5 @@
@import "./card-header"; @import "./card-header.common";
@import "../../themes/native/native.globals";
@import "./card-header.md.vars"; @import "./card-header.md.vars";
// Material Design Card Header // Material Design Card Header

View File

@ -14,7 +14,7 @@ import type { Color } from '../../interface';
styleUrls: { styleUrls: {
ios: 'card-header.ios.scss', ios: 'card-header.ios.scss',
md: 'card-header.md.scss', md: 'card-header.md.scss',
ionic: 'card-header.md.scss', ionic: 'card-header.ionic.scss',
}, },
shadow: true, shadow: true,
}) })

View File

@ -0,0 +1,11 @@
@use "./card-subtitle.common";
@use "../../themes/ionic/ionic.globals.scss" as globals;
// Ionic Card Subtitle
// --------------------------------------------------
:host {
--color: #{globals.$ionic-color-neutral-800};
@include globals.typography(globals.$ionic-body-lg-regular);
}

View File

@ -1,4 +1,4 @@
@import "./card-subtitle"; @import "./card-subtitle.common";
@import "./card-subtitle.ios.vars"; @import "./card-subtitle.ios.vars";
// iOS Card Subtitle // iOS Card Subtitle

View File

@ -1,4 +1,4 @@
@import "./card-subtitle"; @import "./card-subtitle.common";
@import "./card-subtitle.md.vars"; @import "./card-subtitle.md.vars";
// Material Design Card Subtitle // Material Design Card Subtitle

View File

@ -14,7 +14,7 @@ import type { Color } from '../../interface';
styleUrls: { styleUrls: {
ios: 'card-subtitle.ios.scss', ios: 'card-subtitle.ios.scss',
md: 'card-subtitle.md.scss', md: 'card-subtitle.md.scss',
ionic: 'card-subtitle.md.scss', ionic: 'card-subtitle.ionic.scss',
}, },
shadow: true, shadow: true,
}) })

View File

@ -0,0 +1,11 @@
@use "./card-title.common";
@use "../../themes/ionic/ionic.globals.scss" as globals;
// Ionic Card Title
// --------------------------------------------------
:host {
--color: #{globals.$ionic-color-neutral-1200};
@include globals.typography(globals.$ionic-heading-h5-medium);
}

View File

@ -1,4 +1,5 @@
@import "./card-title"; @import "./card-title.common";
@import "../../themes/native/native.globals";
@import "./card-title.ios.vars"; @import "./card-title.ios.vars";
// iOS Card Title // iOS Card Title

View File

@ -1,4 +1,5 @@
@import "./card-title"; @import "./card-title.common";
@import "../../themes/native/native.globals";
@import "./card-title.md.vars"; @import "./card-title.md.vars";
// Material Design Card Title // Material Design Card Title

View File

@ -1,4 +1,4 @@
@import "../../themes/native/native.globals"; @import "../../themes/mixins";
// Card // Card
// -------------------------------------------------- // --------------------------------------------------
@ -21,8 +21,6 @@
background: var(--background); background: var(--background);
color: var(--color); color: var(--color);
font-family: $font-family-base;
contain: content; contain: content;
overflow: hidden; overflow: hidden;
@ -36,43 +34,6 @@
color: current-color(contrast); color: current-color(contrast);
} }
// Disabled Card
// --------------------------------------------------
:host(.card-disabled) {
cursor: default;
opacity: 0.3;
pointer-events: none;
}
// Native
// --------------------------------------------------
.card-native {
@include text-inherit();
@include padding(0);
@include margin(0);
display: block;
width: 100%;
min-height: var(--min-height);
transition: var(--transition);
border-width: var(--border-width);
border-style: var(--border-style);
border-color: var(--border-color);
outline: none;
background: inherit;
}
.card-native::-moz-focus-inner {
border: 0;
}
button, button,
a { a {
cursor: pointer; cursor: pointer;

View File

@ -1,28 +1,24 @@
@use "../../themes/ionic/ionic.globals.scss" as globals; @use "../../themes/ionic/ionic.globals.scss" as globals;
@import "./card.common";
// Ionic Card // Ionic Card
// -------------------------------------------------- // --------------------------------------------------
:host { :host {
--background: #{globals.$ionic-color-base-white}; --background: #{globals.$ionic-color-base-white};
--border-radius: #{globals.$ionic-border-radius-100}; --border-radius: #{globals.$ionic-border-radius-400};
--color: #{globals.$ionic-color-neutral-1200};
@include globals.padding(globals.$ionic-space-400); }
@include globals.border-radius(var(--border-radius));
::slotted(img) {
display: block; display: block;
border: #{globals.$ionic-border-size-025} solid #{globals.$ionic-color-neutral-500};
background: var(--background);
color: var(--color);
} }
// Card Shapes // Card Shapes
// --------------------------------------------- // ---------------------------------------------
:host(.card-round) { :host(.card-soft) {
--border-radius: #{globals.$ionic-border-radius-400}; --border-radius: #{globals.$ionic-border-radius-200};
} }
:host(.card-rectangular) { :host(.card-rectangular) {

View File

@ -1,4 +1,4 @@
@import "./card"; @import "./card.native";
@import "./card.ios.vars"; @import "./card.ios.vars";
// iOS Card // iOS Card

View File

@ -1,4 +1,4 @@
@import "./card"; @import "./card.native";
@import "./card.md.vars"; @import "./card.md.vars";
// Material Design Card // Material Design Card

View File

@ -0,0 +1,46 @@
@import "../../themes/native/native.globals";
@import "./card.common";
// Card
// --------------------------------------------------
:host {
font-family: $font-family-base;
}
// Disabled Card
// --------------------------------------------------
:host(.card-disabled) {
cursor: default;
opacity: 0.3;
pointer-events: none;
}
// Native
// --------------------------------------------------
.card-native {
@include text-inherit();
@include padding(0);
@include margin(0);
display: block;
width: 100%;
min-height: var(--min-height);
transition: var(--transition);
border-width: var(--border-width);
border-style: var(--border-style);
border-color: var(--border-color);
outline: none;
background: inherit;
}
.card-native::-moz-focus-inner {
border: 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@ -1,6 +1,6 @@
<!-- TODO: FW-6077 This file can be removed once the additional test cases are added --> <!-- TODO: FW-6077 This file can be removed once the additional test cases are added -->
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" dir="ltr"> <html lang="en" dir="ltr" theme="ionic">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Card - Theme Ionic</title> <title>Card - Theme Ionic</title>
@ -8,13 +8,16 @@
name="viewport" name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/> />
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" /> <link href="../../../../../css/ionic/bundle.ionic.css" rel="stylesheet" />
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" /> <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
<script src="../../../../../scripts/testing/scripts.js"></script> <script src="../../../../../scripts/testing/scripts.js"></script>
<script nomodule src="../../../../../dist/ionic/ionic.js"></script> <script nomodule src="../../../../../dist/ionic/ionic.js"></script>
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script> <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
<style> <style>
ion-content {
--background: #dde2ef;
}
.ion-margin-top { .ion-margin-top {
margin-top: 32px; margin-top: 32px;
} }
@ -29,13 +32,13 @@
</ion-toolbar> </ion-toolbar>
</ion-header> </ion-header>
<ion-content class="ion-padding ion-text-center" id="content" no-bounce> <ion-content class="ionic-padding-space-400" id="content" no-bounce>
<h4>Preview options</h4> <h4>Preview options</h4>
<p> <p>
<ion-select id="select-shape" justify="space-between" interface="alert" label="Shape" placeholder=""> <ion-select id="select-shape" justify="space-between" interface="alert" label="Shape" placeholder="">
<ion-select-option value="">default</ion-select-option> <ion-select-option value="round">default (round)</ion-select-option>
<ion-select-option value="round">Round</ion-select-option> <ion-select-option value="soft">soft</ion-select-option>
<ion-select-option value="rectangular">Rectangular</ion-select-option> <ion-select-option value="rectangular">Rectangular</ion-select-option>
</ion-select> </ion-select>
</p> </p>
@ -52,6 +55,34 @@
in the woods. Wash your spirit clean. in the woods. Wash your spirit clean.
</ion-card-content> </ion-card-content>
</ion-card> </ion-card>
<ion-card class="ion-margin-top">
<img alt="Silhouette of mountains" src="https://ionicframework.com/docs/img/demos/card-media.png" />
<ion-card-header>
<ion-card-title>Card Title</ion-card-title>
<ion-card-subtitle>Card Subtitle</ion-card-subtitle>
</ion-card-header>
<ion-card-content>
Here's a small text description for the card content. Nothing more, nothing less.
</ion-card-content>
</ion-card>
<ion-card class="ion-margin-top">
<ion-card-header>
<ion-card-title>Header</ion-card-title>
<ion-card-subtitle>Subtitle</ion-card-subtitle>
</ion-card-header>
<ion-card-content>
Lorem ipsum dolor sit amet consectetur. Lorem sem neque mauris ullamcorper enim. Massa tempus sem ligula
turpis consequat nam et semper imperdiet. Leo praesent ut feugiat cursus est. Lectus morbi aliquam lacus
tellus tempor morbi in pharetra.
<img alt="Silhouette of mountains" src="https://ionicframework.com/docs/img/demos/card-media.png" />
<ion-button fill="outline">Secondary</ion-button>
<ion-button>Primary</ion-button>
</ion-card-content>
</ion-card>
</div> </div>
</ion-content> </ion-content>
</ion-app> </ion-app>