Skip to content

Commit

Permalink
Fix compact radio button in selector (#496)
Browse files Browse the repository at this point in the history
* fix: 🐛 added cache to garden meta

* feat: ✨ change default state to open. store state in localstorage

* fix: 🐛 use scroll to colum start when removing subgroup

* feat: 💄 styling

* test: 🧪 updated test

* fix: 🧪 await

* chore: 📦 bump

* style: 💄 compact radio button

* bump
  • Loading branch information
espenkalle authored Oct 12, 2023
1 parent 4d0fc41 commit 30a69bf
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 75 deletions.
2 changes: 1 addition & 1 deletion packages/garden/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-garden",
"version": "5.1.3",
"version": "5.1.4",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Autocomplete, Divider, Label, Radio } from '@equinor/eds-core-react';
import { Autocomplete, Divider, EdsProvider, Label, Radio } from '@equinor/eds-core-react';
import { useQuery } from '@tanstack/react-query';
import { Fragment, useRef } from 'react';
import { GroupingOption } from '../../types';
Expand Down Expand Up @@ -83,79 +83,81 @@ export function GroupingSelector<TContext>({
}

return (
<SelectorBody>
<StyledGroupHeader>Groups</StyledGroupHeader>
<Divider />
<StyledAutoCompleteWrapper>
<Autocomplete
ref={selectorRef}
key={groupingKeys[0]}
options={data.allGroupingOptions.map((option: GroupingOption) => option.groupingKey)}
label={'Group by'}
hideClearButton
multiple={false}
selectedOptions={[groupingKeys[0]]}
onOptionsChange={(changes) => handleGardenKeyChange(changes.selectedItems[0])}
/>
<Autocomplete
options={data.validGroupingOptions}
label={'Then Group by'}
selectedOptions={[groupingKeys.at(1)]}
onOptionsChange={(changes) => handleExistingSelectionChange(changes.selectedItems[0])}
/>
</StyledAutoCompleteWrapper>
<EdsProvider density="compact">
<SelectorBody>
<StyledGroupHeader>Groups</StyledGroupHeader>
<Divider />
<StyledAutoCompleteWrapper>
<Autocomplete
ref={selectorRef}
key={groupingKeys[0]}
options={data.allGroupingOptions.map((option: GroupingOption) => option.groupingKey)}
label={'Group by'}
hideClearButton
multiple={false}
selectedOptions={[groupingKeys[0]]}
onOptionsChange={(changes) => handleGardenKeyChange(changes.selectedItems[0])}
/>
<Autocomplete
options={data.validGroupingOptions}
label={'Then Group by'}
selectedOptions={[groupingKeys.at(1)]}
onOptionsChange={(changes) => handleExistingSelectionChange(changes.selectedItems[0])}
/>
</StyledAutoCompleteWrapper>

{data.allGroupingOptions.map((groupingOption) => {
// Check if dateVariant or timeInterval is defined
const hasDateVariant = !!groupingOption.dateVariant;
const hasTimeInterval = !!groupingOption.timeInterval;
{data.allGroupingOptions.map((groupingOption) => {
// Check if dateVariant or timeInterval is defined
const hasDateVariant = !!groupingOption.dateVariant;
const hasTimeInterval = !!groupingOption.timeInterval;

if (!hasDateVariant && !hasTimeInterval) return null;
if (!hasDateVariant && !hasTimeInterval) return null;

return (
groupingOption.groupingKey === groupingKeys[0] && (
<Fragment key={groupingOption.groupingKey}>
<StyledGroupHeader>Views</StyledGroupHeader>
<Divider />
<RadioWrapper>
<StyledSubGroupHeader>Date Fields:</StyledSubGroupHeader>
<RadioCategoryWrapper>
{hasDateVariant &&
groupingOption.dateVariant?.map((typ) => (
<RadioButtonWrapper key={typ}>
<Radio
id={typ}
key={typ}
value={typ}
name="dateVariant"
checked={dateVariant?.trim().toLowerCase() === typ.trim().toLowerCase()}
onChange={(e) => onChangeDateVarient(e.target.value)}
/>
<Label htmlFor={typ} label={typ} style={{ fontSize: '14' }} />
</RadioButtonWrapper>
))}
</RadioCategoryWrapper>
<StyledSubGroupHeader>Time Intervals:</StyledSubGroupHeader>
<RadioCategoryWrapper>
{hasTimeInterval &&
groupingOption.timeInterval?.map((dim) => (
<RadioButtonWrapper key={dim}>
<Radio
key={dim}
value={dim}
name="timeInterval"
checked={timeInterval?.trim().toLowerCase() === dim.trim().toLowerCase()}
onChange={(e) => onChangeTimeInterval(e.target.value)}
/>
<Label htmlFor={dim} label={dim} style={{ fontSize: '14' }} />
</RadioButtonWrapper>
))}
</RadioCategoryWrapper>
</RadioWrapper>
</Fragment>
)
);
})}
</SelectorBody>
return (
groupingOption.groupingKey === groupingKeys[0] && (
<Fragment key={groupingOption.groupingKey}>
<StyledGroupHeader>Views</StyledGroupHeader>
<Divider />
<RadioWrapper>
<StyledSubGroupHeader>Date Fields:</StyledSubGroupHeader>
<RadioCategoryWrapper>
{hasDateVariant &&
groupingOption.dateVariant?.map((typ) => (
<RadioButtonWrapper key={typ}>
<Radio
id={typ}
key={typ}
value={typ}
name="dateVariant"
checked={dateVariant?.trim().toLowerCase() === typ.trim().toLowerCase()}
onChange={(e) => onChangeDateVarient(e.target.value)}
/>
<Label htmlFor={typ} label={typ} style={{ fontSize: '14' }} />
</RadioButtonWrapper>
))}
</RadioCategoryWrapper>
<StyledSubGroupHeader>Time Intervals:</StyledSubGroupHeader>
<RadioCategoryWrapper>
{hasTimeInterval &&
groupingOption.timeInterval?.map((dim) => (
<RadioButtonWrapper key={dim}>
<Radio
key={dim}
value={dim}
name="timeInterval"
checked={timeInterval?.trim().toLowerCase() === dim.trim().toLowerCase()}
onChange={(e) => onChangeTimeInterval(e.target.value)}
/>
<Label htmlFor={dim} label={dim} style={{ fontSize: '14' }} />
</RadioButtonWrapper>
))}
</RadioCategoryWrapper>
</RadioWrapper>
</Fragment>
)
);
})}
</SelectorBody>
</EdsProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const StyledGroupHeader = styled.div`
`;
export const StyledSubGroupHeader = styled.div`
font-weight: 500;
padding-left: 1rem;
padding-top: 1rem;
`;
export const RadioWrapper = styled.div`
Expand All @@ -23,6 +22,7 @@ export const RadioWrapper = styled.div`
flex-direction: column;
gap: 1em;
font-size: 14;
padding-left: 0.625rem;
`;

export const RadioCategoryWrapper = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace-fusion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-fusion",
"version": "5.3.5",
"version": "5.3.6",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down

0 comments on commit 30a69bf

Please sign in to comment.