Skip to content

Commit

Permalink
fix(select-button): add support for mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
hirsch88 committed Feb 10, 2022
1 parent 32d4ac7 commit 75647d2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
8 changes: 8 additions & 0 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,10 @@ export namespace Components {
* The value of the control.
*/
"value": string;
/**
* If `true`, the controls will be vertically on mobile devices.
*/
"verticalOnMobile": boolean;
}
interface BalSelect {
/**
Expand Down Expand Up @@ -3042,6 +3046,10 @@ declare namespace LocalJSX {
* The value of the control.
*/
"value"?: string;
/**
* If `true`, the controls will be vertically on mobile devices.
*/
"verticalOnMobile"?: boolean;
}
interface BalSelect {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ bal-radio-group {
position: relative;
width: 100%;

&.bal-select-button > div {
display: flex;
flex: 1;
border: 1px solid $blue-2;
border-radius: 100px;
padding: 4px;
&.bal-select-button {
> div {
display: flex;
flex: 1;
border: 1px solid $blue-2;
border-radius: 100px;
padding: 4px;
}

&.is-vertical-mobile > div {
flex-direction: column;
border-radius: 12px;
}
}

&:not(.bal-select-button) {
Expand All @@ -22,4 +29,11 @@ bal-radio-group {
}
}
}

@include tablet() {
&.bal-select-button.is-vertical-mobile > div {
flex-direction: row;
border-radius: 100px;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export class RadioGroup implements ComponentInterface {
*/
@Prop() disabled?: boolean = undefined

/**
* If `true`, the controls will be vertically on mobile devices.
*/
@Prop() verticalOnMobile = false

@Watch('disabled')
disabledChanged(value: boolean | undefined) {
if (value !== undefined) {
Expand Down Expand Up @@ -114,7 +119,15 @@ export class RadioGroup implements ComponentInterface {
render() {
const label = findItemLabel(this.el)
return (
<Host role="radiogroup" aria-labelledby={label?.id} onClick={this.onClick} class={`bal-${this.interface}`}>
<Host
role="radiogroup"
aria-labelledby={label?.id}
onClick={this.onClick}
class={{
[`bal-${this.interface}`]: true,
'is-vertical-mobile': this.verticalOnMobile,
}}
>
<div>
<slot></slot>
</div>
Expand Down

0 comments on commit 75647d2

Please sign in to comment.