-
Notifications
You must be signed in to change notification settings - Fork 13.4k
feat(select): allow HTML within options #31072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from 7 commits
9918f4a
d0a8a56
d53d627
5415cad
8f3e623
f0b45d3
a48cf66
e9eb575
e4bce6b
03b8351
cc0af05
49e0e6c
0c7e4d6
17e9e37
6ef2355
22dace3
f2695ca
8a4e59b
deaafb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| @use "../../themes/ionic/ionic.globals.scss" as globals; | ||
| @use "./action-sheet.common"; | ||
| @use "./action-sheet.md" as action-sheet-md; | ||
|
|
||
| // Ionic Action Sheet | ||
| // -------------------------------------------------- | ||
|
|
||
| // Action Sheet: Select Option | ||
| // -------------------------------------------------- | ||
|
|
||
| .action-sheet-button-label { | ||
| gap: globals.$ion-space-300; | ||
| } | ||
|
|
||
| .select-option-description { | ||
| @include globals.typography(globals.$ion-body-md-regular); | ||
| @include globals.padding(0); | ||
|
|
||
| color: globals.$ion-text-subtle; | ||
|
|
||
| font-size: globals.$ion-font-size-350; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| @use "../../themes/native/native.theme.default" as native; | ||
| @use "../../themes/mixins" as mixins; | ||
| @use "../../themes/functions.font" as font; | ||
| @use "./action-sheet.common"; | ||
|
|
||
| // Action Sheet: Native | ||
| // -------------------------------------------------- | ||
|
|
||
| .action-sheet-button-label { | ||
| gap: 12px; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to use the same value that ionic uses.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based it off |
||
| } | ||
|
|
||
| .select-option-description { | ||
| @include mixins.padding(5px, 0, 0, 0); | ||
|
|
||
| color: native.$text-color-step-300; | ||
|
|
||
| font-size: font.dynamic-font(12px); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import { | |
| safeCall, | ||
| setOverlayId, | ||
| } from '@utils/overlays'; | ||
| import { renderOptionLabel } from '@utils/select-option-render'; | ||
| import { getClassMap } from '@utils/theme'; | ||
|
|
||
| import { getIonMode, getIonTheme } from '../../global/ionic-global'; | ||
|
|
@@ -37,7 +38,7 @@ import { mdLeaveAnimation } from './animations/md.leave'; | |
| styleUrls: { | ||
| ios: 'action-sheet.ios.scss', | ||
| md: 'action-sheet.md.scss', | ||
| ionic: 'action-sheet.md.scss', | ||
| ionic: 'action-sheet.ionic.scss', | ||
| }, | ||
| scoped: true, | ||
| }) | ||
|
|
@@ -559,6 +560,14 @@ export class ActionSheet implements ComponentInterface, OverlayInterface { | |
| htmlAttrs['aria-checked'] = isActiveRadio ? 'true' : 'false'; | ||
| } | ||
|
|
||
| const optionLabelOptions = { | ||
| id: buttonId, | ||
| label: b.text, | ||
| startContent: b.startContent, | ||
| endContent: b.endContent, | ||
| description: b.description, | ||
| }; | ||
|
|
||
| return ( | ||
| <button | ||
| {...htmlAttrs} | ||
|
|
@@ -580,7 +589,7 @@ export class ActionSheet implements ComponentInterface, OverlayInterface { | |
| > | ||
| <span class="action-sheet-button-inner"> | ||
| {b.icon && <ion-icon icon={b.icon} aria-hidden="true" lazy={false} class="action-sheet-icon" />} | ||
| {b.text} | ||
| {renderOptionLabel(optionLabelOptions, 'action-sheet-button-label')} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the DOM structure for all action-sheet buttons, not just ones created through select. Previously
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do understand that breaking changes are acceptable here and this may be intended. Just double checking that's what you're going for.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| </span> | ||
| {theme === 'md' && <ion-ripple-effect></ion-ripple-effect>} | ||
| </button> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| @use "../../themes/ionic/ionic.globals.scss" as globals; | ||
| @use "./alert.common"; | ||
| @use "./alert.md" as alert-md; | ||
|
|
||
| // Ionic Alert | ||
| // -------------------------------------------------- | ||
|
|
||
| // Alert: Select Option | ||
| // -------------------------------------------------- | ||
|
|
||
| .alert-radio-label, | ||
| .alert-checkbox-label { | ||
| gap: globals.$ion-space-300; | ||
| } | ||
|
|
||
| .select-option-description { | ||
| @include globals.typography(globals.$ion-body-md-regular); | ||
| @include globals.padding(0); | ||
|
|
||
| color: globals.$ion-text-subtle; | ||
|
|
||
| font-size: globals.$ion-font-size-350; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| @import "./alert"; | ||
| @import "./alert.native"; | ||
| @import "./alert.ios.vars"; | ||
|
|
||
| // iOS Alert | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| @import "./alert"; | ||
| @import "./alert.native"; | ||
| @import "./alert.md.vars"; | ||
|
|
||
| // Material Design Alert | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| @use "../../themes/native/native.theme.default" as native; | ||
| @use "../../themes/mixins" as mixins; | ||
| @use "../../themes/functions.font" as font; | ||
| @use "./alert.common"; | ||
|
|
||
| // Alert: Native | ||
| // -------------------------------------------------- | ||
|
|
||
| .alert-radio-label, | ||
| .alert-checkbox-label { | ||
| gap: 12px; | ||
| } | ||
|
|
||
| .select-option-description { | ||
| @include mixins.padding(5px, 0, 0, 0); | ||
|
|
||
| color: native.$text-color-step-300; | ||
|
|
||
| font-size: font.dynamic-font(12px); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Widening
textfromstringtostring | HTMLElementhere affects all action-sheet consumers, not just select-driven ones. Same withAlertInput.label. Anyone callingactionSheetController.create()who doesbutton.text.toLowerCase()or passestextto a string-typed function will get TS errors. Since this targetsnext, breaking changes are expected, but would it be cleaner to add a separate property (e.g.,richTextorcontentElement) for the HTMLElement case? That way existing string usage stays untouched.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! cc0af05 and 49e0e6c