Skip to content

Commit

Permalink
feat: footer left and right customization
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Aug 5, 2020
1 parent eea21a6 commit 66e08b5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
5 changes: 5 additions & 0 deletions core/core/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ export interface RunOnlyConfiguration {
*/
toolbar?: ToolbarConfig;

/**
* custom footer items
*/
footer?: ToolbarConfig;

/**
* custom props to components
* ex:
Expand Down
38 changes: 29 additions & 9 deletions ui/app/src/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/** @jsx jsx */
import { FC } from 'react';
import { FC, useMemo } from 'react';
import { Text, Flex, Link, jsx } from 'theme-ui';
import { useConfig } from '@component-controls/store';
import { ActionBar, ActionItems } from '@component-controls/components';

/**
* application footer component
Expand All @@ -13,18 +14,37 @@ export const Footer: FC = () => {
siteUrl,
siteTitle,
siteCopyright = `Copyright \u00A9 ${new Date().getFullYear()}`,
footer,
} = config || {};
if (siteCopyright || author) {
return (
<Flex as="footer" variant="appfooter.container">
<Text variant="appfooter.copyright">
{`${siteCopyright}${author ? `by ${author}` : ''}`}
</Text>
<Flex variant="appfooter.inner">
const leftActions: ActionItems = useMemo(() => {
const actions: ActionItems = [];
if (siteCopyright || author) {
actions.push({
node: <Text>{`${siteCopyright}${author ? ` by ${author}` : ''}`}</Text>,
});
}
return footer.left ? [...actions, ...footer.left] : actions;
}, [footer.left, siteCopyright, author]);

const rightActions: ActionItems = useMemo(() => {
const actions: ActionItems = [];
if (siteTitle) {
actions.push({
node: (
<Link aria-label="visit project home page" href={siteUrl}>
{siteTitle}
</Link>
</Flex>
),
});
}
return footer.right ? [...footer.right, ...actions] : actions;
}, [footer.right, siteTitle, siteUrl]);

if (leftActions.length || rightActions.length) {
return (
<Flex as="footer" variant="appfooter.container">
<ActionBar themeKey="footer" actions={leftActions} />
<ActionBar themeKey="footer" actions={rightActions} />
</Flex>
);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/components/src/ActionBar/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface ActionBarProps {
/**
* two possible layouts from the theme
*/
themeKey?: 'actionbar' | 'toolbar';
themeKey?: 'actionbar' | 'toolbar' | 'footer';
}

/**
Expand Down
6 changes: 0 additions & 6 deletions ui/components/src/ThemeContext/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,12 +906,6 @@ export const theme: ControlsTheme = {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
},
copyright: {},
inner: {
alignItems: `center`,
color: `text`,
fontWeight: `heading`,
a: { color: `text` },
},
},
Expand Down

0 comments on commit 66e08b5

Please sign in to comment.