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

feat: #253 new app-bar (existing app switcher) #261

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,50 @@ exports[`TopBar Snapshot > should match snapshot 1`] = `
<DocumentFragment>
<nav>
<div
class="mocked-styled-6 el-top-bar"
class="mocked-styled-7 el-top-bar"
>
<a
class="mocked-styled-2 el-top-bar-logo"
class="mocked-styled-2 el-top-bar-app-switcher"
>
App-switcher
</a>
<a
class="mocked-styled-3 el-top-bar-logo"
>
<img
data-testid="logo-img"
/>
</a>
<div
class="mocked-styled-4 el-button-group el-top-bar-main-nav el-button-group"
class="mocked-styled-5 el-button-group el-top-bar-main-nav el-button-group"
>
<div
data-testid="nav-item"
/>
</div>
<div
class="mocked-styled-7 el-top-bar-search"
class="mocked-styled-8 el-top-bar-search"
>
<div
data-testid="nav-search-button"
/>
</div>
<div
class="mocked-styled-5 el-button-group el-top-bar-secondary-nav el-button-group"
class="mocked-styled-6 el-button-group el-top-bar-secondary-nav el-button-group"
>
<div
data-testid="nav-icon-item"
/>
</div>
<div
class="mocked-styled-8 el-top-bar-mobile-nav"
class="mocked-styled-9 el-top-bar-mobile-nav"
>
<div
data-testid="nav-icon-item"
/>
</div>
<div
class="mocked-styled-3 el-top-bar-profile"
class="mocked-styled-4 el-top-bar-profile"
>
<div
data-testid="avatar-button"
Expand Down
1 change: 1 addition & 0 deletions src/components/top-bar/__test__/top-bar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('TopBar Snapshot', () => {
it('should match snapshot', () => {
const { asFragment } = render(
<TopBar>
<TopBar.AppSwitcher>App-switcher</TopBar.AppSwitcher>
<TopBar.Logo>
<img data-testid="logo-img" />
</TopBar.Logo>
Expand Down
16 changes: 16 additions & 0 deletions src/components/top-bar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ import { styled } from '@linaria/react'
import { isBelowWideScreen, isTablet, isBelowDesktop, isWideScreen } from '../../styles/media'
import { ElButtonGroup } from '../button-group'
import { css } from '@linaria/core'
import { ElNavResponsiveAppSwitcherIconWrap } from '../nav'

export const ElTopBarAppSwitcher = styled.a`
padding-right: var(--spacing-4);

${isWideScreen} {
padding-right: var(--spacing-5);
}

// TODO: can be removed once new app-switcher ready
${ElNavResponsiveAppSwitcherIconWrap} {
margin-right: 0;
padding: var(--spacing-half);
box-sizing: content-box;
nurm717123 marked this conversation as resolved.
Show resolved Hide resolved
}
`

export const ElTopBarLogo = styled.a`
padding-right: var(--spacing-2);
Expand Down
29 changes: 29 additions & 0 deletions src/components/top-bar/top-bar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import MenuIcon from './icons/menu-icon.svg?react'
import { elTopBarMenuPopover } from './styles'
import { TopBar } from './top-bar'
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport'
import { NavResponsiveAppSwitcher } from '../nav'

const viewports: typeof INITIAL_VIEWPORTS = {
superWideScreen: {
Expand Down Expand Up @@ -59,6 +60,20 @@ export const Default: Story = {
render: () => {
return (
<TopBar>
<TopBar.AppSwitcher>
<NavResponsiveAppSwitcher
options={[
{
text: 'AppMarket',
callback: console.log,
},
{
text: 'DevPortal',
callback: console.log,
},
]}
/>
</TopBar.AppSwitcher>
<TopBar.Logo href="/">
<ReapitLogo />
</TopBar.Logo>
Expand Down Expand Up @@ -125,6 +140,20 @@ export const ResponsiveMainNav: Story = {
render: () => {
return (
<TopBar>
<TopBar.AppSwitcher>
<NavResponsiveAppSwitcher
options={[
{
text: 'AppMarket',
callback: console.log,
},
{
text: 'DevPortal',
callback: console.log,
},
]}
/>
</TopBar.AppSwitcher>
<TopBar.Logo href="/">
<ReapitLogo />
</TopBar.Logo>
Expand Down
3 changes: 3 additions & 0 deletions src/components/top-bar/top-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import {
ElTopBarProfile,
ElTopBarMainNav,
ElTopBarLogo,
ElTopBarAppSwitcher,
} from './styles'

const TopBar: FC<HTMLAttributes<HTMLDivElement>> & {
AppSwitcher: typeof ElTopBarAppSwitcher
Logo: typeof ElTopBarLogo
MainNav: typeof ElTopBarMainNav
SecondaryNav: typeof ElTopBarSecondaryNav
Expand All @@ -24,6 +26,7 @@ const TopBar: FC<HTMLAttributes<HTMLDivElement>> & {
)
}

TopBar.AppSwitcher = ElTopBarAppSwitcher
TopBar.Logo = ElTopBarLogo
TopBar.MainNav = ElTopBarMainNav
TopBar.SecondaryNav = ElTopBarSecondaryNav
Expand Down
Loading