is prettier

This commit is contained in:
Nicola Brunner 2020-03-24 16:03:08 +01:00
parent 10aeb75730
commit 580511ce6e
3 changed files with 130 additions and 124 deletions

View file

@ -5,14 +5,11 @@ import {
BrowserView,
MobileView,
isBrowser,
isMobile
isMobile,
} from "react-device-detect";
const AvatarImage = () => (
<Image
src="avatar3.png"
style={{ width: "25px", height: "auto" }}
centered />
<Image src="avatar3.png" style={{ width: "25px", height: "auto" }} centered />
);
const IconHomeImage = () => (
@ -35,13 +32,7 @@ const IconHomeImageMobile = () => (
/>
);
const TitleImage = () => (
<Image
src="title7.png"
size="medium"
centered
/>
);
const TitleImage = () => <Image src="title7.png" size="medium" centered />;
const BrowserStructure = (props) => (
<Grid columns="equal" divided inverted padded>
@ -90,7 +81,7 @@ const MobileStructure = (props) => (
<Grid.Column>
<IconHomeImage />
</Grid.Column>
<Grid.Column >
<Grid.Column>
<AvatarImage />
<Divider />
<Dropdown item icon="setting" size="huge">
@ -113,13 +104,6 @@ const MobileStructure = (props) => (
</Grid>
);
export default class MyHeader extends React.Component {
render() {
return (

View file

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Button, Grid, Responsive } from 'semantic-ui-react'
import React, { Component } from "react";
import { Button, Grid, Responsive } from "semantic-ui-react";
export default class SelectIcons extends Component {
constructor(props) {
@ -31,8 +31,7 @@ export default class SelectIcons extends Component {
return (
<Grid centered relaxed>
{
myicons.map((e, i) => {
{myicons.map((e, i) => {
return (
<Grid.Row key={i}>
{e.map((e, i) => {

View file

@ -7,17 +7,17 @@ import {
Input,
Icon,
Responsive,
Image
Image,
} from "semantic-ui-react";
import SelectIcons from "./SelectIcons";
const NO_IMAGE="https://react.semantic-ui.com/images/wireframe/image.png";
const NO_IMAGE = "https://react.semantic-ui.com/images/wireframe/image.png";
export default class ModalWindow extends Component {
constructor(props) {
super(props);
console.table(this.props);
console.table(this.props);
this.state = {
id: "",
@ -90,8 +90,7 @@ console.table(this.props);
reader.onerror = console.error;
}
render(){
render() {
const spaceDiv = {
background: "#f4f4f4",
padding: "10px 10px",
@ -115,81 +114,105 @@ console.table(this.props);
<Button icon fluid labelPosition="left" onClick={this.openModal}>
<Icon name="plus" size="small" />
ADD ROOM
</Button>)
:
<Icon name='pencil' size='small' onClick={this.openModal} />
}
</Button>
) : (
<Icon name="pencil" size="small" onClick={this.openModal} />
)}
</Responsive>
<Responsive maxWidth={768} >
{
this.props.type === "new" ?
<Button icon fluid labelPosition='left' onClick={this.openModal}>
<Icon name='plus' size='small'/>
<Responsive maxWidth={768}>
{this.props.type === "new" ? (
<Button icon fluid labelPosition="left" onClick={this.openModal}>
<Icon name="plus" size="small" />
ADD ROOM
</Button>
:
<Button icon fluid labelPosition='left' onClick={this.openModal}>
<Icon name='pencil' size='small'/>
) : (
<Button icon fluid labelPosition="left" onClick={this.openModal}>
<Icon name="pencil" size="small" />
EDIT ROOM
</Button>
}
)}
</Responsive>
<Modal
onClose={this.closeModal}
open={this.state.openModal}>
<Header>{this.props.type === "new" ? "Add new room" : "Modify room" }</Header>
<Modal onClose={this.closeModal} open={this.state.openModal}>
<Header>
{this.props.type === "new" ? "Add new room" : "Modify room"}
</Header>
<Modal.Content>
<Form>
<p>Insert the name of the room:</p>
<Form.Field>
<Input
label='Room name'
placeholder='Room Name'
label="Room name"
placeholder="Room Name"
name="name"
type='text'
type="text"
onChange={this.changeSomething}
value={this.state.name}/>
value={this.state.name}
/>
</Form.Field>
<p>Insert an image of the room:</p>
<Form.Field>
<Image
src={this.state.img == null ? NO_IMAGE : this.state.img}
size='small'
onClick={() => this.fileInputRef.current.click()}/>
<input ref={this.fileInputRef} hidden label='Room image' type='file' name="img" accept="image/png, image/jpeg"
onChange={this.getBase64.bind(this)}/>
size="small"
onClick={() => this.fileInputRef.current.click()}
/>
<input
ref={this.fileInputRef}
hidden
label="Room image"
type="file"
name="img"
accept="image/png, image/jpeg"
onChange={this.getBase64.bind(this)}
/>
</Form.Field>
</Form>
<div style={spaceDiv}>
<p>Select an icon:</p>
<SelectIcons updateIcon={this.updateIcon} currentIcon={this.props.type === "new" ? "home" : this.props.idRoom.icon }/>
<SelectIcons
updateIcon={this.updateIcon}
currentIcon={
this.props.type === "new" ? "home" : this.props.idRoom.icon
}
/>
</div>
{this.props.type === "modify" ?
<Button icon labelPosition='left' inverted color='red' onClick={this.deleteRoom}>
<Icon name='trash alternate' />
{this.props.type === "modify" ? (
<Button
icon
labelPosition="left"
inverted
color="red"
onClick={this.deleteRoom}
>
<Icon name="trash alternate" />
Delete room
</Button> : null }
</Button>
) : null}
</Modal.Content>
<Modal.Actions>
<Button color='red' onClick={this.closeModal}>
<Icon name='remove' /> {this.props.type === "new" ? "Cancel" : "Discard changes" }
<Button color="red" onClick={this.closeModal}>
<Icon name="remove" />{" "}
{this.props.type === "new" ? "Cancel" : "Discard changes"}
</Button>
<Button color='green' onClick={this.props.type === "new" ? this.addRoomModal : this.modifyRoomModal}>
<Icon name='checkmark' /> {this.props.type === "new" ? "Add room" : "Save changes"}
<Button
color="green"
onClick={
this.props.type === "new"
? this.addRoomModal
: this.modifyRoomModal
}
>
<Icon name="checkmark" />{" "}
{this.props.type === "new" ? "Add room" : "Save changes"}
</Button>
</Modal.Actions>
</Modal>
</div>
)
);
}
}