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

feat: add vertical and horizontal orientation for radio-group #3082

Merged
merged 2 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ <h4>Defaults</h4>
</fast-radio-group>
</div>

<div>
<fast-radio-group orientation="vertical" name="trees">
<label slot="label">Trees</label>
<fast-radio value="fir">Fir</fast-radio>
<fast-radio value="juniper">Juniper</fast-radio>
<fast-radio value="hemlock">Hemlock</fast-radio>
<fast-radio value="pine">Pine</fast-radio>
</fast-radio-group>
</div>

<div style="display: flex; flex-direction: column;margin-top: 12px;">
<fast-radio-group name="players">
<label slot="label">Best basketball players</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ export const RadioGroupStyles = css`
margin: calc(var(--design-unit) * 1px) 0;
flex-direction: column;
}
.positioning-region {
display: flex;
flex-wrap: wrap;
}
.vertical {
flex-direction: column;
}
.horizontal {
flex-direction: row;
}
marjonlynch marked this conversation as resolved.
Show resolved Hide resolved
`;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { html, slotted } from "@microsoft/fast-element";
import { Orientation } from "@microsoft/fast-web-utilities";
import { RadioGroup } from "./radio-group";

export const RadioGroupTemplate = html<RadioGroup>`
Expand All @@ -8,7 +9,11 @@ export const RadioGroupTemplate = html<RadioGroup>`
aria-readonly="${x => x.readOnly}"
>
<slot name="label"></slot>
<div class="positioning-region" part="positioning-region">
<div
class="positioning-region ${x =>
x.orientation === Orientation.horizontal ? "horizontal" : "vertical"}"
part="positioning-region"
>
<slot ${slotted("slottedRadioButtons")}> </slot>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { attr, FASTElement, observable } from "@microsoft/fast-element";
import { Orientation } from "@microsoft/fast-web-utilities";
import {
keyCodeArrowDown,
keyCodeArrowLeft,
Expand Down Expand Up @@ -50,6 +51,9 @@ export class RadioGroup extends FASTElement {
@attr
public value: string;

@attr
public orientation: Orientation = Orientation.horizontal;

@observable slottedRadioButtons: RadioControl[];
private selectedRadio: RadioControl | null;
private focusedRadio: RadioControl | null;
Expand Down