frontend/smart-hut/src/components/HeaderController.js

137 lines
3.2 KiB
JavaScript
Raw Normal View History

2020-03-19 10:52:13 +00:00
import React from "react";
2020-03-23 20:24:17 +00:00
import { Dropdown, Icon, Grid, Divider } from "semantic-ui-react";
import { Segment, Image } from "semantic-ui-react";
import {
BrowserView,
MobileView,
isBrowser,
isMobile
} from "react-device-detect";
2020-03-21 15:06:18 +00:00
const AvatarImage = () => (
<Image
src="avatar3.png"
style={{ width: "25px", height: "auto" }}
centered />
2020-03-23 20:24:17 +00:00
);
2020-03-23 20:24:17 +00:00
const IconHomeImage = () => (
<Image
src="smart-home.png"
style={{ width: "50px", height: "auto" }}
centered
as="a"
href="/"
/>
);
const IconHomeImageMobile = () => (
<Image
src="smart-home.png"
style={{ width: "10px", height: "auto" }}
centered
as="a"
href="/"
/>
);
const TitleImage = () => (
<Image
src="title7.png"
size="medium"
centered
/>
);
const BrowserStructure = (props) => (
2020-03-23 20:24:17 +00:00
<Grid columns="equal" divided inverted padded>
<Grid.Row color="black" textAlign="center">
<Grid.Column width={3} height={0.5}>
<Segment color="black" inverted>
<IconHomeImage />
</Segment>
</Grid.Column>
<Grid.Column>
<Segment color="black" inverted>
2020-03-21 15:06:18 +00:00
<TitleImage />
2020-03-23 20:24:17 +00:00
</Segment>
</Grid.Column>
<Grid.Column width={2} heigth={1}>
<AvatarImage />
<Divider />
2020-03-23 20:24:17 +00:00
<Dropdown item icon="setting" size="huge">
<Dropdown.Menu>
<Dropdown.Item>
<Icon name="dropdown" />
<span className="text">Settings</span>
<Dropdown.Menu>
<Dropdown.Item>Document</Dropdown.Item>
<Dropdown.Item>Image</Dropdown.Item>
</Dropdown.Menu>
</Dropdown.Item>
<Dropdown.Item>See profile...</Dropdown.Item>
<Dropdown.Divider />
<Dropdown.Item onClick={props.logout}>Logout</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Grid.Column>
</Grid.Row>
</Grid>
2020-03-23 20:24:17 +00:00
);
const MobileStructure = (props) => (
<Grid columns="equal" divided inverted padded>
<Grid.Row color="black" textAlign="center">
<Segment color="black" inverted>
<TitleImage />
</Segment>
</Grid.Row>
<Grid.Row color="black" textAlign="center">
<Grid.Column>
<IconHomeImage />
</Grid.Column>
<Grid.Column >
<AvatarImage />
<Divider />
<Dropdown item icon="setting" size="huge">
<Dropdown.Menu>
<Dropdown.Item>
<Icon name="dropdown" />
<span className="text">Settings</span>
<Dropdown.Menu>
<Dropdown.Item>Document</Dropdown.Item>
<Dropdown.Item>Image</Dropdown.Item>
</Dropdown.Menu>
</Dropdown.Item>
<Dropdown.Item>See profile...</Dropdown.Item>
<Dropdown.Divider />
<Dropdown.Item onClick={props.logout}>Logout</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Grid.Column>
</Grid.Row>
</Grid>
);
2020-03-23 20:24:17 +00:00
2020-03-23 20:24:17 +00:00
2020-03-23 20:24:17 +00:00
export default class MyHeader extends React.Component {
render() {
return (
<div>
<BrowserView>
<BrowserStructure logout={this.props.logout} />
</BrowserView>
<MobileView>
<MobileStructure />
</MobileView>
</div>
);
}
}