Skip to content

Commit 4a6bcab

Browse files
authored
feat(segment): add missing focus state on segment for Ionic theme (#30074)
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)
1 parent fec23e8 commit 4a6bcab

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

core/src/components/segment-button/segment-button.ionic.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@
7979
color: var(--color-disabled);
8080
}
8181

82+
// Segment Button: Focused
83+
// --------------------------------------------------
84+
85+
:host(.ion-focused) .button-inner {
86+
@include globals.focused-state();
87+
}
88+
8289
// Segment Button: Indicator
8390
// --------------------------------------------------
8491

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { expect } from '@playwright/test';
2+
import { configs, test } from '@utils/test/playwright';
3+
4+
configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
5+
test.describe(title('segment: states'), () => {
6+
test('should render focused segment correctly', async ({ page }) => {
7+
await page.setContent(
8+
`
9+
<ion-segment value="2">
10+
<ion-segment-button value="1">
11+
<ion-label>Bookmarks</ion-label>
12+
</ion-segment-button>
13+
<ion-segment-button class="ion-focused" value="2">
14+
<ion-label>Reading List</ion-label>
15+
</ion-segment-button>
16+
<ion-segment-button value="3">
17+
<ion-label>Shared Links</ion-label>
18+
</ion-segment-button>
19+
</ion-segment>
20+
`,
21+
config
22+
);
23+
24+
const segment = page.locator('ion-segment');
25+
26+
await expect(segment).toHaveScreenshot(screenshot(`segment-focused`));
27+
});
28+
});
29+
});
4.39 KB
Loading
5.04 KB
Loading
3.85 KB
Loading

0 commit comments

Comments
 (0)