Skip to content

Commit

Permalink
feat: added header component (#55)
Browse files Browse the repository at this point in the history
closes #54
  • Loading branch information
danilolutz authored Nov 25, 2021
1 parent c670382 commit 8236aa3
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 22 deletions.
7 changes: 3 additions & 4 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { DefaultTheme, ThemeProvider } from 'styled-components';
import LanguageSelector from './components/I18n/LanguageSelector';
import Translator from './components/I18n/Translator';
import usePersistedState from './hooks/usePersistedState';
import FormBook from './components/Book/FormBook';

import GlobalStyle from './styles/global';
import light from './styles/themes/light';
import dark from './styles/themes/dark';
import Header from './components/Header';

const App: React.FC = () => {
const [theme, setTheme] = usePersistedState<DefaultTheme>(
Expand All @@ -30,12 +30,11 @@ const App: React.FC = () => {

return (
<ThemeProvider theme={theme}>
<header>
<Header>
<LanguageSelector />
</header>
</Header>
<div>
<Translator path="home.message" />
<FormBook></FormBook>
</div>
<GlobalStyle />
</ThemeProvider>
Expand Down
13 changes: 13 additions & 0 deletions src/app/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

import { Container } from './styles';

const Header: React.FC = ({children}) => {
return (
<Container>
{children}
</Container>
);
};

export default Header;
9 changes: 9 additions & 0 deletions src/app/components/Header/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from 'styled-components';

export const Container = styled.div`
display: flex;
height: 56px;
background: ${(props) => props.theme.colors.header.background};
align-items: center;
padding: 16px;
`;
4 changes: 4 additions & 0 deletions src/app/styles/styled.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ declare module 'styled-components' {
secondary: string;
background: string;
text: string;

header: {
background: string;
}
}
}
}
4 changes: 4 additions & 0 deletions src/app/styles/themes/dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ export default {
secondary: '#FF8700',
background: '#16161D',
text: '#CCCCCC',

header: {
background: '#34343D',
}
}
};
4 changes: 4 additions & 0 deletions src/app/styles/themes/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ export default {
secondary: '#D77D13',
background: '#D7D7DD',
text: '#8A8A8A',

header: {
background: '#E7E7EE',
}
}
};
Binary file modified src/database/database.sqlite
Binary file not shown.
21 changes: 13 additions & 8 deletions src/database/migration/1637762838040-create_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ export class createSettings1637762838040 implements MigrationInterface {
await queryRunner.createTable(new Table({
name: "settings",
columns: [
{
name: "days_return_date",
type: "int",
},
{
name: "backup_path",
type: "varchar",
}
{
name: "id",
type: "int",
isPrimary: true
},
{
name: "days_return_date",
type: "int",
},
{
name: "backup_path",
type: "varchar",
}
]
}), true)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {MigrationInterface, QueryRunner, Table, TableForeignKey} from "typeorm";

export class createUser1637784086085 implements MigrationInterface {
export class createUser1637774086085 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(new Table({
name: "user",
columns: [
{
name: "id",
name: "id",
type: "int",
isPrimary: true
},
Expand Down Expand Up @@ -55,7 +55,7 @@ export class createUser1637784086085 implements MigrationInterface {

const userTypeId = table.foreignKeys.find(fk => fk.columnNames.indexOf("user_type_id") !== -1);
await queryRunner.dropForeignKey("user", userTypeId);

await queryRunner.dropTable("user");
}

Expand Down
20 changes: 19 additions & 1 deletion src/electron/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import { Country } from './database/models/country.schema';
import { Publisher } from './database/models/publisher.schema';
import { Category } from './database/models/category.schema';
import { Author } from './database/models/author.schema';
import { TitlePublisher } from './database/models/title_publisher.schema';
import { Contact } from './database/models/contact.schema';
import { Region } from './database/models/region.schema';

declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
Expand All @@ -49,7 +52,22 @@ export default class Main {
logging: true,
logger: 'simple-console',
database: './src/database/database.sqlite',
entities: [Title, User, Author, Program, Category, Publisher, Country, Profile, TypeUser, ContactType, Settings],
entities: [
Title,
TitlePublisher,
User,
Author,
Program,
Category,
Publisher,
Region,
Country,
Profile,
TypeUser,
ContactType,
Contact,
Settings
],
});
}

Expand Down
3 changes: 3 additions & 0 deletions src/electron/database/models/settings.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';

@Entity()
export class Settings {
@PrimaryGeneratedColumn()
id: number;

@Column()
days_return_date: number;

Expand Down
6 changes: 0 additions & 6 deletions src/electron/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
margin: auto;
max-width: 38rem;
padding: 2rem;
}

0 comments on commit 8236aa3

Please sign in to comment.