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

Presentation: Fix test app pickers styling #3523

Merged
merged 1 commit into from
Apr 14, 2022
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 @@ -26,6 +26,7 @@
grid-template-columns: auto 20% 10% 10%;
padding: 5px;
column-gap: 5px;
align-items: center;
}

.app-pickers > div {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
*--------------------------------------------------------------------------------------------*/
import * as React from "react";
import { IModelApp } from "@itwin/core-frontend";
import { Select } from "@itwin/core-react";
import { Select, SelectOption } from "@itwin/itwinui-react";
import { MyAppFrontend } from "../../api/MyAppFrontend";

export interface RulesetSelectorProps {
onRulesetSelected: (rulesetId?: string) => void;
activeRulesetId?: string;
}
export interface RulesetSelectorState {
availableRulesets?: string[];
availableRulesets?: SelectOption<string>[];
}
export class RulesetSelector extends React.Component<RulesetSelectorProps, RulesetSelectorState> {
constructor(props: RulesetSelectorProps) {
Expand All @@ -25,25 +25,21 @@ export class RulesetSelector extends React.Component<RulesetSelectorProps, Rules
}
private async initAvailableRulesets() {
const rulesetIds = await MyAppFrontend.getAvailableRulesets();
this.setState({ availableRulesets: rulesetIds });
this.setState({ availableRulesets: rulesetIds.map((id) => ({value: id, label:id})) });
}
// eslint-disable-next-line @typescript-eslint/naming-convention
private onSelectedRulesetIdChanged = (e: React.ChangeEvent<HTMLSelectElement>) => {
this.props.onRulesetSelected(e.target.value);
};
public override render() {
if (!this.state.availableRulesets)
return (<div className="RulesetSelector">{IModelApp.localization.getLocalizedString("Sample:controls.notifications.loading")}</div>);
if (0 === this.state.availableRulesets.length)
return (<div className="RulesetSelector">{IModelApp.localization.getLocalizedString("Sample:controls.notifications.no-available-rulesets")}</div>);
return (
<div className="RulesetSelector">
{/* eslint-disable-next-line deprecation/deprecation */}
<Select
options={this.state.availableRulesets}
defaultValue={this.props.activeRulesetId}
value={this.props.activeRulesetId}
placeholder={IModelApp.localization.getLocalizedString("Sample:controls.notifications.select-ruleset")}
onChange={this.onSelectedRulesetIdChanged}
onChange={this.props.onRulesetSelected}
size="small"
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as React from "react";
import { IModelApp } from "@itwin/core-frontend";
import { UnitSystemKey } from "@itwin/core-quantity";
import { Select } from "@itwin/core-react";
import { Select, SelectOption } from "@itwin/itwinui-react";

export interface UnitSystemSelectorProps {
selectedUnitSystem: UnitSystemKey | undefined;
Expand All @@ -14,24 +14,21 @@ export interface UnitSystemSelectorProps {

export function UnitSystemSelector(props: UnitSystemSelectorProps) {
const { selectedUnitSystem, onUnitSystemSelected: onUnitSystemSelectedProp } = props;
const onUnitSystemSelected = React.useCallback((evt: React.ChangeEvent<HTMLSelectElement>) => {
onUnitSystemSelectedProp(evt.target.value ? (evt.target.value as UnitSystemKey) : undefined);
}, [onUnitSystemSelectedProp]);

return (
<div className="UnitSystemSelector">
{/* eslint-disable-next-line deprecation/deprecation */}
<Select
options={availableUnitSystems}
defaultValue={selectedUnitSystem}
value={selectedUnitSystem}
placeholder={IModelApp.localization.getLocalizedString("Sample:controls.notifications.select-unit-system")}
onChange={onUnitSystemSelected}
onChange={onUnitSystemSelectedProp}
size="small"
/>
</div>
);
}

const availableUnitSystems = [{
const availableUnitSystems: SelectOption<UnitSystemKey | undefined>[] = [{
value: undefined,
label: "",
}, {
Expand Down