-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix alignment issues with MultiColumnField in Traffic Splitting modal
- Loading branch information
1 parent
b19ffe0
commit 5869b05
Showing
8 changed files
with
94 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
...ages/console-shared/src/components/formik-fields/multi-column-field/MultiColumnField.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 10 additions & 6 deletions
16
...console-shared/src/components/formik-fields/multi-column-field/MultiColumnFieldHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...src/components/formik-fields/multi-column-field/__tests__/multicolumn-field-utils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { getSpans } from '../multicolumn-field-utils'; | ||
|
||
describe('Multicolumn field utils', () => { | ||
it('should return single spans value', () => { | ||
const spans = getSpans(1); | ||
expect(spans).toEqual([12]); | ||
}); | ||
it('should return 12 spans equally sized', () => { | ||
const spans = getSpans(12); | ||
expect(spans).toEqual([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]); | ||
}); | ||
it('should return spans [3, 3, 2, 2, 2]', () => { | ||
const spans = getSpans(5); | ||
expect(spans).toEqual([3, 3, 2, 2, 2]); | ||
}); | ||
it('should return spans [2, 2, 2, 2, 2, 1, 1]', () => { | ||
const spans = getSpans(7); | ||
expect(spans).toEqual([2, 2, 2, 2, 2, 1, 1]); | ||
}); | ||
it('should return spans [2, 2, 2, 1, 1, 1, 1, 1, 1]', () => { | ||
const spans = getSpans(9); | ||
expect(spans).toEqual([2, 2, 2, 1, 1, 1, 1, 1, 1]); | ||
}); | ||
it('should return spans [4, 4, 4]', () => { | ||
const spans = getSpans(3); | ||
expect(spans).toEqual([4, 4, 4]); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
...console-shared/src/components/formik-fields/multi-column-field/multicolumn-field-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as _ from 'lodash'; | ||
import { gridItemSpanValueShape } from '@patternfly/react-core'; | ||
|
||
export const getSpans = (totalFieldCount: number): gridItemSpanValueShape[] => { | ||
const spans: gridItemSpanValueShape[] = _.fill(Array(totalFieldCount), 1); | ||
if (totalFieldCount === 1) { | ||
return [12]; | ||
} | ||
if (totalFieldCount === 12) { | ||
return _.fill(Array(12), 1); | ||
} | ||
while (_.sum(spans) !== 12) { | ||
for (let i = 0; i < totalFieldCount; i++) { | ||
spans[i]++; | ||
if (_.sum(spans) === 12) { | ||
break; | ||
} | ||
} | ||
} | ||
return spans; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters