Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
description: 'Display',
key: 'display-03',
name: 'display-03',
},
{
description: 'Display',
key: 'display-04',
name: 'display-04',
},
],
};
const breakpoints = {
sm: Number(carbonBreakpoints.sm.width.replace('rem', '')) * baseFontSize,
md: Number(carbonBreakpoints.md.width.replace('rem', '')) * baseFontSize,
lg: Number(carbonBreakpoints.lg.width.replace('rem', '')) * baseFontSize,
xlg: Number(carbonBreakpoints.xlg.width.replace('rem', '')) * baseFontSize,
max: Number(carbonBreakpoints.max.width.replace('rem', '')) * baseFontSize,
};
const nextLargerBreakpointPx = viewportWidth =>
values(breakpoints)[indexOfCurrentBreakpoint(viewportWidth) + 1];
const indexOfCurrentBreakpoint = viewportWidth =>
findLastIndex(values(breakpoints), width => viewportWidth >= width);
const isWithinBreakpoint = (viewportWidth, currentBreakpoint) => {
if (viewportWidth === currentBreakpoint) return true;
return (
viewportWidth >= currentBreakpoint &&
viewportWidth < nextLargerBreakpointPx(currentBreakpoint)
);
import React from 'react';
import { settings } from 'carbon-components';
import classnames from 'classnames';
import { findKey, values } from 'lodash';
import {
baseFontSize,
breakpoints as carbonBreakpoints,
} from '@carbon/elements';
import { CodeSnippet } from 'carbon-components-react';
const { prefix } = settings;
const breakpoints = {
sm: Number(carbonBreakpoints.sm.width.replace('rem', '')) * baseFontSize,
md: Number(carbonBreakpoints.md.width.replace('rem', '')) * baseFontSize,
lg: Number(carbonBreakpoints.lg.width.replace('rem', '')) * baseFontSize,
xlg: Number(carbonBreakpoints.xlg.width.replace('rem', '')) * baseFontSize,
max: Number(carbonBreakpoints.max.width.replace('rem', '')) * baseFontSize,
};
const defaultTypeValues = {
'letter-spacing': 0,
};
const TypesetExample = props => (
<div>
{(props.typeSet || []).map(type => {
const indexOfClosestLargerBreakpoint = Math.max(
0,
values(breakpoints).findIndex(
width => props.simulatedScreenWidth <= width
)</div>