Skip to content

Commit

Permalink
Refactor styles
Browse files Browse the repository at this point in the history
  • Loading branch information
atrincas committed Oct 21, 2024
1 parent 7239bb6 commit 18e62eb
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 42 deletions.
3 changes: 2 additions & 1 deletion client/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const POPOVER_CONTENT_CLASS = "ml-4 max-h-[320px] w-full min-w-[320px]";
export const POPOVER_CONTENT_CLASS =
"flex flex-col ml-4 max-h-[320px] w-full min-w-[320px]";
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const FilterSelectValues: FC<FilterSelectValuesProps> = ({
};

return (
<>
<div className="flex h-full flex-col">
<Button
type="button"
variant="clean"
Expand Down Expand Up @@ -194,7 +194,7 @@ const FilterSelectValues: FC<FilterSelectValuesProps> = ({
</Button>
)}
</Form>
</>
</div>
);
};

Expand Down
16 changes: 6 additions & 10 deletions client/src/containers/filter/filter-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {
FilterSelectStep,
} from "@/containers/filter/filter-select/store";

import { Card } from "@/components/ui/card";

export interface FilterSelectProps {
items: PageFilter[];
defaultValues: string[];
Expand All @@ -38,14 +36,12 @@ const FilterSelect: FC<FilterSelectProps> = ({
}
filter={fixedFilter || null}
>
<Card className="relative h-full bg-foreground p-0 text-background">
<FilterSelectSteps
defaultValues={defaultValues}
fixedFilter={fixedFilter}
items={items}
onSubmit={onSubmit}
/>
</Card>
<FilterSelectSteps
defaultValues={defaultValues}
fixedFilter={fixedFilter}
items={items}
onSubmit={onSubmit}
/>
</AtomsHydrator>
</Provider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { FC, useState } from "react";
import { PageFilter } from "@shared/dto/widgets/page-filter.entity";
import { useSetAtom } from "jotai";

import { cn } from "@/lib/utils";

import useFilters from "@/hooks/useFilters";

import FilterSelect from "@/containers/filter/filter-select";
Expand All @@ -14,15 +16,14 @@ import {
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import { POPOVER_CONTENT_CLASS } from "@/constants";

interface FilterPopupProps {
name: string;
fixedFilter?: PageFilter;
items: PageFilter[];
}

const POPOVER_CONTENT_CLASS = "ml-4 h-[320px] w-full min-w-[320px]";

const FilterItemButton: FC<{
value: string;

Expand Down Expand Up @@ -89,7 +90,7 @@ const FilterPopup: FC<FilterPopupProps> = ({ name, fixedFilter, items }) => {
<PopoverContent
align="end"
side="bottom"
className={POPOVER_CONTENT_CLASS}
className={cn(POPOVER_CONTENT_CLASS, "h-[320px]")}
>
<FilterSelect
items={items}
Expand Down
2 changes: 1 addition & 1 deletion client/src/containers/sidebar/filter-settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const FilterSettings: FC = () => {

return (
<>
{data
{filtersQuery.data
?.filter((pageFilter) => DEFAULT_FILTERS.includes(pageFilter.name))
.map((f) => (
<FilterPopup
Expand Down
6 changes: 1 addition & 5 deletions client/src/containers/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ const Sidebar: FC = () => {
key="sidebar-accordion-explore"
type="multiple"
className="w-full overflow-y-auto"
defaultValue={
filters.length
? ["explore-filters", "explore-sections"]
: ["explore-sections"]
}
defaultValue={["explore-sections"]}
>
<AccordionItem value="explore-filters">
<AccordionTrigger>Filters</AccordionTrigger>
Expand Down
39 changes: 19 additions & 20 deletions client/src/containers/sidebar/indicator-seletor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { FC, useState } from "react";

import { BaseWidgetWithData } from "@shared/dto/widgets/base-widget-data.interface";
import { BaseWidget } from "@shared/dto/widgets/base-widget.entity";
import { useAtom, useSetAtom } from "jotai";

import { client } from "@/lib/queryClient";
import { queryKeys } from "@/lib/queryKeys";
import { cn } from "@/lib/utils";

import {
customWidgetAtom,
Expand All @@ -21,8 +23,6 @@ import {
} from "@/components/ui/popover";
import { POPOVER_CONTENT_CLASS } from "@/constants";

import widgets from "../widgets.json";

const IndicatorSelector: FC = () => {
const { data } = client.widgets.getWidgets.useQuery(
queryKeys.widgets.all.queryKey,
Expand All @@ -35,6 +35,7 @@ const IndicatorSelector: FC = () => {
const [selectedVisualization, setSelectedVisualization] = useAtom(
selectedVisualizationAtom,
);
const widgets = data as BaseWidget[];

return (
<Popover
Expand All @@ -61,26 +62,24 @@ const IndicatorSelector: FC = () => {
<PopoverContent
align="start"
side="bottom"
className={POPOVER_CONTENT_CLASS}
className={cn(POPOVER_CONTENT_CLASS, "h-[320px]")}
>
<div className="flex h-full flex-col overflow-y-auto">
<SearchableList
items={widgets}
itemKey="indicator"
onItemClick={(w: any) => {
if (
selectedVisualization &&
!widget?.visualisations.includes(selectedVisualization)
) {
setSelectedVisualization(null);
}
<SearchableList
items={widgets}
itemKey="indicator"
onItemClick={(w) => {
if (
selectedVisualization &&
!widget?.visualisations.includes(selectedVisualization)
) {
setSelectedVisualization(null);
}

setWidget(w as BaseWidgetWithData);
setShowIndicators(false);
setIsPopoverOpen(false);
}}
/>
</div>
setWidget(w as BaseWidgetWithData);
setShowIndicators(false);
setIsPopoverOpen(false);
}}
/>
</PopoverContent>
</Popover>
);
Expand Down

0 comments on commit 18e62eb

Please sign in to comment.