Skip to content

Commit

Permalink
Add FAB
Browse files Browse the repository at this point in the history
  • Loading branch information
taysea committed Mar 14, 2024
1 parent 0d2f090 commit bd4a2b7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sandbox/grommet-app/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Home from './pages/index';
import NextDashboard from './pages/next/index';
import { Login } from './Login';
import { GlobalHeader } from './components/GlobalHeader';
import { FloatingActionButton } from './components';

export const BackgroundContext = createContext({});

Expand Down Expand Up @@ -39,6 +40,7 @@ const App = () => {
cssGap: true,
},
}}
style={{ display: 'relative' }}
>
{authenticated ? (
<BackgroundContext.Provider value={contextValue}>
Expand All @@ -56,6 +58,9 @@ const App = () => {
<Route path="/next" element={<NextDashboard />} />
</Routes>
</BrowserRouter>
{window.location.pathname === '/next' ? (
<FloatingActionButton label="Ask HPE" />
) : undefined}
</BackgroundContext.Provider>
) : (
<Login setAuthenticated={setAuthenticated} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import styled from 'styled-components';
import { Box, Button } from 'grommet';

const PositionedBox = styled(Box)`
position: fixed;
bottom: 0px;
border-radius: 2em;
right: 0px;
z-index: 10;
`;

export const FloatingActionButton = ({ ...rest }) => {
return (
<PositionedBox elevation="large" margin="medium">
<Button {...rest} kind="fab" size="large" />
</PositionedBox>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './FloatingActionButton';
1 change: 1 addition & 0 deletions sandbox/grommet-app/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './NotificationMetric';
export * from './ContentPane';
export * from './GlobalHeader';
export * from './ToggleGroup';
export * from './FloatingActionButton';
16 changes: 16 additions & 0 deletions sandbox/grommet-app/src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ const buildTheme = tokens => {
light: light.color.chart.qualitative['70-secondary'].$value,
dark: dark.color.chart.qualitative['70-secondary'].$value,
},
'background-brand-default': {
light: light.color.background.brand.default.$value,
dark: dark.color.background.brand.default.$value,
},
'background-brand-weak': {
light: light.color.background.brand.weak.$value,
dark: dark.color.background.brand.weak.$value,
Expand All @@ -292,6 +296,11 @@ const buildTheme = tokens => {
light: light.color.foreground.status.info.$value,
dark: dark.color.foreground.status.info.$value,
},

'foreground-onBrand': {
light: light.color.foreground.onBrand.$value,
dark: dark.color.foreground.onBrand.$value,
},
'button-secondary-border-default': {
light: light.color.button.secondary.border.default.$value,
dark: dark.color.button.secondary.border.default.$value,
Expand Down Expand Up @@ -329,6 +338,13 @@ const buildTheme = tokens => {
weight: 600,
},
},
fab: {
background: 'background-brand-default',
color: 'foreground-onBrand',
font: {
weight: 600,
},
},
tab: {
color: 'text-strong',
font: {
Expand Down

0 comments on commit bd4a2b7

Please sign in to comment.