-
Notifications
You must be signed in to change notification settings - Fork 0
CC-101: Improve Component Library Mobile Support #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
Merged
ianpaschal
merged 8 commits into
master
from
ian/cc-101-improve-component-library-mobile-support
Jun 13, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8f4c482
CC-101: Improve Component Library Mobile Support
ianpaschal 68e5904
PR Feedback
ianpaschal eb35f32
PR Feedback
ianpaschal 036dde7
Fix <Select/> positioning
ianpaschal cb2efca
PR Feedback
ianpaschal 20dafd2
Further mobile style improvements
ianpaschal b0510b6
Add <FooterBar/> and <FooterBarActions/>
ianpaschal 1ef83eb
PR Feedback
ianpaschal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| @use "../../style/layers"; | ||
| @use "../../style/flex"; | ||
| @use "../../style/shadows"; | ||
|
|
||
| @layer components { | ||
| .footer-bar { | ||
| --bleed: 100dvh; | ||
| --vertical-padding: 1rem; | ||
|
|
||
| @include shadows.surface; | ||
|
|
||
| position: fixed; | ||
| bottom: calc(-1 * var(--bleed)); | ||
| left: 0; | ||
|
|
||
| overflow: hidden; | ||
|
|
||
| box-sizing: border-box; | ||
| width: 100vw; | ||
| padding-bottom: calc(var(--bleed) + env(safe-area-inset-bottom)); | ||
|
|
||
| &-content { | ||
| @include flex.row($gap: 1.5rem, $yAlign: center); | ||
|
|
||
| box-sizing: border-box; | ||
| margin: 0 auto; | ||
| padding-top: calc(var(--vertical-padding) - var(--border-width)); | ||
| padding-right: calc(var(--page-padding) + env(safe-area-inset-right)); | ||
| padding-bottom: var(--vertical-padding); | ||
| padding-left: calc(var(--page-padding) + env(safe-area-inset-left)); | ||
|
|
||
| &[data-mobile] { | ||
| --mobile-offset: 0.5rem; | ||
|
|
||
| padding-right: calc(var(--vertical-padding) + var(--mobile-offset) + env(safe-area-inset-right)); | ||
| padding-bottom: calc(var(--vertical-padding) + var(--mobile-offset)); | ||
| padding-left: calc(var(--vertical-padding) + var(--mobile-offset) + env(safe-area-inset-left)); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export declare const footerBar: string; | ||
| export declare const footerBarContent: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import { useState } from 'react'; | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { | ||
| ArrowLeft, | ||
| Save, | ||
| X, | ||
| } from 'lucide-react'; | ||
|
|
||
| import { ButtonProps } from '../Button'; | ||
| import { Spinner } from '../Spinner'; | ||
| import { FooterBar, FooterBarProps } from './FooterBar'; | ||
| import { FooterBarActions } from './FooterBarActions'; | ||
|
|
||
| interface StoryArgs extends FooterBarProps { | ||
| mobile?: boolean; | ||
| } | ||
|
|
||
| const meta: Meta<StoryArgs> = { | ||
| title: 'Components/FooterBar', | ||
| component: FooterBar, | ||
| parameters: { | ||
| layout: 'centered', | ||
| bodyBackground: 'var(--color-page-bg)', | ||
| docs: { | ||
| story: { inline: false, height: '12rem' }, | ||
| }, | ||
| }, | ||
| argTypes: { | ||
| maxWidth: { | ||
| control: 'number', | ||
| description: 'Constrains the inner content width.', | ||
| }, | ||
| mobile: { | ||
| control: 'boolean', | ||
| description: 'Switches between desktop and mobile layouts.', | ||
| }, | ||
| portalTarget: { | ||
| table: { disable: true }, | ||
| }, | ||
| children: { | ||
| table: { disable: true }, | ||
| }, | ||
| }, | ||
| decorators: [ | ||
| (Story, { args }) => { | ||
| const [portalTarget, setPortalTarget] = useState<Element | null>(null); | ||
| return ( | ||
| <div ref={setPortalTarget} style={{ width: '100%', height: '100%' }}> | ||
| {portalTarget && <Story args={{ ...args, portalTarget }} />} | ||
| </div> | ||
| ); | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| const actions: { | ||
| left: ButtonProps[]; | ||
| right: ButtonProps[]; | ||
| } = { | ||
| left: [{ icon: <ArrowLeft />, text: 'Cancel', variant: 'shaded' }], | ||
| right: [{ icon: <Save />, text: 'Save', variant: 'solid', intent: 'primary' }], | ||
| }; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| mobile: false, | ||
| }, | ||
| render: (args) => ( | ||
| <FooterBar {...args}> | ||
| <FooterBarActions | ||
| mobile={args.mobile} | ||
| {...actions} | ||
| /> | ||
| </FooterBar> | ||
| ), | ||
| }; | ||
|
|
||
| export const MaxWidth: Story = { | ||
| args: { | ||
| mobile: false, | ||
| maxWidth: 256, | ||
| }, | ||
| render: (args) => ( | ||
| <FooterBar {...args}> | ||
| <FooterBarActions | ||
| mobile={args.mobile} | ||
| left={[ | ||
| { icon: <X />, text: 'Cancel', variant: 'ghost' }, | ||
| ]} | ||
| right={[ | ||
| { icon: <Save />, text: 'Save', variant: 'solid', intent: 'primary' }, | ||
| ]} | ||
| /> | ||
| </FooterBar> | ||
| ), | ||
| }; | ||
|
|
||
| export const CustomElement: Story = { | ||
| args: { | ||
| mobile: false, | ||
| }, | ||
| render: (args) => ( | ||
| <FooterBar {...args}> | ||
| <div style={{ | ||
| display: 'flex', | ||
| flexDirection: 'row', | ||
| alignItems: 'center', | ||
| justifyContent: 'start', | ||
| gap: '0.75rem', | ||
| flex: 1, | ||
| }}> | ||
| <Spinner size={20} /> | ||
| <span>Syncing changes…</span> | ||
| </div> | ||
| </FooterBar> | ||
| ), | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { | ||
| ReactElement, | ||
| ReactNode, | ||
| useEffect, | ||
| useRef, | ||
| } from 'react'; | ||
| import { createPortal } from 'react-dom'; | ||
| import clsx from 'clsx'; | ||
|
|
||
| import { getStyleClassNames } from '../../utils/getStyleClassNames'; | ||
|
|
||
| import styles from './FooterBar.module.scss'; | ||
|
|
||
| export interface FooterBarProps { | ||
| children?: ReactNode; | ||
| className?: string; | ||
| maxWidth?: number | string; | ||
| mobile?: boolean; | ||
| portalTarget?: Element; | ||
| } | ||
|
|
||
| export const FooterBar = ({ | ||
| children, | ||
| className, | ||
| maxWidth = '100vw', | ||
| mobile = false, | ||
| portalTarget = document.body, | ||
| }: FooterBarProps): ReactElement => { | ||
| const contentRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| useEffect(() => { | ||
| const content = contentRef.current; | ||
| if (!content) { | ||
| return; | ||
| } | ||
| const observer = new ResizeObserver(([entry]) => { | ||
| document.documentElement.style.setProperty('--footer-bar-height', `${entry.contentRect.height}px`); | ||
| }); | ||
| observer.observe(content); | ||
| return () => { | ||
| observer.disconnect(); | ||
| document.documentElement.style.removeProperty('--footer-bar-height'); | ||
| }; | ||
| }, []); | ||
|
ianpaschal marked this conversation as resolved.
|
||
|
|
||
| return createPortal(( | ||
| <div | ||
| className={clsx(styles.footerBar, ...getStyleClassNames({ | ||
| variant: 'surface', | ||
| border: 'top', | ||
| }), className)} | ||
|
|
||
| > | ||
| <div ref={contentRef} className={styles.footerBarContent} style={{ maxWidth }} data-mobile={mobile || undefined}> | ||
| {children} | ||
| </div> | ||
| </div> | ||
| ), portalTarget); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.