Skip to content

Commit bc5530f

Browse files
committed
apply styles
1 parent 54517c2 commit bc5530f

File tree

3 files changed

+93
-44
lines changed

3 files changed

+93
-44
lines changed

src/components/TextWidget/editor.tsx

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React, { Component } from 'react';
2+
import styled from 'styled-components';
3+
import { TextField, Button, Typography } from '@material-ui/core';
24
import { FirebaseDatabaseMutation } from '@react-firebase/database'
35
import type { TextWidgetProps } from '@/components/TextWidget/types';
46

@@ -7,6 +9,18 @@ type Props = {
79
props: TextWidgetProps;
810
};
911

12+
const FormGroup = styled.div`
13+
display: flex;
14+
margin-bottom: 1rem;
15+
width: 480px;
16+
& > label {
17+
width: 20%;
18+
}
19+
& > input {
20+
flex-grow: 1;
21+
}
22+
`;
23+
1024
class TextWidgetEditor extends Component<Props, TextWidgetProps> {
1125
constructor(props) {
1226
super(props);
@@ -16,28 +30,41 @@ class TextWidgetEditor extends Component<Props, TextWidgetProps> {
1630
render() {
1731
return (
1832
<div>
19-
<label>
20-
text:
21-
<input
33+
<Typography variant="h6">
34+
TextWidget : {this.props.id}
35+
</Typography>
36+
<FormGroup>
37+
<TextField
2238
type="text"
39+
label="text"
40+
fullWidth
41+
multiline={true}
42+
variant="outlined"
2343
onChange={(e) => {
2444
this.setState({ ...this.state, text: e.target.value });
2545
}}
2646
value={this.state.text}
2747
/>
28-
</label>
48+
</FormGroup>
2949

30-
<FirebaseDatabaseMutation type="set" path={`/widgets/${this.props.id}/props`}>
50+
<FirebaseDatabaseMutation
51+
type="set"
52+
path={`/widgets/${this.props.id}/props`}
53+
>
3154
{({ runMutation }) => {
3255
return (
33-
<button
34-
onClick={async (e: Event) => {
35-
e.preventDefault();
36-
await runMutation(this.state);
37-
}}
38-
>
39-
Save
40-
</button>
56+
<FormGroup>
57+
<Button
58+
color="primary"
59+
variant="contained"
60+
onClick={async (e: Event) => {
61+
e.preventDefault();
62+
await runMutation(this.state);
63+
}}
64+
>
65+
Save
66+
</Button>
67+
</FormGroup>
4168
);
4269
}}
4370
</FirebaseDatabaseMutation>

src/components/admin/SignInForm/index.tsx

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
import React, { VFC, useEffect, useState } from 'react';
22
import styled from 'styled-components';
3+
import { TextField, Button } from '@material-ui/core';
34
import { auth } from '@/lib/firebase';
45

5-
const Button = styled.button`
6-
padding: 0.5rem 1rem;
7-
color: #fff;
8-
background-color: #33bbff;
9-
border-radius: 0.25rem;
10-
cursor: pointer;
11-
&:hover {
12-
background-color: #1188dd;
13-
}
14-
`;
15-
166
const FormGroup = styled.div`
177
display: flex;
188
margin-bottom: 1rem;
@@ -25,11 +15,6 @@ const FormGroup = styled.div`
2515
}
2616
`;
2717

28-
const Input = styled.input`
29-
outline: 1px solid #eee;
30-
padding: 0.25rem 0.5rem;
31-
`;
32-
3318
type SignInFormProps = {
3419
redirectTo: string;
3520
};
@@ -50,22 +35,24 @@ const SignInForm: VFC<SignInFormProps> = ({ redirectTo }) => {
5035
return (
5136
<form onSubmit={signin}>
5237
<FormGroup>
53-
<label>Email</label>
54-
<Input
38+
<TextField
5539
type="email"
40+
label="Email"
5641
placeholder="example@example.com"
42+
fullWidth
5743
onChange={(e) => setEmail(e.target.value)}
5844
/>
5945
</FormGroup>
6046
<FormGroup>
61-
<label>Password</label>
62-
<Input
47+
<TextField
6348
type="password"
49+
label="Password"
50+
fullWidth
6451
onChange={(e) => setPassword(e.target.value)}
6552
/>
6653
</FormGroup>
6754
<div>
68-
<Button type="submit">
55+
<Button variant="contained" color="primary" type="submit">
6956
Sign In
7057
</Button>
7158
</div>

src/components/admin/index.tsx

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
import React, { VFC, useEffect, useState } from 'react';
2+
import {
3+
makeStyles,
4+
CssBaseline,
5+
Container,
6+
Box,
7+
AppBar,
8+
Toolbar,
9+
Typography,
10+
Button
11+
} from '@material-ui/core';
212
import { User } from '@firebase/auth-types';
313
import { FirebaseDatabaseNode } from '@react-firebase/database';
414
import { AuthProvider } from '@/lib/AuthProvider';
@@ -10,6 +20,15 @@ const Editors = {
1020
'text': TextWidgetEditor,
1121
};
1222

23+
const useStyles = makeStyles((theme) => ({
24+
root: {
25+
flexGrow: 1,
26+
},
27+
title: {
28+
flexGrow: 1,
29+
},
30+
}));
31+
1332
const Widgets: VFC = () => {
1433
return (
1534
<div>
@@ -32,6 +51,7 @@ const Widgets: VFC = () => {
3251
}
3352

3453
const Index: VFC = () => {
54+
const classes = useStyles();
3555
const [currentUser, setCurrentUser] = useState<User | null>(null);
3656

3757
useEffect(() => {
@@ -49,16 +69,31 @@ const Index: VFC = () => {
4969
};
5070

5171
return currentUser !== null ? (
52-
<AuthProvider>
53-
<h1>Admin</h1>
54-
<div>{currentUser?.displayName}</div>
55-
<button onClick={signout}>Sign Out</button>
56-
<Widgets />
57-
</AuthProvider>
58-
) : (
59-
<Signin />
60-
)
61-
;
72+
<AuthProvider>
73+
<CssBaseline />
74+
<div className={classes.root}>
75+
<AppBar position="static">
76+
<Toolbar>
77+
<Typography variant="h6" className={classes.title}>
78+
Admin
79+
</Typography>
80+
<Typography>{currentUser.email}</Typography>
81+
<Button color="inherit" onClick={signout}>
82+
Logout
83+
</Button>
84+
</Toolbar>
85+
</AppBar>
86+
87+
<Container>
88+
<Box my={4}>
89+
<Widgets />
90+
</Box>
91+
</Container>
92+
</div>
93+
</AuthProvider>
94+
) : (
95+
<Signin />
96+
);
6297
};
6398

6499
export { Index };

0 commit comments

Comments
 (0)