Skip to content
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

fix(select): add background to selected item and remove color's prop #565

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export namespace Components {
"trigger"?: string;
}
interface AtomSelect {
"color"?: 'primary' | 'secondary' | 'danger';
tassioFront marked this conversation as resolved.
Show resolved Hide resolved
"disabled"?: boolean;
"errorText"?: string;
"fill": 'solid' | 'outline';
Expand Down Expand Up @@ -709,7 +708,6 @@ declare namespace LocalJSX {
"trigger"?: string;
}
interface AtomSelect {
"color"?: 'primary' | 'secondary' | 'danger';
"disabled"?: boolean;
"errorText"?: string;
"fill"?: 'solid' | 'outline';
Expand Down
18 changes: 1 addition & 17 deletions packages/core/src/components/select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,10 @@
--ion-color-step-550: --color-neutral-light-1;
min-height: var(--atom-select-min-height);

&[color='primary'] {
--highlight-color-focused: var(--color-brand-primary-regular);
--atom-icon-color: var(--color-brand-primary-regular);
}

&[color='secondary'] {
--highlight-color-focused: var(--color-brand-secondary-regular);
}

&[color='danger'] {
--highlight-color-focused: var(--color-contextual-error-regular);
}

&.has-error {
--border-color: var(--color-contextual-error-regular);
--placeholder-color: var(--text-color);
Expand Down Expand Up @@ -82,15 +73,8 @@
z-index: var(--zindex-100);

.select-expanded + & {
&.atom-color--primary {
--atom-icon-color: var(--color-brand-primary-regular);
}

&.atom-color--secondary {
--atom-icon-color: var(--color-brand-secondary-regular);
}
--atom-icon-color: var(--color-brand-secondary-regular);

&.atom-color--danger,
&.has-error {
--atom-icon-color: var(--color-contextual-error-regular);
}
Expand Down
7 changes: 3 additions & 4 deletions packages/core/src/components/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ describe('AtomSelect', () => {
name="test"
label="Select a fruit"
placeholder="Select an option"
color="primary"
mode="ios"
fill="outline"
disabled
Expand All @@ -104,9 +103,9 @@ describe('AtomSelect', () => {
await page.waitForChanges()

expect(page.root).toEqualHtml(`
<atom-select color="primary" disabled="" fill="outline" label="Select a fruit" mode="ios" multiple="" name="test" placeholder="Select an option">
<atom-select disabled="" fill="outline" label="Select a fruit" mode="ios" multiple="" name="test" placeholder="Select an option">
<mock:shadow-root>
<ion-select class="atom-select" color="primary" disabled="" fill="outline" interface="popover" label="Select a fruit" label-placement="stacked" mode="ios" multiple="" name="test" placeholder="Select an option" shape="round">
<ion-select class="atom-select" color="secondary" disabled="" fill="outline" interface="popover" label="Select a fruit" label-placement="stacked" mode="ios" multiple="" name="test" placeholder="Select an option" shape="round">
<ion-select-option value="apple">apple</ion-select-option>
<ion-select-option value="banana" disabled>banana</ion-select-option>
<ion-select-option value="orange">orange</ion-select-option>
Expand Down Expand Up @@ -135,7 +134,7 @@ describe('AtomSelect', () => {
<ion-select-option disabled="" value="banana">banana</ion-select-option>
<ion-select-option value="orange">orange</ion-select-option>
</ion-select>
<atom-icon class="atom-color--secondary atom-icon" icon="account-multiple"></atom-icon>
<atom-icon class="atom-icon" icon="account-multiple"></atom-icon>
</mock:shadow-root>
</atom-select>
`)
Expand Down
13 changes: 3 additions & 10 deletions packages/core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { IconProps } from '../../icons'
export class AtomSelect {
@Element() selectEl!: HTMLIonSelectElement

@Prop() color?: 'primary' | 'secondary' | 'danger' = 'secondary'
@Prop() disabled?: boolean
@Prop() errorText?: string
@Prop() fill: 'solid' | 'outline' = 'solid'
Expand Down Expand Up @@ -104,7 +103,7 @@ export class AtomSelect {
placeholder={this.placeholder}
disabled={this.disabled}
multiple={this.multiple}
color={this.color}
color='secondary'
mode={this.mode}
value={this.value}
tabindex={this.readonly && '-1'}
Expand All @@ -114,7 +113,7 @@ export class AtomSelect {
onIonFocus={this.handleFocus}
onIonCancel={this.handleCancel}
interfaceOptions={{
cssClass: `atom-select-color-${this.color}`,
cssClass: `atom-select__popover`,
}}
>
{this.options.map((option) => (
Expand All @@ -136,13 +135,7 @@ export class AtomSelect {
</div>
)}
{this.icon && (
<atom-icon
class={{
[`atom-icon`]: true,
[`atom-color--${this.color}`]: true,
}}
icon={this.icon}
></atom-icon>
<atom-icon class='atom-icon' icon={this.icon}></atom-icon>
)}
</Host>
)
Expand Down
10 changes: 0 additions & 10 deletions packages/core/src/components/select/stories/select.args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ export const SelectStoryArgs = {
category: Category.PROPERTIES,
},
},
color: {
control: 'select',
options: ['primary', 'secondary', 'danger'],
defaultValue: { summary: 'secondary' },
description: "The color to use from your application's color palette.",
table: {
category: Category.PROPERTIES,
},
},
multiple: {
control: 'boolean',
defaultValue: { summary: false },
Expand Down Expand Up @@ -160,7 +151,6 @@ export const SelectStoryArgs = {
}

export const SelectComponentArgs = {
color: 'secondary',
disabled: false,
readonly: false,
multiple: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const createSelect = (args) => {
return html`
<atom-select
placeholder=${args.placeholder}
color=${args.color}
fill=${args.fill}
disabled=${args.disabled}
readonly=${args.readonly}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default {
const createSelect = (args) => (
<AtomSelect
placeholder={args.placeholder}
color={args.color}
fill={args.fill}
disabled={args.disabled}
readonly={args.readonly}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const createSelect = (args) => ({
template: `
<AtomSelect
placeholder="${args.placeholder}"
color="${args.color}"
fill="${args.fill}"
disabled="${args.disabled}"
readonly="${args.readonly}"
Expand Down
34 changes: 11 additions & 23 deletions packages/core/src/global/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,25 @@ Issue: https://github.com/ionic-team/ionic-framework/issues/27500
--background-hover: var(--ion-color-medium);
}

&.atom-select-color-primary {
&.atom-select__popover {
.item-checkbox-checked {
--color: var(--ion-color-primary);
}
--color: var(--color-brand-secondary-regular);

ion-checkbox {
--checkbox-background-checked: var(--ion-color-primary);
--border-color-checked: var(--ion-color-primary);
}

.item-radio-checked {
--background: rgba(var(--ion-color-primary-rgb));
--background-focused: var(--ion-color-primary);
--background-hover: var(--ion-color-primary);
}
}

&.atom-select-color-secondary {
.item-checkbox-checked {
--color: var(--ion-color-secondary);
&::part(native) {
--background: rgba(var(--color-brand-secondary-light-2-rgb));
}
}

ion-checkbox {
--checkbox-background-checked: var(--ion-color-secondary);
--border-color-checked: var(--ion-color-secondary);
--checkbox-background-checked: var(--color-brand-secondary-regular);
--border-color-checked: var(--color-brand-secondary-regular);
}

.item-radio-checked {
--background: rgba(var(--ion-color-secondary-rgb));
--background-focused: var(--ion-color-secondary);
--background-hover: var(--ion-color-secondary);
--background: rgba(var(--color-brand-secondary-light-2-rgb));
--background-focused: var(--color-brand-secondary-regular);
--background-hover: var(--color-brand-secondary-regular);
color: var(--color-brand-secondary-regular);
}
}
}
Loading