Skip to content

Commit 1e1b821

Browse files
committed
feat(layout): add overflow utility
Adds the overflow utility to support the overflow utility upstream feature.
1 parent 930b92e commit 1e1b821

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Box.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ type UserSelect = typeof userSelectValues[number];
7070
const peValues = ['none', 'auto'] as const;
7171
type Pe = typeof peValues[number];
7272

73+
const overflowValues = ['auto', 'hidden'] as const;
74+
type Overflow = typeof overflowValues[number];
75+
7376
const generateBreakpoint = (
7477
bsPrefix: string,
7578
currentBreakpoint: string | true,
@@ -214,6 +217,9 @@ const utilities: Record<string, (utilityValue: any) => string> = {
214217
pe(option: Pe) {
215218
return `pe-${option}`;
216219
},
220+
overflow(option: Overflow) {
221+
return `overflow-${option}`;
222+
},
217223
};
218224

219225
const propTypes = {
@@ -293,6 +299,8 @@ const propTypes = {
293299
userSelect: PropTypes.oneOf(userSelectValues),
294300
pe: PropTypes.oneOf(peValues),
295301

302+
overflow: PropTypes.oneOf(overflowValues),
303+
296304
/**
297305
*
298306
* add `d-print-{display}` className on the element
@@ -381,6 +389,8 @@ export type BoxProps = AsProp &
381389
userSelect: UserSelect;
382390
pe: Pe;
383391

392+
overflow: Overflow;
393+
384394
className: string;
385395
print: Display;
386396
visible: boolean;
@@ -447,6 +457,7 @@ const Box = (React.forwardRef(
447457
floatRight,
448458
floatNone,
449459
userSelect,
460+
overflow,
450461
pe,
451462
print,
452463
visible,
@@ -512,6 +523,7 @@ const Box = (React.forwardRef(
512523
floatNone,
513524
userSelect,
514525
pe,
526+
overflow,
515527
};
516528
const finalClassName = classNames(
517529
...Object.entries(utilityProps)

test/BoxSpec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,8 @@ describe('<Box>', () => {
125125
const component = shallow(<Box pe="auto" />);
126126
component.find('div').hasClass('pe-auto').should.equal(true);
127127
});
128+
it('Should have overflow utility', () => {
129+
const component = shallow(<Box overflow="hidden" />);
130+
component.find('div').hasClass('overflow-hidden').should.equal(true);
131+
});
128132
});

0 commit comments

Comments
 (0)