-
Notifications
You must be signed in to change notification settings - Fork 30
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
base: main
Are you sure you want to change the base?
Changes from all commits
64aede5
2bfc910
33ec331
3a0f7dc
82d68c9
68d35f6
23d79f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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} | ||
> | ||
{children} | ||
</ContentContainer> | ||
); | ||
}; |
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>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './AppBar'; | ||
export * from './AppBarSection'; |
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 — 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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', | ||
}; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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