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

Create "light mode" theme #2959

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9b049b2
the rerender works! Added the type, the preference to the global sto…
jls47 Aug 23, 2023
7d543c7
rudimentary light mode switch for web contents
jls47 Aug 25, 2023
e989f6e
not fully responsive yet, but address bar colors updated
jls47 Sep 18, 2023
b14e24d
sidebar now responsive
jls47 Sep 23, 2023
a7f748f
saving progress
jls47 Sep 26, 2023
708f86a
adding state checking causes crash. Wish Node had GDB!
jls47 Oct 1, 2023
264f2c0
currently crashes the app soon as web contents load. time to investi…
jls47 Oct 4, 2023
4f948b3
still flashing but functional
jls47 Oct 4, 2023
71d2a01
no luck with webview just yet
jls47 Oct 5, 2023
6a9ab5e
browserpage the last holdout
jls47 Oct 9, 2023
1aafb2c
found it thanks to a previous tip from leafo. Not reactive yet but f…
jls47 Oct 9, 2023
5972c5f
responsive enough to test?
jls47 Oct 10, 2023
1f41089
github not tracking non-default commits apparently
jls47 Oct 10, 2023
9a2e844
its -almost- there. I cant figure out the difference between disable…
jls47 Oct 10, 2023
0848842
its -almost- there. I cant figure out the difference between disable…
jls47 Oct 10, 2023
c7f459b
its -almost- there. I cant figure out the difference between disable…
jls47 Oct 10, 2023
09cfa29
sweet victory, the browser window now updates. On to the url bar.
jls47 Oct 10, 2023
7fc12e9
browser address bar now responsive
jls47 Oct 11, 2023
ab76388
final commit and cleanup. Added details to user agent, pruned code e…
jls47 Oct 13, 2023
0db80cc
Merge pull request #1 from itchio/master
jls47 Feb 17, 2024
39c0aef
Merge branch 'itchio:master' into i164
jls47 Feb 28, 2024
f0a3d80
updated navigation color, removed comments, simplified user agent
jls47 Mar 6, 2024
6f0df93
updated advanced settings text, pruned some comments, changed to ligh…
jls47 Mar 7, 2024
b35fd57
changed sortsandfilters back to props basetext, modified BrothCompone…
jls47 Mar 7, 2024
5a88a6d
manage modal color change
jls47 Mar 11, 2024
1cadace
game description text color
jls47 Mar 28, 2024
40c8655
Updating descText: secondaryText ref doesn't work
jls47 Apr 10, 2024
73a372c
Merge branch 'itchio:master' into i164
jls47 Jul 1, 2024
334944f
Merge branch 'itchio:master' into i164
jls47 Oct 14, 2024
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
1 change: 1 addition & 0 deletions src/common/reducers/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const initialState = {
preferOptimizedPatches: false,
disableBrowser: env.integrationTests ? true : false,
enableTabs: false,
lightMode: false,
} as PreferencesState;

export default reducer<PreferencesState>(initialState, (on) => {
Expand Down
3 changes: 3 additions & 0 deletions src/common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ export interface PreferencesState {
/** when closing window, keep running in tray */
closeToTray: boolean;

/** toggle light mode on or off */
lightMode: boolean;

/** notify when a download has been installed or updated */
readyNotification: boolean;

Expand Down
7 changes: 7 additions & 0 deletions src/main/reactors/winds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,13 @@ function getIconPath(): string {
function commonBrowserWindowOpts(
store: Store
): Partial<BrowserWindowConstructorOptions> {
logger.debug("---");
logger.debug("---");
logger.debug("---");
logger.debug("Common browser window opts");
logger.debug("---");
logger.debug("---");
logger.debug("---");
return {
icon: getIconPath(),
autoHideMenuBar: true,
Expand Down
9 changes: 7 additions & 2 deletions src/renderer/App/Modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ import styled, * as styles from "renderer/styles";
import { T, TString } from "renderer/t";
import { filter, isEmpty, map } from "underscore";
import { isSecretClick } from "common/helpers/secret-click";
import { lightTheme } from "renderer/lightTheme";

const HoverCover = Hoverable(Cover);

type Flavor = "normal" | "big";

let lColor = global.ReduxStore.getState().preferences.lightMode
? lightTheme.colors.ivory
: styles.colors.ivory;

const ModalPortalDiv = styled.div`
position: fixed;
top: 0;
Expand Down Expand Up @@ -149,10 +154,10 @@ const ModalsDiv = styled.div`
}

a {
color: darken($ivory, 5%);
color: darken(${lColor}, 5%);

&:hover {
color: $ivory;
color: ${lColor};
cursor: pointer;
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const Profiler = require("react").unstable_Profiler;
import { IntlProvider } from "react-intl";
import { hook } from "renderer/hocs/hook";
import { theme, ThemeProvider } from "renderer/styles";
import { lightTheme } from "renderer/lightTheme";
import AppContents from "renderer/App/AppContents";
import { isEqual } from "underscore";

Expand All @@ -17,6 +18,7 @@ class App extends React.PureComponent<Props, State> {
messages: {},
localeMessages: {},
fallbackMessages: {},
lightMode: false,
};
}

Expand All @@ -42,10 +44,11 @@ class App extends React.PureComponent<Props, State> {

realRender() {
const { localeVersion, locale, messages } = this.state;
const { lightMode } = this.props;

return (
<IntlProvider key={localeVersion} locale={locale} messages={messages}>
<ThemeProvider theme={theme}>
<ThemeProvider theme={lightMode ? lightTheme : theme}>
<AppContents />
</ThemeProvider>
</IntlProvider>
Expand All @@ -70,6 +73,7 @@ class App extends React.PureComponent<Props, State> {
...props.fallbackMessages,
...props.localeMessages,
},
lightMode: props.lightMode,
};
}
return null;
Expand All @@ -84,6 +88,7 @@ interface Props {
fallbackMessages: {
[id: string]: string;
};
lightMode: boolean;
}

interface State {
Expand All @@ -99,6 +104,7 @@ interface State {
fallbackMessages: {
[id: string]: string;
};
lightMode: boolean;
}

const emptyObj = {};
Expand All @@ -110,4 +116,5 @@ export default hook((map) => ({
return strings[lang] || strings[lang.substring(0, 2)] || emptyObj;
}),
fallbackMessages: map((rs) => rs.i18n.strings.en || emptyObj),
lightMode: map((rs) => rs.preferences.lightMode),
}))(App);
21 changes: 10 additions & 11 deletions src/renderer/basics/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ const Label = styled.div`
${styles.singleLine};
`;

const buttonBackground = `
hsla(355, 40%, 21%, 1),
hsla(355, 40%, 32%, 1)`;

const primaryBackground = `
hsla(355, 50%, 32%, 1),
hsla(355, 50%, 48%, 1)`;
const ButtonDiv = styled.div`
${styles.singleLine};
transition: all 0.2s;
Expand All @@ -20,17 +27,13 @@ const ButtonDiv = styled.div`
border-width: 4px 1px 1px 1px;
border-radius: 3px;

background-image: linear-gradient(
10deg,
hsla(355, 40%, 21%, 1),
hsla(355, 40%, 32%, 1)
);
background-image: linear-gradient(10deg, ${buttonBackground});
border-color: hsla(355, 40%, 44%, 1);

box-shadow: 0 1px 3px ${(props) => props.theme.inputBoxShadow};
text-shadow: 0px 1px rgba(0, 0, 0, 0.4);

color: ${(props) => props.theme.baseText};
color: #fffff0;
min-height: 38px;
min-width: 7em;

Expand All @@ -45,11 +48,7 @@ const ButtonDiv = styled.div`

&.primary {
font-weight: bold;
background-image: linear-gradient(
10deg,
hsla(355, 50%, 32%, 1),
hsla(355, 50%, 48%, 1)
);
background-image: linear-gradient(10deg, ${primaryBackground});
border-color: hsla(355, 40%, 52%, 1);
}

Expand Down
75 changes: 74 additions & 1 deletion src/renderer/basics/NavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ const browserAddressStyle = css`
}
`;

const lightBrowserAddressStyle = css`
${browserAddressSizing};
${styles.singleLine};
font-size: 14px;
text-shadow: 0 0 1px black;
padding: 0;
padding-left: 8px;
padding-right: 12px;
width: 100%;
color: #333333;

border: none;
background: rgba(200, 200, 200, 0.7);
box-shadow: none;

&:focus {
outline: none;
}
`;

const AddressWrapper = styled.div`
${browserAddressSizing};
margin: 0 6px;
Expand All @@ -101,6 +121,13 @@ const AddressInput = styled.input`
color: white;
`;

const LightAddressInput = styled.input`
${lightBrowserAddressStyle};

text-shadow: 0 0 1px transparent;
color: black;
`;

const AddressDiv = styled.div`
${browserAddressStyle};

Expand All @@ -113,6 +140,18 @@ const AddressDiv = styled.div`
}
`;

const LightAddressDiv = styled.div`
${lightBrowserAddressStyle};

.security-theater-bit {
color: rgb(108, 145, 85);
}

.fluff-bit {
color: rgb(75, 121, 166);
}
`;

function isHTMLInput(el: HTMLElement): el is HTMLInputElement {
return el.tagName === "INPUT";
}
Expand Down Expand Up @@ -201,14 +240,45 @@ class NavigationBar extends React.PureComponent<Props, State> {
}

renderAddressBar() {
const { loading, url } = this.props;
const { loading, url, lightMode } = this.props;

if (!this.props.showAddressBar) {
return null;
}

let { editingAddress } = this.state;

if (lightMode) {
return (
<>
{loading ? (
<IconButton icon="cross" onClick={this.stop} />
) : (
<IconButton icon="repeat" onClick={this.reload} />
)}
<AddressWrapper className={classNames({ editing: editingAddress })}>
{editingAddress ? (
<LightAddressInput
className="browser-address"
type="search"
ref={this.onBrowserAddress as any}
defaultValue={url}
onKeyDown={this.addressKeyDown}
onBlur={this.addressBlur}
/>
) : (
<LightAddressDiv
className={classNames("browser-address")}
ref={this.onBrowserAddress}
onClick={this.startEditingAddress}
>
{this.renderURL(url)}
</LightAddressDiv>
)}
</AddressWrapper>
</>
);
}
return (
<>
{loading ? (
Expand Down Expand Up @@ -345,11 +415,13 @@ interface Props {
internalPage: string;
canGoBack: string;
canGoForward: string;
lightMode: boolean;
}

interface State {
url: string;
editingAddress: boolean;
lightMode: boolean;
}

export default withTab(
Expand All @@ -360,5 +432,6 @@ export default withTab(
),
canGoBack: map((rs, props) => ambientTab(rs, props).status.canGoBack),
canGoForward: map((rs, props) => ambientTab(rs, props).status.canGoForward),
lightMode: map((rs) => rs.preferences.lightMode),
}))(NavigationBar)
);
11 changes: 8 additions & 3 deletions src/renderer/global-styles/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { css, theme } from "renderer/styles";
import { lightTheme } from "renderer/lightTheme";
import env from "renderer/env";

const currentTheme = global.ReduxStore.getState().preferences.lightMode
? lightTheme
: theme;

const testDisables = () => {
if (!env.integrationTests) {
return css``;
Expand Down Expand Up @@ -33,7 +38,7 @@ export default css`
user-select: none;

font-family: LatoWeb, sans-serif;
color: ${theme.baseText};
color: ${currentTheme.baseText};
}

img.emojione {
Expand All @@ -46,10 +51,10 @@ export default css`
}

a {
color: ${theme.accent};
color: ${currentTheme.accent};

&[href^="itch:"] {
color: ${theme.baseText};
color: ${currentTheme.baseText};
text-decoration: none;

&:hover {
Expand Down
Loading