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

Feat dark mode #167

Merged
merged 27 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ae6361a
feat(Theme): impl pref
h13i32maru Sep 12, 2020
385919e
feat(theme): app theme
h13i32maru Sep 12, 2020
42e602e
refactor(appTheme): bg
h13i32maru Sep 12, 2020
acef95f
refactor(appTheme): bgSide
h13i32maru Sep 12, 2020
37dde78
reafctor(appTheme): bg.hover
h13i32maru Sep 12, 2020
544d6e8
refactor(appTheme): bg.primarySoft
h13i32maru Sep 12, 2020
77301e7
refactor(appTheme): border
h13i32maru Sep 12, 2020
cc46b7e
refactor(appTheme): text.normal
h13i32maru Sep 12, 2020
22db0e0
refactor(appTheme): text.soft
h13i32maru Sep 12, 2020
e084a6e
refactor(appTheme): text.tiny
h13i32maru Sep 12, 2020
73b3425
refactor(appTheme): icon.normal
h13i32maru Sep 12, 2020
8190456
refactor(appTheme): icon.soft
h13i32maru Sep 12, 2020
959a5a7
refactor(appTheme): icon.tiny
h13i32maru Sep 12, 2020
122800e
refactor(appTheme):
h13i32maru Sep 12, 2020
4d25095
refactor(appTheme):
h13i32maru Sep 12, 2020
1fe8402
refactor(appTheme):
h13i32maru Sep 12, 2020
ed82f01
refactor(appTheme):
h13i32maru Sep 12, 2020
da5d1b5
refactor(appTheme):
h13i32maru Sep 12, 2020
c24e20f
feat(appTheme): dark theme
h13i32maru Sep 12, 2020
fb5d598
fix(appTheme):
h13i32maru Sep 12, 2020
ae1ee72
fix(appTheme): text.link
h13i32maru Sep 12, 2020
e189b46
fix(appTheme): apply immediate
h13i32maru Sep 12, 2020
7047f76
fix(darkreader): copy at postinstall
h13i32maru Sep 12, 2020
33ac484
fix(darkreader): cross origin
h13i32maru Sep 12, 2020
353014b
fix(theme): apply when switch pref
h13i32maru Sep 12, 2020
3c0157c
refactor(appTheme): accent.normal
h13i32maru Sep 12, 2020
411c7a7
refactor(appTheme): accent.soft
h13i32maru Sep 12, 2020
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
Prev Previous commit
Next Next commit
fix(darkreader): copy at postinstall
  • Loading branch information
h13i32maru committed Sep 12, 2020
commit 7047f76f398c3a3eb909144f455afe9b5d753622
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/misc/logo/jasper.icns
/misc/data
/.idea
/src/Renderer/Fragment/Browser/BrowserFragmentAsset/darkreader.js
7 changes: 6 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
"linux:build": "./script/linux/build.sh",
"linux:sqlite": "./script/linux/build-sqlite.sh",
"tsc:watch": "./script/tsc/watch.sh",
"postinstall": "rm -rf node_modules/@types/react-native"
"postinstall": "./script/npm/postinstall.sh"
},
"dependencies": {
"@mdi/font": "^5.5.55",
"darkreader": "^4.9.17",
"diff": "3.5.0",
"electron-window-state": "^5.0.3",
"escape-html": "1.0.3",
Expand Down
10 changes: 10 additions & 0 deletions script/npm/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -x

# styled-componentsによってreact-nativeの型がインストールされてしまう
# しかしこれがTSの組み込み型と競合してエラーになるので削除してしまう
rm -rf node_modules/@types/react-native

# darkreader.jsをファイルとして読み込みたいのでコピーする
cp -f node_modules/darkreader/darkreader.js src/Renderer/Fragment/Browser/BrowserFragmentAsset/

# todo mdiのcssファイルなどもコピーする
14 changes: 14 additions & 0 deletions src/Renderer/Fragment/Browser/BrowserCodeExecFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class BrowserCodeExecFragment extends React.Component<Props, State> {
private readonly jsDetectInput: string;
private readonly jsGetIssueState: string;
private readonly jsProjectBoard: string;
private readonly jsDarkReader: string;

private projectStream: StreamEntity | null;

Expand All @@ -59,6 +60,7 @@ export class BrowserCodeExecFragment extends React.Component<Props, State> {
this.jsDetectInput = fs.readFileSync(`${dir}/detect-input.js`).toString();
this.jsGetIssueState = fs.readFileSync(`${dir}/get-issue-state.js`).toString();
this.jsProjectBoard = fs.readFileSync(`${dir}/project-board.js`).toString();
this.jsDarkReader = fs.readFileSync(`${dir}/darkreader.js`).toString();
}

componentDidMount() {
Expand All @@ -70,6 +72,7 @@ export class BrowserCodeExecFragment extends React.Component<Props, State> {
this.setupShowDiffBody();
this.setupGetIssueState();
this.setupProjectBoard();
this.setupDarkReader();

IssueEvent.onSelectIssue(this, (issue, readBody) => this.setState({issue, readBody}));
}
Expand Down Expand Up @@ -291,6 +294,17 @@ export class BrowserCodeExecFragment extends React.Component<Props, State> {
}
}

private setupDarkReader() {
const js = `
${this.jsDarkReader}
DarkReader.enable({brightness: 100, contrast: 100});
`;
BrowserViewIPC.onEventDOMReady(() => {
const theme = UserPrefRepo.getPref().general.style.themeMode;
if (theme === 'dark') BrowserViewIPC.executeJavaScript(js);
});
}

private isTargetIssuePage() {
// if (!this.state.issue) return false;
//
Expand Down