Skip to content

Commit

Permalink
feat(v5): Add XXL support (#5419)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyletsang committed Sep 8, 2020
1 parent adf8eef commit 177922b
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 35 deletions.
16 changes: 9 additions & 7 deletions src/Col.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,10 @@ export interface ColProps extends BsPrefixPropsWithChildren {
md?: ColSpec;
lg?: ColSpec;
xl?: ColSpec;
xxl?: ColSpec;
}

const DEVICE_SIZES = [
'xl' as const,
'lg' as const,
'md' as const,
'sm' as const,
'xs' as const,
];
const DEVICE_SIZES = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs'] as const;
const colSize = PropTypes.oneOfType([
PropTypes.bool,
PropTypes.number,
Expand Down Expand Up @@ -108,6 +103,13 @@ const propTypes = {
* @type {(boolean|"auto"|number|{ span: boolean|"auto"|number, offset: number, order: "first"|"last"|number })}
*/
xl: column,

/**
* The number of columns to span on extra extra large devices (≥1400px)
*
* @type {(boolean|"auto"|number|{ span: boolean|"auto"|number, offset: number, order: "first"|"last"|number })}
*/
xxl: column,
};

const Col: BsPrefixRefForwardingComponent<'div', ColProps> = React.forwardRef(
Expand Down
6 changes: 3 additions & 3 deletions src/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
} from './helpers';

export interface ContainerProps extends BsPrefixPropsWithChildren {
fluid?: boolean | 'sm' | 'md' | 'lg' | 'xl';
fluid?: boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
}

type Container = BsPrefixRefForwardingComponent<'div', ContainerProps>;

const containerSizes = PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf(['sm', 'md', 'lg', 'xl']),
PropTypes.oneOf(['sm', 'md', 'lg', 'xl', 'xxl']),
]);

const propTypes = {
Expand All @@ -27,7 +27,7 @@ const propTypes = {

/**
* Allow the Container to fill all of its available horizontal space.
* @type {(true|"sm"|"md"|"lg"|"xl")}
* @type {(true|"sm"|"md"|"lg"|"xl"|"xxl")}
*/
fluid: containerSizes,
/**
Expand Down
8 changes: 4 additions & 4 deletions src/ListGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

export interface ListGroupProps extends BsPrefixProps {
variant?: 'flush';
horizontal?: boolean | 'sm' | 'md' | 'lg' | 'xl';
horizontal?: boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
activeKey?: unknown;
defaultActiveKey?: unknown;
onSelect?: SelectCallback;
Expand All @@ -42,11 +42,11 @@ const propTypes = {
/**
* Changes the flow of the list group items from vertical to horizontal.
* A value of `null` (the default) sets it to vertical for all breakpoints;
* Just including the prop sets it for all breakpoints, while `{sm|md|lg|xl}`
* Just including the prop sets it for all breakpoints, while `{sm|md|lg|xl|xxl}`
* makes the list group horizontal starting at that breakpoint’s `min-width`.
* @type {(true|'sm'|'md'|'lg'|'xl')}
* @type {(true|'sm'|'md'|'lg'|'xl'|'xxl')}
*/
horizontal: PropTypes.oneOf([true, 'sm', 'md', 'lg', 'xl', undefined]),
horizontal: PropTypes.oneOf([true, 'sm', 'md', 'lg', 'xl', 'xxl', undefined]),

/**
* You can use a custom element type for this component.
Expand Down
10 changes: 8 additions & 2 deletions src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ export interface ModalProps
| 'backdropTransition'
> {
size?: 'sm' | 'lg' | 'xl';
fullscreen?: true | 'sm-down' | 'md-down' | 'lg-down' | 'xl-down';
fullscreen?:
| true
| 'sm-down'
| 'md-down'
| 'lg-down'
| 'xl-down'
| 'xxl-down';
bsPrefix?: string;
centered?: boolean;
backdropClassName?: string;
Expand Down Expand Up @@ -79,7 +85,7 @@ const propTypes = {
* Renders a fullscreen modal. Specifying a breakpoint will render the modal
* as fullscreen __below__ the breakpoint size.
*
* @type (true|'sm-down'|'md-down'|'lg-down'|'xl-down')
* @type (true|'sm-down'|'md-down'|'lg-down'|'xl-down'|'xxl-down')
*/
fullscreen: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),

Expand Down
10 changes: 8 additions & 2 deletions src/ModalDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ export interface ModalDialogProps
extends React.HTMLAttributes<HTMLDivElement>,
BsPrefixPropsWithChildren {
size?: 'sm' | 'lg' | 'xl';
fullscreen?: true | 'sm-down' | 'md-down' | 'lg-down' | 'xl-down';
fullscreen?:
| true
| 'sm-down'
| 'md-down'
| 'lg-down'
| 'xl-down'
| 'xxl-down';
centered?: boolean;
scrollable?: boolean;
contentClassName?: string;
Expand All @@ -32,7 +38,7 @@ const propTypes = {
* Renders a fullscreen modal. Specifying a breakpoint will render the modal
* as fullscreen __below__ the breakpoint size.
*
* @type (true|'sm-down'|'md-down'|'lg-down'|'xl-down')
* @type (true|'sm-down'|'md-down'|'lg-down'|'xl-down'|'xxl-down')
*/
fullscreen: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),

Expand Down
4 changes: 2 additions & 2 deletions src/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const NavbarText = createWithBsPrefix('navbar-text', {

export interface NavbarProps extends BsPrefixPropsWithChildren {
variant?: 'light' | 'dark';
expand?: boolean | 'sm' | 'md' | 'lg' | 'xl';
expand?: boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
bg?: string;
fixed?: 'top' | 'bottom';
sticky?: 'top' | 'bottom';
Expand Down Expand Up @@ -58,7 +58,7 @@ const propTypes = {
* The breakpoint, below which, the Navbar will collapse.
* When `true` the Navbar will always be expanded regardless of screen size.
*/
expand: PropTypes.oneOf([true, 'sm', 'md', 'lg', 'xl']).isRequired,
expand: PropTypes.oneOf([true, 'sm', 'md', 'lg', 'xl', 'xxl']).isRequired,

/**
* A convenience prop for adding `bg-*` utility classes since they are so commonly used here.
Expand Down
11 changes: 10 additions & 1 deletion src/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ export interface RowProps extends BsPrefixPropsWithChildren {
md?: RowColumns;
lg?: RowColumns;
xl?: RowColumns;
xxl?: RowColumns;
}

type Row = BsPrefixRefForwardingComponent<'div', RowProps>;

const DEVICE_SIZES = ['xl', 'lg', 'md', 'sm', 'xs'];
const DEVICE_SIZES = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs'] as const;
const rowColWidth = PropTypes.oneOfType([PropTypes.number, PropTypes.string]);

const rowColumns = PropTypes.oneOfType([
Expand Down Expand Up @@ -96,6 +97,14 @@ const propTypes = {
* @type {(number|'auto'|{ cols: number|'auto' })}
*/
xl: rowColumns,

/**
* The number of columns that will fit next to each other on extra extra large devices (≥1400px).
* Use `auto` to give columns their natural widths.
*
* @type {(number|'auto'|{ cols: number|'auto' })}
*/
xxl: rowColumns,
};

const defaultProps = {
Expand Down
5 changes: 4 additions & 1 deletion tests/simple-types-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,12 @@ const MegaComponent = () => (
md={1}
lg={1}
xl={1}
xxl={1}
noGutters
bsPrefix="row"
className="justify-content-md-center"
>
<Col xs lg="2" bsPrefix="col">
<Col xs sm md lg="2" xl xxl bsPrefix="col">
1 of 3
</Col>
<Col md="auto">Variable width content</Col>
Expand Down Expand Up @@ -656,11 +657,13 @@ const MegaComponent = () => (
<Modal fullscreen="md-down" />
<Modal fullscreen="lg-down" />
<Modal fullscreen="xl-down" />
<Modal fullscreen="xxl-down" />
<Modal.Dialog fullscreen />
<Modal.Dialog fullscreen="sm-down" />
<Modal.Dialog fullscreen="md-down" />
<Modal.Dialog fullscreen="lg-down" />
<Modal.Dialog fullscreen="xl-down" />
<Modal.Dialog fullscreen="xxl-down" />
<Modal.Dialog
centered
scrollable
Expand Down
2 changes: 1 addition & 1 deletion www/src/examples/ListGroup/HorizontalResponsive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
['sm', 'md', 'lg', 'xl'].map((breakpoint, idx) => (
['sm', 'md', 'lg', 'xl', 'xxl'].map((breakpoint, idx) => (
<ListGroup horizontal={breakpoint} className="my-2" key={idx}>
<ListGroup.Item>This ListGroup</ListGroup.Item>
<ListGroup.Item>renders horizontally</ListGroup.Item>
Expand Down
2 changes: 1 addition & 1 deletion www/src/examples/Modal/FullScreen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function Example() {
const values = [true, 'sm-down', 'md-down', 'lg-down', 'xl-down'];
const values = [true, 'sm-down', 'md-down', 'lg-down', 'xl-down', 'xxl-down'];
const [fullscreen, setFullscreen] = useState(true);
const [show, setShow] = useState(false);

Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/components/list-group.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Use the `horizontal` prop to make the ListGroup render horizontally. Currently *
exampleClassName={styles.listGroup}
/>

There are responsive variants to `horizontal`: setting it to `{sm|md|lg|xl}` makes the list group horizontal starting at that breakpoint’s `min-width`.
There are responsive variants to `horizontal`: setting it to `{sm|md|lg|xl|xxl}` makes the list group horizontal starting at that breakpoint’s `min-width`.

<ReactPlayground
codeText={ListGroupHorizontalResponsive}
Expand Down
6 changes: 3 additions & 3 deletions www/src/pages/components/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ export default withLayout(function NaπvbarSection({ data }) {
<p>
When the container is within your navbar, its horizontal padding is
removed at breakpoints lower than your specified{' '}
<code>{`expand={'sm' | 'md' | 'lg' | 'xl'}`}</code> prop. This ensures
we’re not doubling up on padding unnecessarily on lower viewports when
your navbar is collapsed.
<code>{`expand={'sm' | 'md' | 'lg' | 'xl' | 'xxl'}`}</code> prop. This
ensures we’re not doubling up on padding unnecessarily on lower
viewports when your navbar is collapsed.
</p>
<ReactPlayground codeText={ContainerInside} />

Expand Down
15 changes: 8 additions & 7 deletions www/src/pages/layout/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default withLayout(function GridSection({ data }) {
/>
<p>
You can set breakpoints for the <code>fluid</code> prop. Setting it to a
breakpoint (<code>sm, md, lg, xl</code>) will set the{' '}
breakpoint (<code>sm, md, lg, xl, xxl</code>) will set the{' '}
<code>Container</code> as fluid until the specified breakpoint.
</p>
<ReactPlayground
Expand Down Expand Up @@ -110,9 +110,9 @@ export default withLayout(function GridSection({ data }) {
Responsive grids
</LinkedHeading>
<p>
The <code>Col</code> lets you specify column widths across 5 breakpoint
sizes (xs, sm, md, lg, and xl). For every breakpoint, you can specify
the amount of columns to span, or set the prop to{' '}
The <code>Col</code> lets you specify column widths across 6 breakpoint
sizes (xs, sm, md, lg, xl and xxl). For every breakpoint, you can
specify the amount of columns to span, or set the prop to{' '}
<code>{'<Col lg={true} />'}</code> for auto layout widths.
</p>
<ReactPlayground
Expand Down Expand Up @@ -158,9 +158,10 @@ export default withLayout(function GridSection({ data }) {

<p>
The <code>Row</code> lets you specify column widths across 5 breakpoint
sizes (xs, sm, md, lg, and xl). For every breakpoint, you can specify
the amount of columns that will fit next to each other. You can also
specify <code>auto</code> to set the columns to their natural widths.
sizes (xs, sm, md, lg, xl and xxl). For every breakpoint, you can
specify the amount of columns that will fit next to each other. You can
also specify <code>auto</code> to set the columns to their natural
widths.
</p>
<ReactPlayground
codeText={GridRowColLayout}
Expand Down

0 comments on commit 177922b

Please sign in to comment.