Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(AppBar): move appbar from brand #3038

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/gamut/__tests__/__snapshots__/gamut.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ exports[`Gamut Exported Keys 1`] = `
"Alert",
"Anchor",
"AnchorBase",
"AppBar",
"AppBarSection",
"AppWrapper",
"Badge",
"BodyPortal",
Expand Down
34 changes: 34 additions & 0 deletions packages/gamut/src/AppBar/AppBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'react';

import { ContentContainer } from '../ContentContainer';
import { WithChildrenProp } from '../utils';

export interface AppBarProps
extends WithChildrenProp,
Pick<React.ComponentProps<typeof ContentContainer>, 'aria-label' | 'as'> {
/**
* Whether the container should be larger than the default content size.
*/
wide?: boolean;
}

export const AppBar: React.FC<AppBarProps> = ({
'aria-label': ariaLabel,
as,
wide,
children,
}) => {
return (
<ContentContainer
aria-label={ariaLabel}
as={as}
display="flex"
alignItems="center"
height="100%"
size={wide ? 'wide' : 'medium'}
zIndex={14}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like an arbitrary value lol
should it always be 14? should/could this value potentially be set by a prop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeha that makes sense, i'll make it a prop

>
{children}
</ContentContainer>
);
};
46 changes: 46 additions & 0 deletions packages/gamut/src/AppBar/AppBarSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { styledOptions, variant } from '@codecademy/gamut-styles';
import { StyleProps } from '@codecademy/variance';
import styled from '@emotion/styled';
import * as React from 'react';

import { WithChildrenProp } from '../utils';

const positionVariants = variant({
prop: 'position',
base: {
display: 'flex',
alignItems: 'center',
height: '100%',
zIndex: 1,
},
variants: {
left: {
flex: 1,
},
right: {
flex: 1,
justifyContent: 'flex-end',
},
center: {
flex: 2,
justifyContent: 'center',
textAlign: 'center',
},
},
});

export interface AppBarSectionProps
extends StyleProps<typeof positionVariants>,
WithChildrenProp {}

const StyledSection = styled(
'div',
styledOptions
)<AppBarSectionProps>(positionVariants);

export const AppBarSection: React.FC<AppBarSectionProps> = ({
position,
children,
}) => {
return <StyledSection position={position}>{children}</StyledSection>;
};
2 changes: 2 additions & 0 deletions packages/gamut/src/AppBar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './AppBar';
export * from './AppBarSection';
1 change: 1 addition & 0 deletions packages/gamut/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './AccordionButtonDeprecated';
export * from './Alert';
export * from './Anchor';
export * from './Animation';
export * from './AppBar';
export * from './AppWrapper';
export * from './Badge';
export * from './BodyPortal';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Meta } from '@storybook/blocks';

import { AboutHeader, TableOfContents } from '~styleguide/blocks';

export const parameters = {
id: 'Organisms/Headers & Footers',
title: 'Headers & Footers',
subtitle:
'Components related to header and footers, sometimes used within larger organisms and page layouts.',
};

<Meta title="Organisms/Headers & Footers/About" />

<AboutHeader {...parameters} />

These are the platform agnostic parts of the page that are used to provide structure and layout to the page. They are not specific to any one page or layout, but are used across the site to provide a consistent look and feel.

<br />

<TableOfContents
links={[
{
id: 'Organisms/Headers & Footers/AppBar',
subtitle:
'Components that provide spacing and layout help that you can use for something like a footer or header',
title: 'AppBar',
status: 'current',
},
]}
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Canvas, Controls, Meta, Story } from '@storybook/blocks';

import { ComponentHeader } from '~styleguide/blocks';

import * as AppBarStories from './AppBar.stories';

export const parameters = {
subtitle: `Components that provide spacing and layout help that you can use for something like a footer or header`,
status: 'current',
};

<Meta of={AppBarStories} />

<ComponentHeader {...parameters} />

This is an example of an AppBar component that contains one left-oriented AppBarSection that holds one AppBar Tab.

<Canvas>
<Story of={AppBarStories.Default} />
</Canvas>

<Controls />

## Header

This is an example of how our headers use the AppBar component to format various sections in a bar (left, center, and right). The AppBar can hold as many AppBarSections as you'd like.

<Canvas>
<Story of={AppBarStories.Header} />
</Canvas>
Comment on lines +28 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason this shows up in the page as the default story —
You can change it: <Canvas of={AppBarStories.Header} /> to get it show properly

It'd also be good to include a playground section below this and maybe format the whole story closer to the other stories we use for gamut's story pages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i just did a straight copy-paste, i'll fix it more

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { AppBar, AppBarSection, Logo } from '@codecademy/gamut';

export default {
component: AppBar,
subcomponents: {
AppBarSection,
},
};

export const Default = {
render: () => (
<AppBar>
<AppBarSection position="left">In Left Position</AppBarSection>
</AppBar>
),
name: 'AppBar',
};

export const Header = {
render: () => (
<AppBar>
<AppBarSection position="left">
<Logo />
</AppBarSection>
<AppBarSection position="center">Pricing</AppBarSection>
<AppBarSection position="right">Sign In</AppBarSection>
</AppBar>
),
name: 'Header',
};
Loading