MCPcopy
hub / github.com/typestyle/typestyle / media

Function media

src/internal/utilities.ts:75–93  ·  view source on GitHub ↗
(mediaQuery: MediaQuery, ...objects: (NestedCSSProperties | undefined | null | false)[])

Source from the content-addressed store, hash-verified

73 * ```
74 */
75export const media = (mediaQuery: MediaQuery, ...objects: (NestedCSSProperties | undefined | null | false)[]): NestedCSSProperties => {
76 const mediaQuerySections: string[] = [];
77 if (mediaQuery.type) mediaQuerySections.push(mediaQuery.type);
78 if (mediaQuery.orientation) mediaQuerySections.push(`(orientation: ${mediaQuery.orientation})`);
79 if (mediaQuery.minWidth) mediaQuerySections.push(`(min-width: ${mediaLength(mediaQuery.minWidth)})`);
80 if (mediaQuery.maxWidth) mediaQuerySections.push(`(max-width: ${mediaLength(mediaQuery.maxWidth)})`);
81 if (mediaQuery.minHeight) mediaQuerySections.push(`(min-height: ${mediaLength(mediaQuery.minHeight)})`);
82 if (mediaQuery.maxHeight) mediaQuerySections.push(`(max-height: ${mediaLength(mediaQuery.maxHeight)})`);
83 if (mediaQuery.prefersColorScheme) mediaQuerySections.push(`(prefers-color-scheme: ${mediaQuery.prefersColorScheme})`);
84
85 const stringMediaQuery = `@media ${mediaQuerySections.join(' and ')}`;
86
87 const object: NestedCSSProperties = {
88 $nest: {
89 [stringMediaQuery]: extend(...objects)
90 }
91 };
92 return object;
93}
94
95const mediaLength = (value: number | string) =>
96 typeof value === 'string' ? value : `${value}px`;

Callers 1

media.tsFile · 0.85

Calls 2

mediaLengthFunction · 0.85
extendFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…