added 3 column layout to footer

This commit is contained in:
Sebastian Sdorra
2020-02-19 13:35:04 +01:00
parent a83ef175be
commit 8e39d53add
4 changed files with 106 additions and 41 deletions

View File

@@ -6,6 +6,7 @@ import { Me } from "@scm-manager/ui-types";
import { EXTENSION_POINT } from "../avatar/Avatar"; import { EXTENSION_POINT } from "../avatar/Avatar";
// @ts-ignore ignore unknown png // @ts-ignore ignore unknown png
import avatar from "../__resources__/avatar.png"; import avatar from "../__resources__/avatar.png";
import NavLink from "../navigation/NavLink";
const trillian: Me = { const trillian: Me = {
name: "trillian", name: "trillian",
@@ -24,6 +25,7 @@ const bindAvatar = (binder: Binder) => {
const bindLinks = (binder: Binder) => { const bindLinks = (binder: Binder) => {
binder.bind("footer.links", () => <a href="#">REST API</a>); binder.bind("footer.links", () => <a href="#">REST API</a>);
binder.bind("footer.links", () => <a href="#">CLI</a>); binder.bind("footer.links", () => <a href="#">CLI</a>);
binder.bind("profile.setting", () => <NavLink label="Authorized Keys" to="#" />);
}; };
const withBinder = (binder: Binder) => { const withBinder = (binder: Binder) => {

View File

@@ -1,8 +1,11 @@
import React, { FC } from "react"; import React, { FC } from "react";
import { Me, Links } from "@scm-manager/ui-types"; import { Me, Links } from "@scm-manager/ui-types";
import { Link } from "react-router-dom"; import { useBinder, ExtensionPoint } from "@scm-manager/ui-extensions";
import { useBinder } from "@scm-manager/ui-extensions"; import { AvatarImage } from "../avatar";
import { AvatarWrapper, AvatarImage } from "../avatar"; import NavLink from "../navigation/NavLink";
import FooterSection from "./FooterSection";
import styled from "styled-components";
import { EXTENSION_POINT } from "../avatar/Avatar";
type Props = { type Props = {
me?: Me; me?: Me;
@@ -10,51 +13,81 @@ type Props = {
links: Links; links: Links;
}; };
type TitleWithIconsProps = {
title: string;
icon: string;
};
const TitleWithIcon: FC<TitleWithIconsProps> = ({ icon, title }) => (
<>
<i className={`fas fa-${icon} fa-fw`} /> {title}
</>
);
type TitleWithAvatarProps = {
me: Me;
};
const VCenteredAvatar = styled(AvatarImage)`
vertical-align: middle;
`;
const AvatarContainer = styled.span`
float: left;
margin-right: 0.3em;
padding-top: 0.2em;
width: 1em;
height: 1em;
`;
const TitleWithAvatar: FC<TitleWithAvatarProps> = ({ me }) => (
<>
<AvatarContainer className="image is-rounded">
<VCenteredAvatar person={me} representation="rounded" />
</AvatarContainer>
{me.displayName}
</>
);
const Footer: FC<Props> = ({ me, version, links }) => { const Footer: FC<Props> = ({ me, version, links }) => {
const binder = useBinder(); const binder = useBinder();
if (!me) { if (!me) {
return null; return null;
} }
const extensionProps = { me, links }; const extensionProps = { me, url: "/me", links };
const extensions = binder.getExtensions("footer.links", extensionProps); let meSectionTile;
if (binder.hasExtension(EXTENSION_POINT)) {
meSectionTile = <TitleWithAvatar me={me} />;
} else {
meSectionTile = <TitleWithIcon title={me.displayName} icon="user-circle" />;
}
return ( return (
<footer className="footer"> <footer className="footer">
<div className="container is-centered has-text-centered "> <section className="section container">
<p className="is-size-6 columns is-centered"> <div className="columns is-size-7">
<AvatarWrapper> <FooterSection title={meSectionTile}>
<figure className="media-left"> <NavLink to="#" label="Profile" />
<p className="image is-24x24 is-rounded"> <NavLink to="#" label="Change Password" />
<AvatarImage person={me} representation="rounded" /> <ExtensionPoint name="profile.setting" props={extensionProps} renderAll={true} />
</p> </FooterSection>
</figure> <FooterSection title={<TitleWithIcon title="Information" icon="info-circle" />}>
</AvatarWrapper> <a href="https://www.scm-manager.org/" target="_blank">
<Link to={"/me"}>{me.displayName}</Link> SCM-Manager {version}
</p> </a>
<hr className={"has-background-grey-lighter"} /> <ExtensionPoint name="footer.links" props={extensionProps} renderAll={true} />
<p> </FooterSection>
<a href="https://www.scm-manager.org/" target="_blank"> <FooterSection title={<TitleWithIcon title="About" icon="external-link-alt" />}>
SCM-Manager {version} <a href="https://www.scm-manager.org/" target="_blank">
</a> Learn more
{extensions.map(Ext => ( </a>
<> <a target="_blank" href="https://cloudogu.com/">
{" "} Powered by Cloudogu
| <Ext {...extensionProps} /> </a>
</> <ExtensionPoint name="footer.links" props={extensionProps} renderAll={true} />
))} </FooterSection>
</p> </div>
<br /> </section>
<p>
Powered by{" "}
<a target="_blank" href="https://cloudogu.com/">
Cloudogu GmbH
</a>{" "}
| Learn more about{" "}
<a href="https://www.scm-manager.org/" target="_blank">
SCM-Manager
</a>
</p>
</div>
</footer> </footer>
); );
}; };

View File

@@ -0,0 +1,30 @@
import React, { FC, ReactNode } from "react";
import styled from "styled-components";
type Props = {
title: ReactNode;
};
const Title = styled.div`
font-weight: bold;
margin-bottom: 0.5rem;
`;
const Menu = styled.ul`
padding-left: 1.1rem;
`;
const FooterSection: FC<Props> = ({ title, children }) => {
return (
<section className="column is-one-third">
<Title>{title}</Title>
<Menu>
{React.Children.map(children, (child, index) => (
<li key={index}>{child}</li>
))}
</Menu>
</section>
);
};
export default FooterSection;

View File

@@ -70,7 +70,7 @@ hr.header-with-actions {
footer.footer { footer.footer {
//height: 100px; //height: 100px;
background-color: whitesmoke; background-color: whitesmoke;
padding: 2rem 1.5rem 1rem; padding: inherit;
} }
// 6. Import the rest of Bulma // 6. Import the rest of Bulma