mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Compare commits
2 Commits
FW-6830
...
build-test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba2a3b80c1 | ||
|
|
e29d8e6bae |
@@ -1,6 +1,8 @@
|
||||
@import "./chip";
|
||||
@use "./chip" as b;
|
||||
@import "./chip.vars";
|
||||
|
||||
@include b.base;
|
||||
|
||||
:host {
|
||||
/**
|
||||
* Main content should be prioritized on iOS,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@import "./chip";
|
||||
@import "./chip.vars";
|
||||
|
||||
:host {
|
||||
font-size: $chip-base-font-size-rem;
|
||||
@mixin md2 {
|
||||
:host {
|
||||
font-size: $chip-base-font-size-rem;
|
||||
}
|
||||
}
|
||||
|
||||
9
core/src/components/chip/chip.md2.flag.scss
Normal file
9
core/src/components/chip/chip.md2.flag.scss
Normal file
@@ -0,0 +1,9 @@
|
||||
@use 'chip.md.scss' as c;
|
||||
@use 'chip.scss' as b;
|
||||
|
||||
@use '../../utils/md-controller/index.scss' as controller;
|
||||
|
||||
@if controller.$md2 {
|
||||
@include b.base;
|
||||
@include c.md2;
|
||||
}
|
||||
9
core/src/components/chip/chip.md3.flag.scss
Normal file
9
core/src/components/chip/chip.md3.flag.scss
Normal file
@@ -0,0 +1,9 @@
|
||||
@use 'chip.md3.scss' as c;
|
||||
@use 'chip.scss' as b;
|
||||
|
||||
@use '../../utils/md-controller/index.scss' as controller;
|
||||
|
||||
@if controller.$md3 {
|
||||
@include b.base;
|
||||
@include c.md3;
|
||||
}
|
||||
7
core/src/components/chip/chip.md3.scss
Normal file
7
core/src/components/chip/chip.md3.scss
Normal file
@@ -0,0 +1,7 @@
|
||||
@import "./chip.vars";
|
||||
|
||||
@mixin md3 {
|
||||
:host {
|
||||
background: green;
|
||||
}
|
||||
}
|
||||
@@ -1,156 +1,158 @@
|
||||
@import "../../themes/ionic.globals";
|
||||
@import "./chip.vars";
|
||||
|
||||
:host {
|
||||
/**
|
||||
* @prop --background: Background of the chip
|
||||
* @prop --color: Color of the chip
|
||||
*/
|
||||
--background: #{rgba($text-color-rgb, 0.12)};
|
||||
--color: #{rgba($text-color-rgb, 0.87)};
|
||||
@mixin base {
|
||||
:host {
|
||||
/**
|
||||
* @prop --background: Background of the chip
|
||||
* @prop --color: Color of the chip
|
||||
*/
|
||||
--background: #{rgba($text-color-rgb, 0.12)};
|
||||
--color: #{rgba($text-color-rgb, 0.87)};
|
||||
|
||||
@include border-radius(16px);
|
||||
@include font-smoothing();
|
||||
@include margin(4px);
|
||||
@include padding(6px, 12px);
|
||||
@include border-radius(16px);
|
||||
@include font-smoothing();
|
||||
@include margin(4px);
|
||||
@include padding(6px, 12px);
|
||||
|
||||
display: inline-flex;
|
||||
display: inline-flex;
|
||||
|
||||
position: relative;
|
||||
position: relative;
|
||||
|
||||
align-items: center;
|
||||
align-items: center;
|
||||
|
||||
min-height: 32px;
|
||||
min-height: 32px;
|
||||
|
||||
background: var(--background);
|
||||
color: var(--color);
|
||||
background: var(--background);
|
||||
color: var(--color);
|
||||
|
||||
font-family: $font-family-base;
|
||||
font-family: $font-family-base;
|
||||
|
||||
cursor: pointer;
|
||||
cursor: pointer;
|
||||
|
||||
overflow: hidden;
|
||||
overflow: hidden;
|
||||
|
||||
vertical-align: middle;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:host(.chip-disabled) {
|
||||
cursor: default;
|
||||
opacity: 0.4;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
// Chip Colors
|
||||
// ---------------------------------------------
|
||||
|
||||
:host(.ion-color) {
|
||||
background: current-color(base, 0.08);
|
||||
color: current-color(shade);
|
||||
}
|
||||
|
||||
:host(.ion-color:focus) {
|
||||
background: current-color(base, 0.12);
|
||||
}
|
||||
|
||||
:host(.ion-color.ion-activated) {
|
||||
background: current-color(base, 0.16);
|
||||
}
|
||||
|
||||
// Outline Chip
|
||||
// ---------------------------------------------
|
||||
|
||||
:host(.chip-outline) {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
:host(.chip-outline) {
|
||||
border-color: rgba($text-color-rgb, 0.32);
|
||||
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:host(.chip-outline.ion-color) {
|
||||
border-color: current-color(base, 0.32);
|
||||
}
|
||||
|
||||
:host(.chip-outline:not(.ion-color):focus) {
|
||||
background: rgba($text-color-rgb, 0.04);
|
||||
}
|
||||
|
||||
:host(.chip-outline.ion-activated:not(.ion-color)) {
|
||||
background: rgba($text-color-rgb, 0.08);
|
||||
}
|
||||
|
||||
// Chip Icon
|
||||
// ---------------------------------------------
|
||||
|
||||
::slotted(ion-icon) {
|
||||
font-size: $chip-icon-size;
|
||||
}
|
||||
|
||||
:host(:not(.ion-color)) ::slotted(ion-icon) {
|
||||
color: rgba($text-color-rgb, 0.54);
|
||||
}
|
||||
|
||||
::slotted(ion-icon:first-child) {
|
||||
@include margin(-4px, 8px, -4px, -4px);
|
||||
}
|
||||
|
||||
::slotted(ion-icon:last-child) {
|
||||
@include margin(-4px, -4px, -4px, 8px);
|
||||
}
|
||||
|
||||
// Chip Avatar
|
||||
// ---------------------------------------------
|
||||
|
||||
::slotted(ion-avatar) {
|
||||
flex-shrink: 0;
|
||||
|
||||
width: $chip-avatar-size;
|
||||
height: $chip-avatar-size;
|
||||
}
|
||||
|
||||
::slotted(ion-avatar:first-child) {
|
||||
@include margin(-4px, 8px, -4px, -8px);
|
||||
}
|
||||
|
||||
::slotted(ion-avatar:last-child) {
|
||||
@include margin(-4px, -8px, -4px, 8px);
|
||||
}
|
||||
|
||||
// Chip: Focus
|
||||
// ---------------------------------------------
|
||||
|
||||
:host(:focus) {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
:host(:focus) {
|
||||
--background: #{rgba($text-color-rgb, 0.16)};
|
||||
}
|
||||
|
||||
// Chip: Activated
|
||||
// ---------------------------------------------
|
||||
|
||||
:host(.ion-activated) {
|
||||
--background: #{rgba($text-color-rgb, 0.2)};
|
||||
}
|
||||
|
||||
// Chip: Hover
|
||||
// ---------------------------------------------
|
||||
|
||||
@media (any-hover: hover) {
|
||||
:host(:hover) {
|
||||
--background: #{rgba($text-color-rgb, 0.16)};
|
||||
vertical-align: middle;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:host(.ion-color:hover) {
|
||||
:host(.chip-disabled) {
|
||||
cursor: default;
|
||||
opacity: 0.4;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
// Chip Colors
|
||||
// ---------------------------------------------
|
||||
|
||||
:host(.ion-color) {
|
||||
background: current-color(base, 0.08);
|
||||
color: current-color(shade);
|
||||
}
|
||||
|
||||
:host(.ion-color:focus) {
|
||||
background: current-color(base, 0.12);
|
||||
}
|
||||
|
||||
:host(.chip-outline:not(.ion-color):hover) {
|
||||
:host(.ion-color.ion-activated) {
|
||||
background: current-color(base, 0.16);
|
||||
}
|
||||
|
||||
// Outline Chip
|
||||
// ---------------------------------------------
|
||||
|
||||
:host(.chip-outline) {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
:host(.chip-outline) {
|
||||
border-color: rgba($text-color-rgb, 0.32);
|
||||
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:host(.chip-outline.ion-color) {
|
||||
border-color: current-color(base, 0.32);
|
||||
}
|
||||
|
||||
:host(.chip-outline:not(.ion-color):focus) {
|
||||
background: rgba($text-color-rgb, 0.04);
|
||||
}
|
||||
|
||||
:host(.chip-outline.ion-activated:not(.ion-color)) {
|
||||
background: rgba($text-color-rgb, 0.08);
|
||||
}
|
||||
|
||||
// Chip Icon
|
||||
// ---------------------------------------------
|
||||
|
||||
::slotted(ion-icon) {
|
||||
font-size: $chip-icon-size;
|
||||
}
|
||||
|
||||
:host(:not(.ion-color)) ::slotted(ion-icon) {
|
||||
color: rgba($text-color-rgb, 0.54);
|
||||
}
|
||||
|
||||
::slotted(ion-icon:first-child) {
|
||||
@include margin(-4px, 8px, -4px, -4px);
|
||||
}
|
||||
|
||||
::slotted(ion-icon:last-child) {
|
||||
@include margin(-4px, -4px, -4px, 8px);
|
||||
}
|
||||
|
||||
// Chip Avatar
|
||||
// ---------------------------------------------
|
||||
|
||||
::slotted(ion-avatar) {
|
||||
flex-shrink: 0;
|
||||
|
||||
width: $chip-avatar-size;
|
||||
height: $chip-avatar-size;
|
||||
}
|
||||
|
||||
::slotted(ion-avatar:first-child) {
|
||||
@include margin(-4px, 8px, -4px, -8px);
|
||||
}
|
||||
|
||||
::slotted(ion-avatar:last-child) {
|
||||
@include margin(-4px, -8px, -4px, 8px);
|
||||
}
|
||||
|
||||
// Chip: Focus
|
||||
// ---------------------------------------------
|
||||
|
||||
:host(:focus) {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
:host(:focus) {
|
||||
--background: #{rgba($text-color-rgb, 0.16)};
|
||||
}
|
||||
|
||||
// Chip: Activated
|
||||
// ---------------------------------------------
|
||||
|
||||
:host(.ion-activated) {
|
||||
--background: #{rgba($text-color-rgb, 0.2)};
|
||||
}
|
||||
|
||||
// Chip: Hover
|
||||
// ---------------------------------------------
|
||||
|
||||
@media (any-hover: hover) {
|
||||
:host(:hover) {
|
||||
--background: #{rgba($text-color-rgb, 0.16)};
|
||||
}
|
||||
|
||||
:host(.ion-color:hover) {
|
||||
background: current-color(base, 0.12);
|
||||
}
|
||||
|
||||
:host(.chip-outline:not(.ion-color):hover) {
|
||||
background: rgba($text-color-rgb, 0.04);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,14 @@ import { createColorClasses } from '@utils/theme';
|
||||
import { getIonMode } from '../../global/ionic-global';
|
||||
import type { Color } from '../../interface';
|
||||
|
||||
/**
|
||||
styleUrls: {
|
||||
ios: 'chip.ios.scss',
|
||||
md: 'chip.md2.scss',
|
||||
md3: Build.isDev ? 'chip.md3.scss' : undefined
|
||||
},
|
||||
*/
|
||||
|
||||
/**
|
||||
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
|
||||
*/
|
||||
@@ -12,7 +20,8 @@ import type { Color } from '../../interface';
|
||||
tag: 'ion-chip',
|
||||
styleUrls: {
|
||||
ios: 'chip.ios.scss',
|
||||
md: 'chip.md.scss',
|
||||
md: 'chip.md2.flag.scss',
|
||||
md3: 'chip.md3.flag.scss'
|
||||
},
|
||||
shadow: true,
|
||||
})
|
||||
|
||||
@@ -23,82 +23,19 @@
|
||||
</ion-header>
|
||||
|
||||
<ion-content class="ion-padding" id="content" style="text-align: center">
|
||||
<h2>Basic Chips</h2>
|
||||
<h2>Default Chip</h2>
|
||||
<ion-chip>
|
||||
<ion-label>Default</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip style="border-radius: 4px">
|
||||
<ion-label>Border Radius</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip>
|
||||
<ion-icon name="checkmark-circle"></ion-icon>
|
||||
<ion-label>With Icon</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip>
|
||||
<ion-avatar>
|
||||
<img
|
||||
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjYzVkYmZmIiBkPSJNMCAwaDUxMnY1MTJIMHoiLz48cGF0aCBkPSJNMjU2IDMwNGM2MS42IDAgMTEyLTUwLjQgMTEyLTExMlMzMTcuNiA4MCAyNTYgODBzLTExMiA1MC40LTExMiAxMTIgNTAuNCAxMTIgMTEyIDExMnptMCA0MGMtNzQuMiAwLTIyNCAzNy44LTIyNCAxMTJ2NTZoNDQ4di01NmMwLTc0LjItMTQ5LjgtMTEyLTIyNC0xMTJ6IiBmaWxsPSIjODJhZWZmIi8+PC9zdmc+"
|
||||
/>
|
||||
</ion-avatar>
|
||||
<ion-label>With Avatar</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip>
|
||||
<ion-avatar>
|
||||
<img
|
||||
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjYzVkYmZmIiBkPSJNMCAwaDUxMnY1MTJIMHoiLz48cGF0aCBkPSJNMjU2IDMwNGM2MS42IDAgMTEyLTUwLjQgMTEyLTExMlMzMTcuNiA4MCAyNTYgODBzLTExMiA1MC40LTExMiAxMTIgNTAuNCAxMTIgMTEyIDExMnptMCA0MGMtNzQuMiAwLTIyNCAzNy44LTIyNCAxMTJ2NTZoNDQ4di01NmMwLTc0LjItMTQ5LjgtMTEyLTIyNC0xMTJ6IiBmaWxsPSIjODJhZWZmIi8+PC9zdmc+"
|
||||
/>
|
||||
</ion-avatar>
|
||||
<ion-label>With Icon and Avatar</ion-label>
|
||||
<ion-icon name="close-circle"></ion-icon>
|
||||
|
||||
<h2>MD2 Chip</h2>
|
||||
<ion-chip mode="md">
|
||||
<ion-label>MD2</ion-label>
|
||||
</ion-chip>
|
||||
|
||||
<h2>Color Chips</h2>
|
||||
<ion-chip color="primary">
|
||||
<ion-label>Primary</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip color="danger">
|
||||
<ion-label>Danger</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip color="tertiary">
|
||||
<ion-icon name="checkmark-circle"></ion-icon>
|
||||
<ion-label>Tertiary with Icon</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip color="primary">
|
||||
<ion-avatar>
|
||||
<img
|
||||
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjYzVkYmZmIiBkPSJNMCAwaDUxMnY1MTJIMHoiLz48cGF0aCBkPSJNMjU2IDMwNGM2MS42IDAgMTEyLTUwLjQgMTEyLTExMlMzMTcuNiA4MCAyNTYgODBzLTExMiA1MC40LTExMiAxMTIgNTAuNCAxMTIgMTEyIDExMnptMCA0MGMtNzQuMiAwLTIyNCAzNy44LTIyNCAxMTJ2NTZoNDQ4di01NmMwLTc0LjItMTQ5LjgtMTEyLTIyNC0xMTJ6IiBmaWxsPSIjODJhZWZmIi8+PC9zdmc+"
|
||||
/>
|
||||
</ion-avatar>
|
||||
<ion-label>Primary with Avatar</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip color="success">
|
||||
<ion-label>Success with Icon</ion-label>
|
||||
<ion-icon name="calendar"></ion-icon>
|
||||
</ion-chip>
|
||||
|
||||
<h2>Outline Chips</h2>
|
||||
<ion-chip outline>
|
||||
<ion-label>Outline</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip outline color="danger">
|
||||
<ion-label>Danger Outline</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip outline color="secondary">
|
||||
<ion-icon name="checkmark-circle"></ion-icon>
|
||||
<ion-label>Secondary Outline with Icon</ion-label>
|
||||
</ion-chip>
|
||||
<ion-chip outline color="primary">
|
||||
<ion-label>Primary Outline with Avatar</ion-label>
|
||||
<ion-avatar>
|
||||
<img
|
||||
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjYzVkYmZmIiBkPSJNMCAwaDUxMnY1MTJIMHoiLz48cGF0aCBkPSJNMjU2IDMwNGM2MS42IDAgMTEyLTUwLjQgMTEyLTExMlMzMTcuNiA4MCAyNTYgODBzLTExMiA1MC40LTExMiAxMTIgNTAuNCAxMTIgMTEyIDExMnptMCA0MGMtNzQuMiAwLTIyNCAzNy44LTIyNCAxMTJ2NTZoNDQ4di01NmMwLTc0LjItMTQ5LjgtMTEyLTIyNC0xMTJ6IiBmaWxsPSIjODJhZWZmIi8+PC9zdmc+"
|
||||
/>
|
||||
</ion-avatar>
|
||||
</ion-chip>
|
||||
<ion-chip outline>
|
||||
<ion-icon name="git-pull-request"></ion-icon>
|
||||
<ion-label>Outline with Icon and Avatar</ion-label>
|
||||
<ion-icon name="close-circle"></ion-icon>
|
||||
<h2>MD3 Chip</h2>
|
||||
<ion-chip mode="md3">
|
||||
<ion-label>MD3</ion-label>
|
||||
</ion-chip>
|
||||
</ion-content>
|
||||
</ion-app>
|
||||
|
||||
@@ -70,7 +70,7 @@ export const initialize = (userConfig: IonicConfig = {}) => {
|
||||
|
||||
const isIonicElement = (elm: any) => elm.tagName?.startsWith('ION-');
|
||||
|
||||
const isAllowedIonicModeValue = (elmMode: string) => ['ios', 'md'].includes(elmMode);
|
||||
const isAllowedIonicModeValue = (elmMode: string) => ['ios', 'md', 'md3'].includes(elmMode);
|
||||
|
||||
setMode((elm: any) => {
|
||||
while (elm) {
|
||||
|
||||
2
core/src/utils/md-controller/index.scss
Normal file
2
core/src/utils/md-controller/index.scss
Normal file
@@ -0,0 +1,2 @@
|
||||
$md2: true;
|
||||
$md3: false;
|
||||
Reference in New Issue
Block a user