Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSCI] Adding props for shrink and basis for OuiFlexItem #1126

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d7426fe
adding shrink and basis props for OuiFlexItem
BigSamu Oct 27, 2023
0cf7375
adding tests for shrink and basis props added in OuiFlexItem
BigSamu Oct 27, 2023
fe28556
changing API for values accepted for basis prop and updating snapshoo…
BigSamu Oct 28, 2023
d5dd922
updating CHANGELOG.md and testing snapshoots
BigSamu Oct 30, 2023
a4362a8
Merge branch 'main' into feat/props-ouiFlexItem
BigSamu Nov 1, 2023
3eb7413
changing location of chanelog description for this issue into correct…
BigSamu Nov 1, 2023
428ef63
fixing typo lines 122 and 123 flexItem.tsx
BigSamu Nov 1, 2023
eb68e2c
fixing typo line 55 file _flex_item.scss
BigSamu Nov 1, 2023
9665bba
updating jest unit-testing snapshoots
BigSamu Nov 1, 2023
b8ec51e
changing default values for shrink and basis props
BigSamu Nov 1, 2023
8abdb38
removing class .ouiFlexItem--flexShrinkZero from _flex_item.scss and …
BigSamu Nov 1, 2023
34fad9a
updating documentation for shrink and basis props in OuiFlexItem
BigSamu Nov 1, 2023
4674627
updating jest unit-testing snapshoots
BigSamu Nov 1, 2023
29aff44
removing extra line CHANELOG.md
BigSamu Nov 4, 2023
74354d0
Merge branch 'main' into feat/props-ouiFlexItem
BigSamu Nov 8, 2023
6914c7d
refactoring code adding after suggestions from code review in last PR
BigSamu Nov 9, 2023
345fd2d
adding snapshoots for unit-testing
BigSamu Nov 9, 2023
e74f52e
Merge branch 'main' into feat/props-ouiFlexItem
BigSamu Nov 17, 2023
8d6e8fa
Adding tests for combinatios of grow, shrink and basis values and res…
BigSamu Nov 17, 2023
c58f11a
removing property flex-basis:auto from CSS class ouiFlexItem--flexShr…
BigSamu Nov 17, 2023
66c8e9e
modifiying logic for prop 'basis' according what was requested by mai…
BigSamu Nov 21, 2023
a539b13
Merge branch 'main' into feat/props-ouiFlexItem
BigSamu Jan 1, 2024
fb97c87
Merge branch 'main' into feat/props-ouiFlexItem
BigSamu Jan 11, 2024
e4e0aff
Update src-docs/src/views/flex/flex_basis_string.tsx
BigSamu Jan 12, 2024
2341eab
Update src-docs/src/views/flex/flex_shrink_numeric.tsx
BigSamu Jan 12, 2024
ceed1ce
updating text for examples of Basis in flex items
BigSamu Jan 12, 2024
01e94ea
adding 0 item for GROW_SIZES and SHRINK_SIZES arrays and FlexItemGrow…
BigSamu Jan 12, 2024
03ce677
make 'true' and 'false' options for types FlexItemGrowSize and FlexIt…
BigSamu Jan 12, 2024
9fd51c9
updating snapshoots
BigSamu Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Add slugs to markdown headers ([#1051](https://github.com/opensearch-project/oui/pull/1051))
- Add `crossInCircleEmpty` and `power` icons ([#1044](https://github.com/opensearch-project/oui/pull/1044))
- Add `Figma` icon and link to OUI Figma resources ([#1064](https://github.com/opensearch-project/oui/pull/1064))
- Add `shrink` and `basis` props to OuiFlexItem ([#1126](https://github.com/opensearch-project/oui/pull/1126))

### 🐛 Bug Fixes

Expand Down
43 changes: 43 additions & 0 deletions src-docs/src/views/flex/flex_basis_string.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
BigSamu marked this conversation as resolved.
Show resolved Hide resolved

import React from 'react';

import { OuiFlexGroup, OuiFlexItem } from '../../../../src/components/flex';

export default () => (
<div>
<OuiFlexGroup>
<OuiFlexItem basis={'auto'}>
Auto
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because the actual value of the prop we want users to use is auto, we should use auto here and not Auto. Also, we should perhaps wrap it in OuiCode?

The same goes for all of the other values too.

@kgcreative

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AMoo-Miki,

Updated text in examples for Basis in Flex Item for all basis properties (e.g.Auto to auto). Just one question what is this suggestion of wrapping with OuiCode?

<br />
Varies based on content size or width/height property
</OuiFlexItem>
<OuiFlexItem basis={'fit-content'}>
Fit-content
<br />
Sizes the item based on the content&apos;s width but within the
container.
</OuiFlexItem>
<OuiFlexItem basis={'max-content'}>
Max-content
<br />
Sizes the item to be as large as the content&apos;s maximum width.
</OuiFlexItem>
<OuiFlexItem basis={'min-content'}>
Min-content
<br />
Sizes the item to be as small as the content&apos;s minimum width
without breaking.
</OuiFlexItem>
</OuiFlexGroup>
</div>
);
82 changes: 79 additions & 3 deletions src-docs/src/views/flex/flex_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ const flexGrowZeroSource = require('!!raw-loader!./flex_grow_zero');
import FlexGrowNumeric from './flex_grow_numeric';
const flexGrowNumericSource = require('!!raw-loader!./flex_grow_numeric');

import FlexShrinkNumeric from './flex_shrink_numeric';
const flexShrinkNumericSource = require('!!raw-loader!./flex_shrink_numeric');

import FlexBasisString from './flex_basis_string';
const FlexBasisStringSource = require('!!raw-loader!./flex_basis_string');

import FlexJustify from './flex_justify';
const flexJustifySource = require('!!raw-loader!./flex_justify');
import FlexJustifyBetween from './flex_justify_between';
Expand Down Expand Up @@ -105,10 +111,31 @@ const flexGrowZeroSnippet = `<OuiFlexGroup>
</OuiFlexGroup>`;

const flexGrowNumericSnippet = `<OuiFlexGroup>
<OuiFlexItem grow={1}><!-- FlexItem with flew-grow 1 --></OuiFlexItem>
<OuiFlexItem grow={2}><!-- FlexItem with flew-grow 2 --></OuiFlexItem>
<OuiFlexItem grow={1}><!-- FlexItem with flex-grow 1 --></OuiFlexItem>
<OuiFlexItem grow={2}><!-- FlexItem with flex-grow 2 --></OuiFlexItem>
...
<OuiFlexItem grow={10}><!-- FlexItem with flex-grow 10 --></OuiFlexItem>
</OuiFlexGroup>`;

const flexShrinkNumericSnippet = `<OuiFlexGroup>
<OuiFlexItem grow={false} shrink={1}><!-- FlexItem with flex-shrink 1 --></OuiFlexItem>
<OuiFlexItem grow={false} shrink={2}><!-- FlexItem with flex-shrink 2 --></OuiFlexItem>
...
<OuiFlexItem grow={10}><!-- FlexItem with flew-grow 10 --></OuiFlexItem>
<OuiFlexItem grow={false} shrink={10}><!-- FlexItem with flex-shrink 10 --></OuiFlexItem>
</OuiFlexGroup>

<OuiFlexGroup>
<OuiFlexItem shrink={1} basis={'auto'}><!-- FlexItem with flex-shrink 1 --></OuiFlexItem>
<OuiFlexItem shrink={2} basis={'auto'}><!-- FlexItem with flex-shrink 2 --></OuiFlexItem>
...
<OuiFlexItem shrink={10} basis={'auto'}><!-- FlexItem with flex-shrink 10 --></OuiFlexItem>
</OuiFlexGroup>`;

const flexBasisStringSnippet = `<OuiFlexGroup>
<OuiFlexItem basis={'auto'}><!-- FlexItem with flex-basis 'auto' --></OuiFlexItem>
<OuiFlexItem basis={'fit-content'}><!-- FlexItem with flex-basis 'fit-content' --></OuiFlexItem>
<OuiFlexItem basis={'max-content'}><!-- FlexItem with flex-basis 'max-content' --></OuiFlexItem>
<OuiFlexItem basis={'min-content'}><!-- FlexItem with flex-basis 'min-content' --></OuiFlexItem>
</OuiFlexGroup>`;

const directionSnippet = `<OuiFlexGroup direction="column">
Expand Down Expand Up @@ -328,6 +355,55 @@ export const FlexExample = {
</div>
),
},
{
title: 'Proportional shrinking of items',
source: [
{
type: GuideSectionTypes.JS,
code: flexShrinkNumericSource,
},
],
text: (
<p>
You can specify a number between 1 and 10 for each{' '}
<strong>OuiFlexItem</strong> to take up a proportional shrinking of
the <strong>OuiFlexGroup</strong> it is in. For this to apply: (1) the
BigSamu marked this conversation as resolved.
Show resolved Hide resolved
prop <strong>grow</strong> should set into <strong>false</strong> or
change the <strong>basis</strong> prop to <strong>auto</strong> and
(2) the content in the all flex item should be sufficient enough to
reach the width of the flex parent.
</p>
),
snippet: flexShrinkNumericSnippet,
demo: (
<div className="guideDemo__highlightGrid">
<FlexShrinkNumeric />
</div>
),
},
{
title: 'Basis of flex items',
source: [
{
type: GuideSectionTypes.JS,
code: FlexBasisStringSource,
},
],
text: (
<p>
You can also specify the <strong>flex-basis</strong> CSS property of a
flex item using the <strong>basis</strong> prop with one of the
following options: <strong>auto</strong>, <strong>content-fit</strong>
, <strong>content-max</strong>, <strong>content-min</strong>
</p>
),
snippet: flexBasisStringSnippet,
demo: (
<div className="guideDemo__highlightGrid">
<FlexBasisString />
</div>
),
},
{
title: 'Justify and align',
source: [
Expand Down
51 changes: 51 additions & 0 deletions src-docs/src/views/flex/flex_shrink_numeric.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
BigSamu marked this conversation as resolved.
Show resolved Hide resolved

import React from 'react';

import { OuiFlexGroup, OuiFlexItem } from '../../../../src/components/flex';
import { OuiSpacer } from '../../../../src/components/spacer';

export default () => (
<div>
<OuiFlexGroup>
<OuiFlexItem grow={false} shrink={1}>
Extensive Text Extensive Text Extensive Text
BigSamu marked this conversation as resolved.
Show resolved Hide resolved
</OuiFlexItem>
<OuiFlexItem grow={false} shrink={2}>
Extensive Text Extensive Text Extensive Text
</OuiFlexItem>
<OuiFlexItem grow={false} shrink={4}>
Extensive Text Extensive Text Extensive Text
</OuiFlexItem>
<OuiFlexItem grow={false} shrink={8}>
Extensive Text Extensive Text Extensive Text
</OuiFlexItem>
</OuiFlexGroup>

<OuiSpacer />

<OuiFlexGroup>
<OuiFlexItem shrink={1} basis={'auto'}>
Extensive Text Extensive Text Extensive Text
</OuiFlexItem>
<OuiFlexItem shrink={2} basis={'auto'}>
Extensive Text Extensive Text Extensive Text
</OuiFlexItem>
<OuiFlexItem shrink={4} basis={'auto'}>
Extensive Text Extensive Text Extensive Text
</OuiFlexItem>
<OuiFlexItem shrink={8} basis={'auto'}>
Extensive Text Extensive Text Extensive Text
</OuiFlexItem>
</OuiFlexGroup>
</div>
);
Loading
Loading