mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 23:58:13 +08:00
Add shape prop to Chip
This commit is contained in:
8
core/src/components.d.ts
vendored
8
core/src/components.d.ts
vendored
@ -750,6 +750,10 @@ export namespace Components {
|
|||||||
* Display an outline style button.
|
* Display an outline style button.
|
||||||
*/
|
*/
|
||||||
"outline": boolean;
|
"outline": boolean;
|
||||||
|
/**
|
||||||
|
* Set to 'rectangular' for a chip with sharp corners.
|
||||||
|
*/
|
||||||
|
"shape"?: 'soft' | 'round' | 'rectangular';
|
||||||
/**
|
/**
|
||||||
* The theme determines the visual appearance of the component.
|
* The theme determines the visual appearance of the component.
|
||||||
*/
|
*/
|
||||||
@ -5978,6 +5982,10 @@ declare namespace LocalJSX {
|
|||||||
* Display an outline style button.
|
* Display an outline style button.
|
||||||
*/
|
*/
|
||||||
"outline"?: boolean;
|
"outline"?: boolean;
|
||||||
|
/**
|
||||||
|
* Set to 'rectangular' for a chip with sharp corners.
|
||||||
|
*/
|
||||||
|
"shape"?: 'soft' | 'round' | 'rectangular';
|
||||||
/**
|
/**
|
||||||
* The theme determines the visual appearance of the component.
|
* The theme determines the visual appearance of the component.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -9,13 +9,14 @@ $ionic-states-focus-primary: #9ec4fd; // TODO(ROU-4870): there is no token yet f
|
|||||||
:host {
|
:host {
|
||||||
--background: #{tokens.$ionic-color-neutral-10};
|
--background: #{tokens.$ionic-color-neutral-10};
|
||||||
--border-color: transparent;
|
--border-color: transparent;
|
||||||
|
--border-radius: #{tokens.$ionic-border-radius-rounded-large};
|
||||||
--color: #{tokens.$ionic-color-neutral-900};
|
--color: #{tokens.$ionic-color-neutral-900};
|
||||||
--focus-ring-color: #{$ionic-states-focus-primary};
|
--focus-ring-color: #{$ionic-states-focus-primary};
|
||||||
--focus-ring-width: #{tokens.$ionic-border-size-medium};
|
--focus-ring-width: #{tokens.$ionic-border-size-medium};
|
||||||
|
|
||||||
@include mixins.font-smoothing;
|
@include mixins.font-smoothing;
|
||||||
@include mixins.padding(tokens.$ionic-space-xs, tokens.$ionic-space-xxs);
|
@include mixins.padding(tokens.$ionic-space-xs, tokens.$ionic-space-xxs);
|
||||||
@include mixins.border-radius(tokens.$ionic-border-radius-rounded-large);
|
@include mixins.border-radius(var(--border-radius));
|
||||||
|
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
|
||||||
@ -75,3 +76,16 @@ $ionic-states-focus-primary: #9ec4fd; // TODO(ROU-4870): there is no token yet f
|
|||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Chip Shapes
|
||||||
|
// ---------------------------------------------
|
||||||
|
|
||||||
|
:host(.chip-soft) {
|
||||||
|
--border-radius: #{tokens.$ionic-border-radius-rounded-small};
|
||||||
|
}
|
||||||
|
:host(.chip-round) {
|
||||||
|
--border-radius: #{tokens.$ionic-border-radius-rounded-large};
|
||||||
|
}
|
||||||
|
:host(.chip-rectangular) {
|
||||||
|
--border-radius: #{tokens.$ionic-border-radius-square};
|
||||||
|
}
|
||||||
|
|||||||
@ -36,7 +36,13 @@ export class Chip implements ComponentInterface {
|
|||||||
*/
|
*/
|
||||||
@Prop() disabled = false;
|
@Prop() disabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to 'rectangular' for a chip with sharp corners.
|
||||||
|
*/
|
||||||
|
@Prop({ reflect: true }) shape?: 'soft' | 'round' | 'rectangular';
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { shape } = this;
|
||||||
const theme = getIonTheme(this);
|
const theme = getIonTheme(this);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -44,6 +50,7 @@ export class Chip implements ComponentInterface {
|
|||||||
aria-disabled={this.disabled ? 'true' : null}
|
aria-disabled={this.disabled ? 'true' : null}
|
||||||
class={createColorClasses(this.color, {
|
class={createColorClasses(this.color, {
|
||||||
[theme]: true,
|
[theme]: true,
|
||||||
|
[`chip-${shape}`]: shape !== undefined,
|
||||||
'chip-outline': this.outline,
|
'chip-outline': this.outline,
|
||||||
'chip-disabled': this.disabled,
|
'chip-disabled': this.disabled,
|
||||||
'ion-activatable': true,
|
'ion-activatable': true,
|
||||||
|
|||||||
@ -50,6 +50,19 @@
|
|||||||
<ion-label>Focus</ion-label>
|
<ion-label>Focus</ion-label>
|
||||||
</ion-chip>
|
</ion-chip>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h3>Shapes</h3>
|
||||||
|
<p>
|
||||||
|
<ion-chip shape="soft">
|
||||||
|
<ion-label>Soft</ion-label>
|
||||||
|
</ion-chip>
|
||||||
|
<ion-chip shape="round">
|
||||||
|
<ion-label>Round</ion-label>
|
||||||
|
</ion-chip>
|
||||||
|
<ion-chip shape="rectangular">
|
||||||
|
<ion-label>Rectangular</ion-label>
|
||||||
|
</ion-chip>
|
||||||
|
</p>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
</ion-app>
|
</ion-app>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user