Skip to content

feat(design-system): create reusable helper function to support responsive styling [AR-53842]#338

Open
vpolessky-dn wants to merge 11 commits intodrivenets:mainfrom
vpolessky-dn:feat/AR-53842-create-reusable-helper-function-to-support-responsive-styling
Open

feat(design-system): create reusable helper function to support responsive styling [AR-53842]#338
vpolessky-dn wants to merge 11 commits intodrivenets:mainfrom
vpolessky-dn:feat/AR-53842-create-reusable-helper-function-to-support-responsive-styling

Conversation

@vpolessky-dn
Copy link
Copy Markdown
Collaborator

No description provided.

children,
...props
}) => {
const size = useResponsiveValue(sizeProp);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We rely on JS to choose the size based on the screen width. Using CSS media queries would be cheaper form performance standpoint.
I think useResponsiveValue hook is equivalent of MUI useMediaQuery and is usefull when you have some conditional rendering etc. We should expose it for library consumers.
If we want to follow MUI, then responsive props → generate CSS media queries. It may be hard, because it requires runtime css / css pre-processors. I'm not saying we 100% need it. I want to make sure we discuss this option and are on the same page.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

let discuss it on the daily

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We decided to keep it as is and do not invest time into runtime css solutions (like emotion).

@iromanchuk-dn iromanchuk-dn self-requested a review April 1, 2026 09:57

import breakpointTokens from '../styles/_breakpoints.module.scss';

export const BREAKPOINT_LG = parseInt(breakpointTokens.breakpointLg, 10);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pick question: Does it work in the build script? Just to be sure it's picked up, maybe something compiler/bundler related could be missing

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Image

working well


const getSnapshot = (): Breakpoint => (window.matchMedia(MEDIA_QUERY).matches ? 'lg' : 'md');

const getServerSnapshot = (): Breakpoint => 'lg';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It returns static value, why is that? Assumption server will always render the 'lg', right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As we do not have info during SSR about screen size it is fallback for lg size

iromanchuk-dn
iromanchuk-dn previously approved these changes Apr 2, 2026

const Wrapper = (props: EnhancedProps) => {
const breakpoint = useBreakpoint();
const resolved = { ...props } as Record<string, unknown>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is a lot of type casting. Can you verify whether it can be avoided?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

  • as T (line 22) — Partial makes every lookup T | undefined; TS can't track that isResponsiveValue guarantees at least one defined value. ! would be more precise but is banned by ESLint.
  • { ...props } as Record<string, unknown> (line 62) — generic EnhancedProps can't be indexed by string without widening
  • Component as FunctionComponent<...> (line 72) — widened Record<string, unknown> isn't assignable back to FunctionComponent

removed cast for string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants