Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update dependency eslint-plugin-react-refresh to v0.4.14 #1289

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ui/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions ui/src/components/theme-provider-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
* License-Filename: LICENSE
*/

import { useContext } from 'react';
import { createContext, useContext } from 'react';

import { ThemeProviderContext } from '@/components/theme-provider';
import {
initialState,
ThemeProviderState,
} from '@/components/theme-provider-state';

export const ThemeProviderContext =
createContext<ThemeProviderState>(initialState);

export const useTheme = () => {
const context = useContext(ThemeProviderContext);
Expand Down
30 changes: 30 additions & 0 deletions ui/src/components/theme-provider-state.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2024 The ORT Server Authors (See <https://github.com/eclipse-apoapsis/ort-server/blob/main/NOTICE>)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/

import { Theme } from '@/components/theme-provider';

export type ThemeProviderState = {
theme: Theme;
setTheme: (theme: Theme) => void;
};

export const initialState: ThemeProviderState = {
theme: 'light',
setTheme: () => null,
};
19 changes: 4 additions & 15 deletions ui/src/components/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,18 @@
* License-Filename: LICENSE
*/

import { createContext, useEffect, useState } from 'react';
import { useEffect, useState } from 'react';

type Theme = 'dark' | 'light' | 'system';
import { ThemeProviderContext } from '@/components/theme-provider-context';

export type Theme = 'dark' | 'light' | 'system';

type ThemeProviderProps = {
children: React.ReactNode;
defaultTheme?: Theme;
storageKey?: string;
};

type ThemeProviderState = {
theme: Theme;
setTheme: (theme: Theme) => void;
};

const initialState: ThemeProviderState = {
theme: 'light',
setTheme: () => null,
};

export const ThemeProviderContext =
createContext<ThemeProviderState>(initialState);

export function ThemeProvider({
children,
defaultTheme = 'light',
Expand Down