mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
import { Component, Element, Prop } from '@stencil/core';
|
|
|
|
import { Color, Mode } from '../../interface';
|
|
import { createColorClasses } from '../../utils/theme';
|
|
|
|
@Component({
|
|
tag: 'ion-chip-button',
|
|
styleUrl: 'chip-button.scss',
|
|
shadow: true
|
|
})
|
|
export class ChipButton {
|
|
@Element() el!: HTMLElement;
|
|
|
|
/**
|
|
* The color to use from your application's color palette.
|
|
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
|
|
* For more information on colors, see [theming](/docs/theming/basics).
|
|
*/
|
|
@Prop() color?: Color;
|
|
|
|
/**
|
|
* The mode determines which platform styles to use.
|
|
* Possible values are: `"ios"` or `"md"`.
|
|
*/
|
|
@Prop() mode!: Mode;
|
|
|
|
/**
|
|
* If true, the user cannot interact with the chip button. Defaults to `false`.
|
|
*/
|
|
@Prop() disabled = false;
|
|
|
|
/**
|
|
* Set to `"clear"` for a transparent button or to `"solid"` for a filled background.
|
|
* Defaults to `"clear"`.
|
|
*/
|
|
@Prop() fill: 'clear' | 'solid' = 'clear';
|
|
|
|
/**
|
|
* Contains a URL or a URL fragment that the hyperlink points to.
|
|
* If this property is set, an anchor tag will be rendered.
|
|
*/
|
|
@Prop() href?: string;
|
|
|
|
hostData() {
|
|
return {
|
|
class: {
|
|
...createColorClasses(this.color),
|
|
[`chip-button-${this.fill}`]: true
|
|
}
|
|
};
|
|
}
|
|
|
|
render() {
|
|
const TagType = this.href ? 'a' : 'button';
|
|
|
|
return (
|
|
<TagType
|
|
type="button"
|
|
class="chip-button-native"
|
|
disabled={this.disabled}
|
|
href={this.href}>
|
|
<span class="chip-button-inner">
|
|
<slot></slot>
|
|
</span>
|
|
{ this.mode === 'md' && <ion-ripple-effect tapClick={true}/> }
|
|
</TagType>
|
|
);
|
|
}
|
|
}
|