Skip to content

Commit bbc68ea

Browse files
authored
🐛 Fix: isFocused devtools warning (#285)
* 🧹 Chore: fix types in DateTimeSection * ✨ Feat: Add IconProvider for consistent icon sizing * ♻️ Refactor: Update icon color handling This removes the isFocused props, resolving devtools error
1 parent ebb6a0d commit bbc68ea

File tree

8 files changed

+58
-16
lines changed

8 files changed

+58
-16
lines changed

packages/web/src/App.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { sagaMiddleware } from "@web/common/store/middlewares";
1414
import { GlobalStyle } from "@web/components/GlobalStyle";
1515
import { sagas } from "@web/store/sagas";
1616
import { theme } from "./common/styles/theme";
17+
import { IconProvider } from "./components/IconProvider/IconProvider";
1718
import { RootRouter } from "./routers";
1819
import { store } from "./store";
1920

@@ -39,7 +40,9 @@ export const App = () => {
3940
<SuperTokensWrapper>
4041
<GlobalStyle />
4142
<ThemeProvider theme={theme}>
42-
<RootRouter />
43+
<IconProvider>
44+
<RootRouter />
45+
</IconProvider>
4346
<ToastContainer
4447
position="bottom-left"
4548
autoClose={5000}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from "react";
2+
import { IconContext } from "@phosphor-icons/react";
3+
4+
export const IconProvider = ({ children }: { children: React.ReactNode }) => {
5+
return (
6+
<IconContext.Provider
7+
value={{
8+
size: 25,
9+
}}
10+
>
11+
{children}
12+
</IconContext.Provider>
13+
);
14+
};

packages/web/src/components/Icons/styled.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { css } from "styled-components";
22
import { IconProps } from "@phosphor-icons/react";
33

4-
interface Props extends IconProps {
5-
isFocused: boolean;
6-
}
7-
8-
export const iconStyles = css<Props>`
9-
color: ${({ theme, isFocused }) =>
10-
isFocused ? theme.color.text.light : theme.color.text.lightInactive};
4+
export const iconStyles = css<IconProps>`
115
transition: filter 0.2s ease;
126
137
&:hover {

packages/web/src/views/Calendar/components/Dedication/Dedication.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const Dedication = () => {
4141
justifyContent={JustifyContent.SPACE_BETWEEN}
4242
>
4343
<h2>For Derek</h2>
44-
<StyledXIcon size={20} onClick={close} />
44+
<StyledXIcon onClick={close} />
4545
</Flex>
4646
<StyledDedicationText>
4747
This app is dedicated to Derek John Benton (1993-2014).

packages/web/src/views/Calendar/components/Header/Header.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import dayjs, { Dayjs } from "dayjs";
22
import React, { FC } from "react";
3+
import { theme } from "@web/common/styles/theme";
34
import { getCalendarHeadingLabel } from "@web/common/utils/web.date.util";
45
import { AlignItems } from "@web/components/Flex/styled";
56
import { SidebarIcon } from "@web/components/Icons/Sidebar";
@@ -59,7 +60,13 @@ export const Header: FC<Props> = ({
5960
onClick={() => dispatch(viewSlice.actions.toggleSidebar())}
6061
shortcut="["
6162
>
62-
<SidebarIcon size={25} isFocused={isSidebarOpen} />
63+
<SidebarIcon
64+
color={
65+
isSidebarOpen
66+
? theme.color.text.light
67+
: theme.color.text.lightInactive
68+
}
69+
/>
6370
</TooltipWrapper>
6471
<StyledLeftGroup>
6572
<StyledHeaderLabel aria-level={1} role="heading">

packages/web/src/views/Calendar/components/Sidebar/SidebarIconRow/SidebarIconRow.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from "react";
2+
import { Command } from "@phosphor-icons/react";
3+
import { theme } from "@web/common/styles/theme";
24
import { CalendarIcon } from "@web/components/Icons/Calendar";
35
import { CommandIcon } from "@web/components/Icons/Command";
46
import { TodoIcon } from "@web/components/Icons/Todo";
@@ -32,14 +34,26 @@ export const SidebarIconRow = () => {
3234
shortcut="CMD + K"
3335
onClick={toggleCmdPalette}
3436
>
35-
<CommandIcon isFocused={isCmdPaletteOpen} size={25} />
37+
<CommandIcon
38+
color={
39+
isCmdPaletteOpen
40+
? theme.color.text.darkPlaceholder
41+
: theme.color.text.light
42+
}
43+
/>
3644
</TooltipWrapper>
3745
<TooltipWrapper
3846
description="Open tasks"
3947
shortcut="SHIFT + 1"
4048
onClick={() => dispatch(viewSlice.actions.updateSidebarTab("tasks"))}
4149
>
42-
<TodoIcon isFocused={tab === "tasks"} size={25} />
50+
<TodoIcon
51+
color={
52+
tab === "tasks"
53+
? theme.color.text.light
54+
: theme.color.text.darkPlaceholder
55+
}
56+
/>
4357
</TooltipWrapper>
4458
<TooltipWrapper
4559
description="Open month"
@@ -48,7 +62,13 @@ export const SidebarIconRow = () => {
4862
dispatch(viewSlice.actions.updateSidebarTab("monthWidget"))
4963
}
5064
>
51-
<CalendarIcon isFocused={tab === "monthWidget"} size={25} />
65+
<CalendarIcon
66+
color={
67+
tab === "monthWidget"
68+
? theme.color.text.light
69+
: theme.color.text.darkPlaceholder
70+
}
71+
/>
5272
</TooltipWrapper>
5373
</LeftIconGroup>
5474
</IconRow>

packages/web/src/views/Forms/EventForm/DateTimeSection/DatePickers/DatePickers.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ export const DatePickers: FC<Props> = ({
159159
}}
160160
onChange={() => null}
161161
onInputClick={() => {
162-
isEndDatePickerOpen && setIsEndDatePickerOpen(false);
162+
if (isEndDatePickerOpen) {
163+
setIsEndDatePickerOpen(false);
164+
}
163165
setIsStartDatePickerOpen(true);
164166
}}
165167
onKeyDown={(e) => onPickerKeyDown("start", e)}
@@ -182,7 +184,9 @@ export const DatePickers: FC<Props> = ({
182184
onCalendarOpen={() => setIsEndDatePickerOpen(true)}
183185
onChange={() => null}
184186
onInputClick={() => {
185-
isStartDatePickerOpen && setIsStartDatePickerOpen(false);
187+
if (isStartDatePickerOpen) {
188+
setIsStartDatePickerOpen(false);
189+
}
186190
setIsEndDatePickerOpen(true);
187191
}}
188192
onKeyDown={(e) => onPickerKeyDown("end", e)}

packages/web/src/views/Forms/EventForm/DateTimeSection/DateTimeSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import dayjs from "dayjs";
22
import customParseFormat from "dayjs/plugin/customParseFormat";
3-
import React, { FC, SetStateAction, useRef } from "react";
3+
import React, { FC, SetStateAction } from "react";
44
import { Categories_Event, Schema_Event } from "@core/types/event.types";
55
import { SelectOption } from "@web/common/types/component.types";
66
import { AlignItems } from "@web/components/Flex/styled";

0 commit comments

Comments
 (0)