mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
feat(input): add the readonly styles for the ionic theme (#29483)
Issue number: internal --------- ## What is the current behavior? There are no custom styles when readonly is added to an input. ## What is the new behavior? - Applies an `input-readonly` class when the `readonly` property is `true` - Styles the class in the `ionic` theme to match the design requirements for readonly inputs - Adds screenshot tests for the readonly style for an unset `fill` and `"outline"` fill ## Does this introduce a breaking change? - [ ] Yes - [x] No
This commit is contained in:
@ -7,6 +7,8 @@
|
||||
// --------------------------------------------------
|
||||
|
||||
:host {
|
||||
// TODO(ROU-5477): use design token here when it is added
|
||||
--color: #121212;
|
||||
--border-width: #{$ionic-border-size-small};
|
||||
--border-color: #{$ionic-color-neutral-300};
|
||||
--highlight-color-valid: #{$ionic-color-success-400};
|
||||
@ -178,6 +180,13 @@
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
// Input - Readonly
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
:host(.input-readonly) {
|
||||
--background: #{tokens.$ionic-color-neutral-10};
|
||||
}
|
||||
|
||||
// Input Highlight
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
|
||||
@ -808,6 +808,7 @@ export class Input implements ComponentInterface {
|
||||
'in-item': inItem,
|
||||
'in-item-color': hostContext('ion-item.ion-color', this.el),
|
||||
'input-disabled': disabled,
|
||||
'input-readonly': readonly,
|
||||
})}
|
||||
>
|
||||
{/**
|
||||
|
||||
@ -50,7 +50,28 @@
|
||||
<div class="grid-item">
|
||||
<h2>No Fill</h2>
|
||||
|
||||
<ion-input label="Email" value="hi@ionic.io" readonly="true"></ion-input>
|
||||
<ion-input
|
||||
label="Email"
|
||||
value="hi@ionic.io"
|
||||
helper-text="Enter an email"
|
||||
counter="true"
|
||||
maxlength="20"
|
||||
readonly="true"
|
||||
></ion-input>
|
||||
</div>
|
||||
|
||||
<div class="grid-item">
|
||||
<h2>Outline</h2>
|
||||
|
||||
<ion-input
|
||||
fill="outline"
|
||||
label="Email"
|
||||
value="hi@ionic.io"
|
||||
helper-text="Enter an email"
|
||||
counter="true"
|
||||
maxlength="20"
|
||||
readonly="true"
|
||||
></ion-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -175,5 +175,54 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh
|
||||
await expect(container).toHaveScreenshot(screenshot(`input-focused`));
|
||||
});
|
||||
});
|
||||
|
||||
test.describe(title('readonly'), () => {
|
||||
test.describe(title('no fill'), () => {
|
||||
test('should render readonly input correctly', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<div class="container">
|
||||
<ion-input
|
||||
label="Email"
|
||||
value="hi@ionic.io"
|
||||
helper-text="Enter an email"
|
||||
counter="true"
|
||||
maxlength="20"
|
||||
readonly="true"
|
||||
></ion-input>
|
||||
</div>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const container = page.locator('.container');
|
||||
await expect(container).toHaveScreenshot(screenshot(`input-readonly-no-fill`));
|
||||
});
|
||||
});
|
||||
|
||||
test.describe(title('outline'), () => {
|
||||
test('should render readonly input correctly', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<div class="container">
|
||||
<ion-input
|
||||
fill="outline"
|
||||
label="Email"
|
||||
value="hi@ionic.io"
|
||||
helper-text="Enter an email"
|
||||
counter="true"
|
||||
maxlength="20"
|
||||
readonly="true"
|
||||
></ion-input>
|
||||
</div>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const container = page.locator('.container');
|
||||
await expect(container).toHaveScreenshot(screenshot(`input-readonly-outline`));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
Reference in New Issue
Block a user