-
Notifications
You must be signed in to change notification settings - Fork 13
feat: themes #3
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
Open
nakajimayoshi
wants to merge
17
commits into
synapticsim:master
Choose a base branch
from
nakajimayoshi:themes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: themes #3
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e173527
squash commits
nakajimayoshi 99d168b
fixes
nakajimayoshi 2f2a836
remove logger
nakajimayoshi cce1b6e
amethyst-dark text color to uppercase
nakajimayoshi d68e972
resolve merge conflicts
nakajimayoshi 34c05b9
default theme not loading on init fixed
nakajimayoshi 34e653b
fix name capitlization
nakajimayoshi ca3d770
remove ghost logger
nakajimayoshi b564164
fix name capitlization with forced declaration of theme titles
nakajimayoshi 454bb68
fix fallback themeconfig missing field title
nakajimayoshi a850f8c
fix build errors
nakajimayoshi 06c90cd
fallback for theme title added
nakajimayoshi bc1a145
change fallback behavior for themes object
nakajimayoshi ace1fef
maybe finishing changes. maybe.
nakajimayoshi fcefe0e
Merge branch 'master' into themes
MikeRomaa cf96beb
Merge pull request #1 from synapticsim/master
nakajimayoshi b544733
Merge branch 'master' into themes
nakajimayoshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| module.exports = { | ||
| plugins: { | ||
| tailwindcss: {}, | ||
| autoprefixer: {}, | ||
| }, | ||
| } | ||
| plugins: { | ||
| 'tailwindcss/nesting': {}, | ||
| 'tailwindcss': {}, | ||
| 'autoprefixer': {}, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { MdSettings } from 'react-icons/md'; | ||
| import { Menu } from './index'; | ||
| import { ThemeButton, themeButtons } from './ThemeButton'; | ||
|
|
||
| interface SettingsMenuCanvasProps { | ||
| show?: boolean; | ||
| onClick?: () => void; | ||
| onExit?: () => void; | ||
| } | ||
|
|
||
| export const SettingsMenuCanvas: React.FC<SettingsMenuCanvasProps> = ({ ...props }) => ( | ||
| <Menu title="Settings" icon={<MdSettings size={25} />} {...props}> | ||
| <div className="px-6 py-5"> | ||
| <div className="container grid items-center mb-4"> | ||
| <h3>Theme</h3> | ||
| <ul> | ||
| {themeButtons.map((button) => ( | ||
| <li key={button.themeName}> | ||
| <ThemeButton {...button} /> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </Menu> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { useEffect, useState } from 'react'; | ||
| import { MdCheckCircle } from 'react-icons/md'; | ||
| import { useGlobalSelector, GlobalState, GlobalDispatch, useGlobalDispatch } from '../../redux/global'; | ||
| import { themeConfigs, fallbackThemeConfig, themes } from '../../redux/global/ui/uitheme'; | ||
| import { setTheme } from '../../redux/global/configSlice'; | ||
| import { Button } from '../Button'; | ||
|
|
||
| export interface ThemeButtonProps { | ||
| themeName: string; | ||
| title: string | undefined; | ||
| className?: string; | ||
| } | ||
|
|
||
| export const ThemeButton: React.FC<ThemeButtonProps> = ({ themeName, title, className }: ThemeButtonProps) => { | ||
| const globalDispatch = useGlobalDispatch<GlobalDispatch>(); | ||
|
|
||
| const { theme } = useGlobalSelector((state: GlobalState) => state.config); | ||
|
|
||
| const themeConfig = theme !== undefined ? theme : fallbackThemeConfig; | ||
|
|
||
| const { colors: { primary, secondary, text, padding, workspacePadding, background } } = themeConfig; | ||
|
|
||
| const [selected, setSelected] = useState(themeConfig.name === themeName); | ||
|
|
||
| const changeTheme = (name: string) => { | ||
| const newThemeConfig = themeConfigs.get(name); | ||
|
|
||
| if (newThemeConfig === undefined) { | ||
| console.error(`Theme ${name} not found.`); | ||
| return; | ||
| } | ||
|
|
||
| globalDispatch(setTheme(newThemeConfig)); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| setSelected(themeConfig.name === themeName); | ||
| }, [themeConfig, themeName]); | ||
|
|
||
| useEffect(() => { | ||
| document.documentElement.style.setProperty('--primary-color', primary); | ||
| document.documentElement.style.setProperty('--secondary-color', secondary); | ||
| document.documentElement.style.setProperty('--text-color', text); | ||
| document.documentElement.style.setProperty('--padding-color', padding); | ||
| document.documentElement.style.setProperty('--workspace-padding-color', workspacePadding); | ||
| document.documentElement.style.setProperty('--background-color', background); | ||
| }, [background, padding, primary, secondary, workspacePadding, text]); | ||
|
|
||
| return ( | ||
| <Button className={`flex w-64 ${className}`} onClick={() => changeTheme(themeName)}> | ||
| {selected | ||
| ? <MdCheckCircle className="mt-1 mx-4 transition-opacity duration-200 ease-in-out opacity-100" size={20} /> | ||
| : <MdCheckCircle className="mt-1 mx-4 transition-opacity duration-200 ease-in-out opacity-0" size={20} />} | ||
| {title} | ||
| </Button> | ||
| ); | ||
| }; | ||
|
|
||
| export const themeButtons = themes.map((theme) => { | ||
| let title; | ||
|
|
||
| if (theme.name.includes('flybywire')) { | ||
| title = 'FlyByWire'; | ||
| } else { | ||
| title = theme.name.split('-').map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' '); | ||
| } | ||
|
|
||
| return { | ||
| themeName: theme.name, | ||
| title: theme.title, | ||
| className: 'hover:font-semibold', | ||
| }; | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.