1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

better sidepane

This commit is contained in:
muerwre 2019-07-26 14:00:53 +07:00
parent 1b001db91a
commit e315b33284
19 changed files with 253 additions and 99 deletions

View file

@ -7,6 +7,7 @@ interface IProps {
width?: number;
title?: string;
is_hero?: boolean;
is_stamp?: boolean;
}
const Cell: FC<IProps> = ({
@ -14,6 +15,7 @@ const Cell: FC<IProps> = ({
height = 1,
title,
is_hero,
is_stamp,
}) => (
<div
className={classNames(styles.cell, { is_hero })}

View file

@ -1,5 +1,6 @@
import * as React from 'react';
import { Cell } from "~/components/flow/Cell";
import { range } from 'ramda';
const style = require('./style.scss');
@ -11,13 +12,14 @@ export const TestGrid = () => (
title="Example cell Example cell Example cell Example cell Example cell Example cell Example cell "
is_hero
/>
<Cell />
<Cell
height={2}
title="Example cell Example cell Example cell Example cell Example cell Example cell Example cell "
/>
<Cell width={2} />
<Cell />
{
range(1,20).map(el => (
<Cell
width={1}
height={1}
title="Example cell Example cell Example cell Example cell Example cell Example cell Example cell "
/>
))
}
</div>
);

View file

@ -7,8 +7,8 @@ import { userSendLoginRequest, userSetLoginError } from "~/redux/user/actions";
import { IUserFormStateLogin, IUserState } from "~/redux/user/reducer";
import { Info } from "~/components/input/Info";
const login = require('~/containers/LoginLayout/style');
const style = require('./style.scss');
import * as login from '~/containers/login/LoginLayout/styles.scss';
import * as style from './style.scss';
interface ILoginFormProps {
error: IUserFormStateLogin['error'],

View file

@ -1,25 +1,38 @@
import React, { useEffect, useState } from 'react';
import React, { FC, LegacyRef, ReactChild, useCallback, useEffect, useState } from 'react';
import * as styles from './styles.scss';
import classNames from 'classnames';
export const SidePane = ({ }) => {
interface IProps {
container: React.RefObject<HTMLDivElement>;
}
export const SidePane: FC<IProps> = ({
container,
}) => {
const [left, setLeft] = useState(0);
const moveThis = () => {
const shift = ((document.body.getBoundingClientRect().width - 1024) / 2) - 54 - 10;
const moveThis = useCallback(() => {
const shift = window.innerWidth > (1024 + 64 + 20)
? ((window.innerWidth - 1024 - 64 - 20) / 2) - 54 - 10 + 64
: 10;
setLeft(shift);
};
console.log({ shift });
}, [setLeft, container]);
useEffect(() => {
window.addEventListener('resize', moveThis)
moveThis();
window.addEventListener('resize', moveThis);
document.addEventListener('DOMContentLoaded', moveThis);
return () => { window.removeEventListener('resize', moveThis); }
});
useEffect(moveThis, []);
return () => {
window.removeEventListener('resize', moveThis);
document.removeEventListener('DOMContentLoaded', moveThis);
}
}, [container]);
return (
<div className={styles.pane} style={{ left }}>
<div className={styles.pane} style={{ transform: `translate(${left}px, 0px)` }}>
<div className={classNames(styles.group, 'logo')} />
<div className={styles.group}>

View file

@ -5,8 +5,10 @@ import { hot } from 'react-hot-loader';
import { ConnectedRouter } from "connected-react-router";
import { history } from "~/redux/store";
import { NavLink, Switch, Route } from 'react-router-dom';
import { FlowLayout } from "~/containers/FlowLayout";
import { LoginLayout } from "~/containers/LoginLayout";
import { FlowLayout } from "~/containers/flow/FlowLayout";
import { LoginLayout } from "~/containers/login/LoginLayout";
import { MainLayout } from "~/containers/main/MainLayout";
import { ImageExample } from "~/containers/examples/ImageExample";
interface IAppProps {}
interface IAppState {}
@ -15,19 +17,17 @@ class Component extends React.Component<IAppProps, IAppState> {
render() {
return (
<ConnectedRouter history={history}>
<div>
<MainLayout>
<Switch>
<Route
exact
path="/"
component={FlowLayout}
/>
<Route path="/examples/image" component={ImageExample} />
<Route path="/" component={FlowLayout} />
<Route
path="/login"
component={LoginLayout}
/>
</Switch>
</div>
</MainLayout>
</ConnectedRouter>
);
}

View file

@ -1,13 +0,0 @@
import * as React from 'react';
import { MainLayout } from "~/containers/MainLayout";
import { HeroPlaceholder } from "~/components/flow/HeroPlaceholder";
import { TestGrid } from "~/components/flow/TestGrid";
// const style = require('./style.scss');
export const FlowLayout = () => (
<MainLayout>
<div className="default_container content_container">
<TestGrid />
</div>
</MainLayout>
);

View file

@ -1,17 +0,0 @@
import * as React from 'react';
import { SidePane } from "~/components/main/SidePane";
import { Header } from "~/components/main/Header";
import * as styles from './styles.scss';
export const MainLayout = ({ children }) => (
<div className={styles.wrapper}>
{
// <Header />
}
{
<SidePane />
}
{children}
</div>
);

View file

@ -1,4 +0,0 @@
.wrapper {
width: 100%;
padding: $gap 0;
}

View file

@ -0,0 +1,9 @@
import React, { FC } from 'react';
interface IProps {}
const ImageExample: FC<IProps> = () => (
<div>image example</div>
);
export { ImageExample };

View file

@ -0,0 +1,10 @@
import * as React from 'react';
import { MainLayout } from "~/containers/main/MainLayout";
import { TestGrid } from "~/components/flow/TestGrid";
// const style = require('./style.scss');
export const FlowLayout = () => (
<div className="default_container content_container">
<TestGrid />
</div>
);

View file

@ -3,15 +3,15 @@ import { LoginForm } from '~/components/login/LoginForm';
import { Header } from "~/components/main/Header";
import { GodRays } from "~/components/main/GodRays";
const style = require('./style.scss');
import * as styles from './styles.scss';
export const LoginLayout: React.FunctionComponent<{}> = () => (
<div className={style.wrapper}>
<div className={styles.wrapper}>
<GodRays />
<div className={style.header}>
<div className={styles.header}>
<Header />
</div>
<div className={style.container}>
<div className={styles.container}>
<LoginForm />
</div>
</div>

View file

@ -0,0 +1,18 @@
import * as React from 'react';
import { SidePane } from "~/components/main/SidePane";
import * as styles from './styles.scss';
import { useRef } from "react";
export const MainLayout = ({ children }) => {
const container = useRef(null);
return (
<div className={styles.wrapper}>
<div className={styles.content} ref={container}>
{children}
</div>
<SidePane container={container} />
</div>
);
};

View file

@ -0,0 +1,15 @@
.wrapper {
width: 100%;
padding: $gap $gap 0 74px;
display: flex;
align-items: flex-start;
justify-content: center;
flex-direction: row;
box-sizing: border-box;
}
.content {
flex: 0 1 $content_width;
position: relative;
background: red;
}

View file

@ -0,0 +1,10 @@
import React, { FC } from 'react';
import * as styles from './styles.scss';
interface IProps {}
const NodeLayout: FC<IProps> = () => (
<div></div>
);
export { NodeLayout };

View file

@ -1,9 +1,3 @@
/*
LAYOUT PACKING:
https://github.com/rexxars/react-layout-pack
https://github.com/gxapplications/react-gridifier
https://github.com/STRML/react-grid-layout
*/
import * as React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';