Skip to content

Commit 90aa5e2

Browse files
committed
Replace programmatic mobile styles with CSS
1 parent e5b16cc commit 90aa5e2

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

features/issues/components/filters/filters.styled.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import styled from "styled-components";
22
import { breakpoint } from "@styles/theme";
3+
import { Select as UnstyledSelect, Input as UnstyledInput } from "@features/ui";
34

45
export const Container = styled.div`
56
display: flex;
@@ -12,7 +13,20 @@ export const Container = styled.div`
1213
flex-direction: row;
1314
justify-content: flex-end;
1415
order: initial;
15-
gap: 3rem;
1616
flex-wrap: wrap;
1717
}
1818
`;
19+
20+
export const Select = styled(UnstyledSelect)`
21+
width: 100%;
22+
@media (min-width: ${breakpoint("desktop")}) {
23+
width: 10rem;
24+
}
25+
`;
26+
27+
export const Input = styled(UnstyledInput)`
28+
width: 100%;
29+
@media (min-width: ${breakpoint("desktop")}) {
30+
width: 17.5rem;
31+
}
32+
`;

features/issues/components/filters/filters.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { useState } from "react";
2-
import { useWindowSize } from "react-use";
32
import { useDebouncedCallback } from "use-debounce";
43
import { capitalize } from "lodash";
5-
import { Select, Option, Input } from "@features/ui";
4+
import { Option } from "@features/ui";
65
import { IssueFilters, IssueLevel, IssueStatus } from "@api/issues.types";
76
import { useFilters } from "../../hooks/use-filters";
87
import * as S from "./filters.styled";
@@ -30,9 +29,6 @@ export function Filters() {
3029
const debouncedHandleFilters = useDebouncedCallback(handleFilters, 300);
3130
const [inputValue, setInputValue] = useState(filters.project || "");
3231

33-
const { width } = useWindowSize();
34-
const isMobileScreen = width <= 1023;
35-
3632
const handleChange = (project: string) => {
3733
setInputValue(project);
3834
debouncedHandleFilters({ project: project.toLowerCase() });
@@ -57,10 +53,9 @@ export function Filters() {
5753

5854
return (
5955
<S.Container>
60-
<Select
56+
<S.Select
6157
placeholder="Status"
6258
defaultValue={getStatusDefaultValue(filters)}
63-
width={isMobileScreen ? "97%" : "8rem"}
6459
>
6560
<Option value={undefined} handleCallback={handleStatus}>
6661
--None--
@@ -71,12 +66,11 @@ export function Filters() {
7166
<Option value="Resolved" handleCallback={handleStatus}>
7267
Resolved
7368
</Option>
74-
</Select>
69+
</S.Select>
7570

76-
<Select
71+
<S.Select
7772
placeholder="Level"
7873
defaultValue={getLevelDefaultValue(filters)}
79-
width={isMobileScreen ? "97%" : "8rem"}
8074
>
8175
<Option value={undefined} handleCallback={handleLevel}>
8276
--None--
@@ -90,9 +84,9 @@ export function Filters() {
9084
<Option value="Info" handleCallback={handleLevel}>
9185
Info
9286
</Option>
93-
</Select>
87+
</S.Select>
9488

95-
<Input
89+
<S.Input
9690
handleChange={handleChange}
9791
value={inputValue}
9892
label="project name"

features/ui/input/input.styled.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const InputContainer = styled.input<{
1717
border-radius: 7px;
1818
width: calc(${space(20)} * 4 - ${space(6)});
1919
padding: ${space(2, 3)};
20+
box-sizing: border-box;
2021
letter-spacing: 0.05rem;
2122
color: ${color("gray", 900)};
2223
${textFont("md", "regular")};

0 commit comments

Comments
 (0)