| 26 | shadow: true, |
| 27 | }) |
| 28 | export class BackButton implements ComponentInterface, ButtonInterface { |
| 29 | private inheritedAttributes: Attributes = {}; |
| 30 | |
| 31 | @Element() el!: HTMLElement; |
| 32 | |
| 33 | /** |
| 34 | * The color to use from your application's color palette. |
| 35 | * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. |
| 36 | * For more information on colors, see [theming](/docs/theming/basics). |
| 37 | */ |
| 38 | @Prop({ reflect: true }) color?: Color; |
| 39 | |
| 40 | /** |
| 41 | * The url to navigate back to by default when there is no history. |
| 42 | */ |
| 43 | @Prop({ mutable: true }) defaultHref?: string; |
| 44 | |
| 45 | /** |
| 46 | * If `true`, the user cannot interact with the button. |
| 47 | */ |
| 48 | @Prop({ reflect: true }) disabled = false; |
| 49 | |
| 50 | /** |
| 51 | * The built-in named SVG icon name or the exact `src` of an SVG file |
| 52 | * to use for the back button. |
| 53 | */ |
| 54 | @Prop() icon?: string | null; |
| 55 | |
| 56 | /** |
| 57 | * The text to display in the back button. |
| 58 | */ |
| 59 | @Prop() text?: string | null; |
| 60 | |
| 61 | /** |
| 62 | * The type of the button. |
| 63 | */ |
| 64 | @Prop() type: 'submit' | 'reset' | 'button' = 'button'; |
| 65 | |
| 66 | /** |
| 67 | * When using a router, it specifies the transition animation when navigating to |
| 68 | * another page. |
| 69 | */ |
| 70 | @Prop() routerAnimation: AnimationBuilder | undefined; |
| 71 | |
| 72 | componentWillLoad() { |
| 73 | this.inheritedAttributes = inheritAriaAttributes(this.el); |
| 74 | |
| 75 | if (this.defaultHref === undefined) { |
| 76 | this.defaultHref = config.get('backButtonDefaultHref'); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | get backButtonIcon() { |
| 81 | const icon = this.icon; |
| 82 | if (icon != null) { |
| 83 | // icon is set on the component or by the config |
| 84 | return icon; |
| 85 | } |