Skip to content

Commit

Permalink
feat(segment): add missing focus state on segment for Ionic theme (#3…
Browse files Browse the repository at this point in the history
…0074)

Issue number: internal

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

This is part of a bigger task to add focus styles on all components that
need them on Ionic Theme. A separate PR will be done for each component.

- Added new focus styles for segment on Ionic theme.
- Added new state test and snapshots.
- UI is slightly different from Figma, but t was discussed and aligned
with UX/UI.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

- [Ionic Segment
Focus](https://ionic-framework-ixz97yf70-ionic1.vercel.app/src/components/segment/test/a11y?ionic:theme=ionic)
  • Loading branch information
BenOsodrac authored Dec 12, 2024
1 parent fec23e8 commit 4a6bcab
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/components/segment-button/segment-button.ionic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
color: var(--color-disabled);
}

// Segment Button: Focused
// --------------------------------------------------

:host(.ion-focused) .button-inner {
@include globals.focused-state();
}

// Segment Button: Indicator
// --------------------------------------------------

Expand Down
29 changes: 29 additions & 0 deletions core/src/components/segment/test/states/segment.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';

configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('segment: states'), () => {
test('should render focused segment correctly', async ({ page }) => {
await page.setContent(
`
<ion-segment value="2">
<ion-segment-button value="1">
<ion-label>Bookmarks</ion-label>
</ion-segment-button>
<ion-segment-button class="ion-focused" value="2">
<ion-label>Reading List</ion-label>
</ion-segment-button>
<ion-segment-button value="3">
<ion-label>Shared Links</ion-label>
</ion-segment-button>
</ion-segment>
`,
config
);

const segment = page.locator('ion-segment');

await expect(segment).toHaveScreenshot(screenshot(`segment-focused`));
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4a6bcab

Please sign in to comment.