Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 13.3k
feat(button): add circular shape as round#29161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
b02881f59621b9233a05676d7f45bea547b8be455c43269c528748986fd9fdd6faac2fb2ee732dce3c20e3682d6c8289367edaf5c233a9519f3d1b12e6a5315384747919301ab3b61f0f44ceeeb58a4e273aa34eae86371aa02181de5ab7caee9c7b0f7febf2029f80fa6f783File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import type { ComponentInterface, EventEmitter } from '@stencil/core'; | ||
| import { Component, Element, Event, Host, Prop, Watch, h } from '@stencil/core'; | ||
| import { Component, Element, Event, Host, Prop, Watch, State, h } from '@stencil/core'; | ||
| import type { AnchorInterface, ButtonInterface } from '@utils/element-interface'; | ||
| import type { Attributes } from '@utils/helpers'; | ||
| import { inheritAriaAttributes, hasShadowDom } from '@utils/helpers'; | ||
| @@ -38,6 +38,11 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf | ||
| @Element() el!: HTMLElement; | ||
| /** | ||
| * If `true`, the button only has an icon. | ||
| */ | ||
| @State() isCircle: boolean = false; | ||
| /** | ||
| * The color to use from your application's color palette. | ||
| * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. | ||
| @@ -295,6 +300,18 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf | ||
| this.ionBlur.emit(); | ||
| }; | ||
| private slotChanged = () => { | ||
| /** | ||
| * Ensures that the 'has-icon-only' class is properly added | ||
| * or removed from `ion-button` when manipulating the | ||
| * `icon-only` slot. | ||
| * | ||
| * Without this, the 'has-icon-only' class is only checked | ||
| * or added when `ion-button` component first renders. | ||
| */ | ||
| this.isCircle = this.hasIconOnly; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ~ We should explain that we are using a state variable to trigger a re-render of the Stencil component when the slotted content changes, so that I think moving that documentation here to enable the earlier documentation to be more focused on what | ||
| }; | ||
| render() { | ||
| const mode = getIonMode(this); | ||
| const { | ||
| @@ -374,7 +391,7 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf | ||
| {...inheritedAttributes} | ||
| > | ||
| <span class="button-inner"> | ||
| <slot name="icon-only"></slot> | ||
| <slot name="icon-only" onSlotchange={this.slotChanged}></slot> | ||
| <slot name="start"></slot> | ||
| <slot></slot> | ||
| <slot name="end"></slot> | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the correct value for the large icon only button? The icon is set to ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking into this now ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brandyscarney this is correct. The large button has a |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -6,12 +6,64 @@ import { configs, test } from '@utils/test/playwright'; | ||
| */ | ||
| configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||
| test.describe(title('button: round'), () => { | ||
| test('should not have visual regressions', async ({ page }) => { | ||
| await page.goto(`/src/components/button/test/round`, config); | ||
| test.describe('default', () => { | ||
| test('should not have visual regressions', async ({ page }) => { | ||
| await page.goto(`/src/components/button/test/round`, config); | ||
| await page.setIonViewport(); | ||
| await page.setIonViewport(); | ||
| await expect(page).toHaveScreenshot(screenshot(`button-round`)); | ||
| const container = page.locator('#default'); | ||
| await expect(container).toHaveScreenshot(screenshot(`button-round`)); | ||
| }); | ||
| }); | ||
| test.describe('outline', () => { | ||
| test('should not have visual regressions', async ({ page }) => { | ||
| await page.goto(`/src/components/button/test/round`, config); | ||
| await page.setIonViewport(); | ||
| const container = page.locator('#outline'); | ||
| await expect(container).toHaveScreenshot(screenshot(`button-outline-round`)); | ||
| }); | ||
| }); | ||
| test.describe('clear', () => { | ||
| test('should not have visual regressions', async ({ page }) => { | ||
| await page.goto(`/src/components/button/test/round`, config); | ||
| await page.setIonViewport(); | ||
| const container = page.locator('#clear'); | ||
thetaPC marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| await expect(container).toHaveScreenshot(screenshot(`button-clear-round`)); | ||
| }); | ||
| }); | ||
| test.describe('color', () => { | ||
| test('should not have visual regressions', async ({ page }) => { | ||
| await page.goto(`/src/components/button/test/round`, config); | ||
| await page.setIonViewport(); | ||
| const container = page.locator('#color'); | ||
| await expect(container).toHaveScreenshot(screenshot(`button-color-round`)); | ||
| }); | ||
| }); | ||
| test.describe('expand', () => { | ||
| test('should not have visual regressions', async ({ page }) => { | ||
| await page.goto(`/src/components/button/test/round`, config); | ||
| await page.setIonViewport(); | ||
| const container = page.locator('#expand'); | ||
| await expect(container).toHaveScreenshot(screenshot(`button-expand-round`)); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed since the font size is being overwritten through their respective mode files.