Skip to content

Commit

Permalink
tab colors
Browse files Browse the repository at this point in the history
Co-authored-by: lleyton <[email protected]>
  • Loading branch information
Adam and lleyton committed Oct 24, 2021
1 parent 4cada21 commit f25f857
Show file tree
Hide file tree
Showing 71 changed files with 440 additions and 158 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "skye",
"version": "6.0.3-nightly.5",
"version": "6.0.3-nightly.6",
"sideEffects": false,
"description": "Extensible, fast and innovative web browser with material UI.",
"keywords": [
Expand Down Expand Up @@ -110,6 +110,7 @@
"@fortawesome/free-solid-svg-icons": "^6.0.0-beta2",
"@fortawesome/react-fontawesome": "^0.1.16",
"electron-chrome-extensions": "^3.8.0",
"hex-to-rgb": "^1.0.1",
"jwt-decode": "^3.1.2",
"patch-package": "^6.4.7",
"postinstall-postinstall": "^2.1.0"
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface IBookmark {
isFolder?: boolean;
parent?: string;
order?: number;
color?: string;
expanded?: boolean;
static?: 'mobile' | 'main' | 'other' | 'pinned';
children?: string[];
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ export type BrowserActionChangeType =
| 'setPopup'
| 'setBadgeText'
| 'setTitle'
| 'setColor'
| 'setIcon'
| 'setBadgeBackgroundColor';

export const BROWSER_ACTION_METHODS: BrowserActionChangeType[] = [
'setPopup',
'setBadgeText',
'setTitle',
'setColor',
'setIcon',
'setBadgeBackgroundColor',
];
1 change: 1 addition & 0 deletions src/interfaces/history-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface IHistoryItem {
title?: string;
url?: string;
date?: number;
color?: string;
favicon?: string;
hovered?: boolean;
}
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/news-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface INewsItem {
};
author: string;
title: string;
color: string;
description: string;
url: string;
urlToImage: string;
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/startup-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface IStartupTab {
title?: string;
url?: string;
favicon?: string;
color?: string;
order?: number;
pinned?: boolean;
isUserDefined?: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type TabEvent =
| 'load-commit'
| 'url-updated'
| 'title-updated'
| 'color-updated'
| 'favicon-updated'
| 'did-navigate'
| 'loading'
Expand Down
3 changes: 3 additions & 0 deletions src/main/dialogs/add-bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const showAddBookmarkDialog = (
data?: {
url: string;
title: string;
color: string;
bookmark?: IBookmark;
favicon?: string;
},
Expand All @@ -18,11 +19,13 @@ export const showAddBookmarkDialog = (
const {
url,
title,
color,
bookmark,
favicon,
} = Application.instance.windows.current.viewManager.selected;
data = {
url,
color,
title,
bookmark,
favicon,
Expand Down
2 changes: 2 additions & 0 deletions src/main/dialogs/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class PreviewDialog extends PersistentDialog {
const {
id,
url,
color,
title,
errorURL,
} = Application.instance.windows
Expand All @@ -41,6 +42,7 @@ export class PreviewDialog extends PersistentDialog {
id,
url: url.startsWith(`${ERROR_PROTOCOL}://`) ? errorURL : url,
title,
color,
x: this.tab.x - 8,
});
}
Expand Down
1 change: 1 addition & 0 deletions src/main/menus/bookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function createMenu(appWindow: AppWindow, item: IBookmark) {
showAddBookmarkDialog(appWindow.win, windowBounds.width - 20, 72, {
url: item.url,
title: item.title,
color: item.color,
bookmark: item,
favicon: item.favicon,
});
Expand Down
13 changes: 12 additions & 1 deletion src/main/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class View {
public isNewTab = false;
public homeUrl: string;
public favicon = '';
public color = '';
public incognito = false;

public errorURL = '';
Expand Down Expand Up @@ -115,6 +116,13 @@ export class View {
this.updateURL(this.webContents.getURL());
});

this.webContents.addListener('did-change-theme-color', (e, color) => {
this.updateData();
console.log(color);
this.emitEvent('color-updated', color);
this.updateURL(this.webContents.getURL());
});

this.webContents.addListener('did-navigate', async (e, url) => {
this.emitEvent('did-navigate', url);

Expand Down Expand Up @@ -349,6 +357,7 @@ export class View {
) {
const historyItem: IHistoryItem = {
title: this.title,
color: this.color,
url,
favicon: this.favicon,
date: new Date().getTime(),
Expand Down Expand Up @@ -403,7 +412,7 @@ export class View {
if (!this.incognito) {
const id = this.lastHistoryId;
if (id) {
const { title, url, favicon } = this;
const { title, color, url, favicon } = this;

this.historyQueue.enqueue(async () => {
await Application.instance.storage.update({
Expand All @@ -413,6 +422,7 @@ export class View {
},
value: {
title,
color,
url,
favicon,
},
Expand All @@ -425,6 +435,7 @@ export class View {

if (item) {
item.title = title;
item.color = color;
item.url = url;
item.favicon = favicon;
}
Expand Down
9 changes: 8 additions & 1 deletion src/main/windows-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@ export class WindowsService {

if (!win) throw new Error('Window not found');

const view = win.viewManager.create(details);
const view = win.viewManager.create(details, false, false);
win.webContents.send('create-tab', { ...details }, false, view.id);

await new Promise((resolve) => {
ipcMain.once('create-tab-reply-' + view.id, resolve);
});

return [view.webContents, win.win];
},
selectTab: (tab, window) => {
const win = this.list.find((x) => x.win.id === window.id);
win.viewManager.select(tab.id, true);
win.send('select-tab-id', tab.id);
},
removeTab: (tab, window) => {
const win = this.list.find((x) => x.win.id === window.id);
Expand Down
2 changes: 1 addition & 1 deletion src/main/windows/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class AppWindow {
public constructor(incognito: boolean) {
this.win = new BrowserWindow({
frame: false,
minWidth: 400,
minWidth: 900,
minHeight: 450,
width: 900,
height: 700,
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/Button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const StyledButton = styled.div<ButtonProps>`
align-items: center;
justify-content: center;
overflow: hidden;
border-radius: 8px;
border-radius: 6px;
position: relative;
cursor: pointer;
Expand All @@ -38,11 +38,11 @@ export const StyledButton = styled.div<ButtonProps>`
${({ background, foreground, type }) => css`
color: ${foreground || '#fff'};
border: ${type === 'outlined'
? `1px solid ${background || '#2196F3'}`
? `1px solid ${background || '#1E6FEB'}`
: 'unset'};
background-color: ${type === 'outlined'
? 'transparent'
: background || '#2196F3'};
: background || '#1E6FEB'};
&::before {
background-color: ${foreground || '#fff'};
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/GlobalNavigationDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const MenuItem = observer(

export const GlobalNavigationDrawer = () => {
return (
<NavigationDrawer dense title="">
<NavigationDrawer dense title="" global>
<MenuItem name="settings" global>
<FontAwesomeIcon icon={ICON_SETTINGS} fixedWidth />
</MenuItem>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ITheme } from '~/interfaces';
import { centerIcon } from '~/renderer/mixins';

export const Control = css`
height: 32px;
height: 40px;
position: relative;
border: none;
outline: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const NavigationDrawerItem = observer(
<StyledNavigationDrawerItem
title={children}
onClick={onClick}
selected={selected}
global={global}
>
{icon && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,35 @@ import { transparency } from '~/renderer/constants';
interface NavigationDrawerItemProps {
theme?: ITheme;
global?: boolean;
selected?: boolean;
}
export const StyledNavigationDrawerItem = styled.div<NavigationDrawerItemProps>`
display: flex;
height: 40px;
border-radius: 4px;
align-items: center;
position: relative;
border-radius: 8px;
cursor: pointer;
${({ theme, global }) => css`
${({ theme, global, selected }) => css`
&:hover {
background-color: ${theme['backgroundColor']};
background-color: ${global ? 'transparent' : theme['backgroundColor']};
}
${selected &&
!global && {
backgroundColor: theme['backgroundColor'],
}}
${selected &&
global && {
color: '#1E6FEB',
}}
${global && {
fontSize: 18,
}}
padding-left: ${global ? '0' : '10px'};
padding-right: ${global ? '0' : '10px'};
justify-content: ${global ? 'center' : 'left'};
`};
`;
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/components/NavigationDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const NavigationDrawer = ({
onSearchInput,
style,
dense,
global,
}: {
children?: any;
title?: string;
Expand All @@ -25,6 +26,7 @@ export const NavigationDrawer = ({
onBackClick?: (e?: React.MouseEvent<HTMLDivElement>) => void;
style?: any;
dense?: boolean;
global?: boolean;
}) => {
return (
<StyledNavigationDrawer style={style} dense={dense}>
Expand All @@ -38,7 +40,7 @@ export const NavigationDrawer = ({
<Input placeholder="Search" onInput={onSearchInput} />
</Search>
)}
<MenuItems>{children}</MenuItems>
<MenuItems global={global}>{children}</MenuItems>
</StyledNavigationDrawer>
);
};
Expand Down
10 changes: 9 additions & 1 deletion src/renderer/components/NavigationDrawer/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,22 @@ export const StyledNavigationDrawer = styled.div<NavigationDrawerProps>`
`}
`;

export const MenuItems = styled.div`
export const MenuItems = styled.div<{
global?: boolean;
}>`
display: flex;
flex-flow: column;
flex: 1;
margin-top: 10px;
padding-bottom: 24px;
overflow: hidden auto;
${noButtons('6px', 'rgba(0, 0, 0, 0.04)', 'rgba(0, 0, 0, 0.12)')};
${({ global }) => css`
margin-left: ${global ? '0' : '-10px'};
margin-right: ${global ? '0' : '-10px'};
justify-content: ${global ? 'center' : 'left'};
gap: ${global ? '30px' : '0'};
`}
`;

export const Header = styled.div`
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/RadioButton/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled, { css } from 'styled-components';

import { transparency, BLUE_500 } from '~/renderer/constants';
import { robotoRegular } from '~/renderer/mixins';
import { interRegular } from '~/renderer/mixins';
import { ITheme } from '~/interfaces';

export const Container = styled.div`
Expand Down Expand Up @@ -106,5 +106,5 @@ export const Label = styled.div`
font-size: 14px;
color: rgba(0, 0, 0, ${transparency.text.high});
margin-left: 8px;
${robotoRegular()};
${interRegular()};
`;
8 changes: 4 additions & 4 deletions src/renderer/components/Textfield/style.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import styled, { css } from 'styled-components';

import {
robotoRegular,
interRegular,
centerVertical,
robotoMedium,
interMedium,
centerIcon,
coloredCursor,
} from '~/renderer/mixins';
Expand Down Expand Up @@ -42,7 +42,7 @@ export const Input = styled.input<InputProps>`
outline: none;
background-color: transparent;
user-select: auto;
${robotoRegular()};
${interRegular()};
${({ color, hasLabel, hasIcon, dark }) => css`
padding-top: ${hasLabel ? 12 : 0}px;
Expand Down Expand Up @@ -88,7 +88,7 @@ export const Label = styled.div<LabelProps>`
: dark
? `rgba(255, 255, 255, ${transparency.text.medium})`
: `rgba(0, 0, 0, ${transparency.text.medium})`};
${activated ? robotoMedium() : robotoRegular()};
${activated ? interMedium() : interRegular()};
`}
`;

Expand Down
Loading

0 comments on commit f25f857

Please sign in to comment.