Change to using arrow functions (#1603)
* Change to using arrow functions Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Add lint rule --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -15,7 +15,7 @@ const themes = {
|
||||
[ColorScheme.Light]: lightTheme,
|
||||
};
|
||||
|
||||
export function AppThemeProvider({ children }: OwnProps) {
|
||||
export const AppThemeProvider = ({ children }: OwnProps) => {
|
||||
const systemColorScheme = useSystemColorScheme();
|
||||
|
||||
const { colorScheme } = useColorScheme();
|
||||
@ -26,4 +26,4 @@ export function AppThemeProvider({ children }: OwnProps) {
|
||||
];
|
||||
|
||||
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
|
||||
}
|
||||
};
|
||||
|
||||
@ -146,7 +146,7 @@ export const color = {
|
||||
...secondaryColors,
|
||||
};
|
||||
|
||||
export function rgba(hex: string, alpha: number) {
|
||||
export const rgba = (hex: string, alpha: number) => {
|
||||
const rgb = hexRgb(hex, { format: 'array' }).slice(0, -1).join(',');
|
||||
return `rgba(${rgb},${alpha})`;
|
||||
}
|
||||
};
|
||||
|
||||
@ -8,7 +8,7 @@ import {
|
||||
useUpdateUserMutation,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export function useColorScheme() {
|
||||
export const useColorScheme = () => {
|
||||
const [currentUser, setCurrentUser] = useRecoilState(currentUserState);
|
||||
|
||||
const [updateUser] = useUpdateUserMutation();
|
||||
@ -106,4 +106,4 @@ export function useColorScheme() {
|
||||
colorScheme,
|
||||
setColorScheme,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@ -4,7 +4,7 @@ import { ColorScheme } from '~/generated/graphql';
|
||||
|
||||
type SystemColorScheme = ColorScheme.Light | ColorScheme.Dark;
|
||||
|
||||
export function useSystemColorScheme(): SystemColorScheme {
|
||||
export const useSystemColorScheme = (): SystemColorScheme => {
|
||||
const mediaQuery = useMemo(
|
||||
() => window.matchMedia('(prefers-color-scheme: dark)'),
|
||||
[],
|
||||
@ -22,11 +22,11 @@ export function useSystemColorScheme(): SystemColorScheme {
|
||||
return;
|
||||
}
|
||||
|
||||
function handleChange(event: MediaQueryListEvent): void {
|
||||
const handleChange = (event: MediaQueryListEvent): void => {
|
||||
setPreferredColorScheme(
|
||||
event.matches ? ColorScheme.Dark : ColorScheme.Light,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
mediaQuery.addEventListener('change', handleChange);
|
||||
|
||||
@ -36,4 +36,4 @@ export function useSystemColorScheme(): SystemColorScheme {
|
||||
}, [mediaQuery]);
|
||||
|
||||
return preferredColorScheme;
|
||||
}
|
||||
};
|
||||
|
||||
@ -2,6 +2,5 @@ import { mainColors, ThemeColor } from '../constants/colors';
|
||||
|
||||
export const COLORS = Object.keys(mainColors);
|
||||
|
||||
export function isThemeColor(color: string): color is ThemeColor {
|
||||
return COLORS.includes(color);
|
||||
}
|
||||
export const isThemeColor = (color: string): color is ThemeColor =>
|
||||
COLORS.includes(color);
|
||||
|
||||
Reference in New Issue
Block a user