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 {
|
:host {
|
||||||
|
// TODO(ROU-5477): use design token here when it is added
|
||||||
|
--color: #121212;
|
||||||
--border-width: #{$ionic-border-size-small};
|
--border-width: #{$ionic-border-size-small};
|
||||||
--border-color: #{$ionic-color-neutral-300};
|
--border-color: #{$ionic-color-neutral-300};
|
||||||
--highlight-color-valid: #{$ionic-color-success-400};
|
--highlight-color-valid: #{$ionic-color-success-400};
|
||||||
@ -178,6 +180,13 @@
|
|||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Input - Readonly
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
|
:host(.input-readonly) {
|
||||||
|
--background: #{tokens.$ionic-color-neutral-10};
|
||||||
|
}
|
||||||
|
|
||||||
// Input Highlight
|
// Input Highlight
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -808,6 +808,7 @@ export class Input implements ComponentInterface {
|
|||||||
'in-item': inItem,
|
'in-item': inItem,
|
||||||
'in-item-color': hostContext('ion-item.ion-color', this.el),
|
'in-item-color': hostContext('ion-item.ion-color', this.el),
|
||||||
'input-disabled': disabled,
|
'input-disabled': disabled,
|
||||||
|
'input-readonly': readonly,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{/**
|
{/**
|
||||||
|
|||||||
@ -50,7 +50,28 @@
|
|||||||
<div class="grid-item">
|
<div class="grid-item">
|
||||||
<h2>No Fill</h2>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh
|
|||||||
`
|
`
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<ion-input
|
<ion-input
|
||||||
label="Email"
|
label="Email"
|
||||||
value="hi@ionic.io"
|
value="hi@ionic.io"
|
||||||
helper-text="Enter an email"
|
helper-text="Enter an email"
|
||||||
counter="true"
|
counter="true"
|
||||||
@ -55,7 +55,7 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh
|
|||||||
class="ion-valid has-focus"
|
class="ion-valid has-focus"
|
||||||
disabled="true"
|
disabled="true"
|
||||||
></ion-input>
|
></ion-input>
|
||||||
|
|
||||||
<ion-input
|
<ion-input
|
||||||
label="Email"
|
label="Email"
|
||||||
value="hi@ionic.io"
|
value="hi@ionic.io"
|
||||||
@ -92,7 +92,7 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<ion-input
|
<ion-input
|
||||||
fill="outline"
|
fill="outline"
|
||||||
label="Email"
|
label="Email"
|
||||||
value="hi@ionic.io"
|
value="hi@ionic.io"
|
||||||
helper-text="Enter an email"
|
helper-text="Enter an email"
|
||||||
counter="true"
|
counter="true"
|
||||||
@ -110,7 +110,7 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh
|
|||||||
class="ion-valid has-focus"
|
class="ion-valid has-focus"
|
||||||
disabled="true"
|
disabled="true"
|
||||||
></ion-input>
|
></ion-input>
|
||||||
|
|
||||||
<ion-input
|
<ion-input
|
||||||
fill="outline"
|
fill="outline"
|
||||||
label="Email"
|
label="Email"
|
||||||
@ -149,7 +149,7 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh
|
|||||||
`
|
`
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<ion-input
|
<ion-input
|
||||||
label="Email"
|
label="Email"
|
||||||
value="hi@ionic.io"
|
value="hi@ionic.io"
|
||||||
helper-text="Enter an email"
|
helper-text="Enter an email"
|
||||||
counter="true"
|
counter="true"
|
||||||
@ -159,7 +159,7 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh
|
|||||||
|
|
||||||
<ion-input
|
<ion-input
|
||||||
fill="outline"
|
fill="outline"
|
||||||
label="Email"
|
label="Email"
|
||||||
value="hi@ionic.io"
|
value="hi@ionic.io"
|
||||||
helper-text="Enter an email"
|
helper-text="Enter an email"
|
||||||
counter="true"
|
counter="true"
|
||||||
@ -175,5 +175,54 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh
|
|||||||
await expect(container).toHaveScreenshot(screenshot(`input-focused`));
|
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