Skip to content

Commit 805b75a

Browse files
authored
feat(textarea): added highlight and focus styles to ionic theme (#30062)
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. --> - Fixed highlight validation to include ionic theme - Added styles on ionic scss partial for focus and highlight - Added focus state test to textarea ## 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. --> - Textarea [basic sample](https://ionic-framework-git-rou-11444-ionic1.vercel.app/src/components/textarea/test/basic?ionic:theme=ionic)
1 parent 826e7e2 commit 805b75a

File tree

7 files changed

+60
-1
lines changed

7 files changed

+60
-1
lines changed

core/src/components/textarea/test/states/textarea.e2e.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,21 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
2828
});
2929
});
3030
});
31+
32+
configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
33+
test.describe(title('focused'), () => {
34+
test('should render focused textarea correctly', async ({ page }) => {
35+
await page.setContent(
36+
`
37+
<div class="container ion-padding">
38+
<ion-textarea fill="outline" value="[email protected]" class="has-focus"></ion-textarea>
39+
</div>
40+
`,
41+
config
42+
);
43+
44+
const container = page.locator('.container');
45+
await expect(container).toHaveScreenshot(screenshot(`textarea-focused`));
46+
});
47+
});
48+
});
2.84 KB
Loading
4.46 KB
Loading
2.79 KB
Loading

core/src/components/textarea/textarea.ionic.outline.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,10 @@
5959
:host(.textarea-fill-outline) textarea {
6060
margin-top: globals.$ion-space-100;
6161
}
62+
63+
// Input Focus
64+
// ----------------------------------------------------------------
65+
66+
:host(.textarea-fill-outline.has-focus) {
67+
--border-width: #{globals.$ion-border-size-050};
68+
}

core/src/components/textarea/textarea.ionic.scss

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,37 @@ ion-icon {
132132
.textarea-bottom .counter {
133133
color: globals.$ion-primitives-neutral-800;
134134
}
135+
136+
:host(.has-focus.ion-valid),
137+
:host(.ion-touched.ion-invalid) {
138+
--border-width: #{globals.$ion-border-size-025};
139+
}
140+
141+
// Textarea Highlight
142+
// ----------------------------------------------------------------
143+
144+
.textarea-highlight {
145+
@include globals.position(null, null, -1px, 0);
146+
147+
position: absolute;
148+
149+
width: 100%;
150+
height: globals.$ion-border-size-050;
151+
152+
transform: scale(0);
153+
154+
transition: transform globals.$ion-transition-time-200;
155+
156+
background: var(--border-color);
157+
}
158+
159+
// Textarea Focus
160+
// ----------------------------------------------------------------
161+
162+
:host(.has-focus) {
163+
--border-color: #{globals.$ion-border-focus-default};
164+
}
165+
166+
:host(.has-focus) .textarea-highlight {
167+
transform: scale(1);
168+
}

core/src/components/textarea/textarea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ export class Textarea implements ComponentInterface {
670670
const shape = this.getShape();
671671
const value = this.getValue();
672672
const inItem = hostContext('ion-item', this.el);
673-
const shouldRenderHighlight = theme === 'md' && fill !== 'outline' && !inItem;
673+
const shouldRenderHighlight = (theme === 'md' || theme === 'ionic') && fill !== 'outline' && !inItem;
674674

675675
const hasValue = this.hasValue();
676676
const hasStartEndSlots = el.querySelector('[slot="start"], [slot="end"]') !== null;

0 commit comments

Comments
 (0)