-
Notifications
You must be signed in to change notification settings - Fork 96
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
DEP Upgrade bootstrap and reactstrap #1889
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,13 @@ class Badge extends PureComponent { | |
return null; | ||
} | ||
|
||
const invertedClass = inverted ? `badge-${status}--inverted` : ''; | ||
const colourClass = inverted ? `text-bg-${status}--inverted` : `text-bg-${status}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#badges
Note that as of bootstrap 5.2 the |
||
|
||
const compiledClassNames = classnames( | ||
className, | ||
'badge', | ||
`badge-${status}`, | ||
invertedClass, | ||
colourClass, | ||
); | ||
return ( | ||
<span className={compiledClassNames}> | ||
|
@@ -48,7 +48,7 @@ Badge.propTypes = { | |
|
||
Badge.defaultProps = { | ||
status: 'default', | ||
className: 'badge-pill', | ||
className: 'rounded-pill', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#badges
|
||
inverted: false, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// Provides an inverted variant of Bootstrap badges. | ||
// See: bootstrap/mixins/_badge.scss for original. | ||
// Provides an inverted variant of Bootstrap 5's .text-bg-{color} classes which replace the old .badge-{color} classes. | ||
@mixin badge-variant-inverted($bg) { | ||
color: $bg; | ||
background-color: color-yiq($bg); | ||
background-color: color-contrast($bg); | ||
|
||
Comment on lines
-5
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#sass
|
||
&[href] { | ||
@include hover-focus { | ||
&:hover, | ||
&:focus { | ||
color: darken($bg, 10%); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#sass
|
||
background-color: color-yiq($bg); | ||
background-color: color-contrast($bg); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ | |
max-height: $toolbar-height; | ||
overflow: hidden; | ||
|
||
@include media-breakpoint-down(sm) { | ||
@include media-breakpoint-down(md) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#sass
|
||
margin-left: $toolbar-total-height; | ||
|
||
.toolbar__back-button + & { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React, { Component } from 'react'; | ||
import { FormGroup, InputGroup, InputGroupAddon, Label } from 'reactstrap'; | ||
import { FormGroup, InputGroup, InputGroupText, Label } from 'reactstrap'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://reactstrap.github.io/?path=/story/home-upgrading--page
Note that |
||
import castStringToElement from 'lib/castStringToElement'; | ||
import classnames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
|
@@ -42,6 +42,7 @@ function fieldHolder(Field) { | |
field: true, | ||
[this.props.extraClass]: true, | ||
readonly: this.props.readOnly, | ||
'form-group': true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#sass
It would require a non-trivial amount of effort to do that refactor and I like how semantic these class names are, so I opted instead to port those styles into Reactstrap correctly stopped adding these css classes, so I've added them back where necessary. |
||
}), | ||
id: this.props.holderId, | ||
}; | ||
|
@@ -126,20 +127,22 @@ function fieldHolder(Field) { | |
}; | ||
|
||
const field = <Field {...props} />; | ||
const prefix = this.props.data && this.props.data.prefix ? this.props.data.prefix : ''; | ||
const suffix = this.props.data && this.props.data.suffix ? this.props.data.suffix : ''; | ||
let prefix = this.props.data && this.props.data.prefix ? this.props.data.prefix : ''; | ||
let suffix = this.props.data && this.props.data.suffix ? this.props.data.suffix : ''; | ||
if (!prefix && !suffix) { | ||
return field; | ||
} | ||
if (prefix !== '' && typeof prefix === 'string') { | ||
prefix = <InputGroupText>{prefix}</InputGroupText>; | ||
} | ||
if (suffix !== '' && typeof suffix === 'string') { | ||
suffix = <InputGroupText>{suffix}</InputGroupText>; | ||
} | ||
return ( | ||
<InputGroup> | ||
{prefix && | ||
<InputGroupAddon addonType="prepend">{prefix}</InputGroupAddon> | ||
} | ||
{prefix} | ||
{field} | ||
{suffix && | ||
<InputGroupAddon addonType="append">{suffix}</InputGroupAddon> | ||
} | ||
{suffix} | ||
</InputGroup> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,7 +171,6 @@ input[type="checkbox"], | |
input[type="radio"], | ||
input.checkbox, | ||
input.radio { | ||
display: inline; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does nothing in most cases due to the usage of |
||
margin-right: 6px; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,6 @@ | |
} | ||
|
||
// Used buttons with text and icons, but you wan to hide the text only. eg. gridfield pagination | ||
// Could change to BS .text-hide { @include text-hide(); }, although slightly different | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.btn--hide-text[class*="font-icon-"] { | ||
|
||
&:before { | ||
|
@@ -142,39 +141,6 @@ | |
} | ||
} | ||
|
||
|
||
// Specific button variations | ||
.btn-primary { | ||
border-bottom-color: $btn-primary-shadow; | ||
|
||
.btn__circle { | ||
background: $white; | ||
} | ||
|
||
&:focus { | ||
outline-color: $brand-primary; | ||
} | ||
} | ||
|
||
.btn-outline-primary { | ||
border-color: lighten($btn-primary-border, 10%); | ||
|
||
&:not(:disabled, .disabled) { | ||
&:hover, | ||
&:active, | ||
&:focus { | ||
color: darken($btn-primary-bg, 10%); | ||
background-image: none; | ||
background-color: lighten($btn-primary-bg, 50%); | ||
border-color: $btn-primary-border; | ||
} | ||
} | ||
|
||
.btn__circle { | ||
background: $btn-primary-bg; | ||
} | ||
} | ||
Comment on lines
-146
to
-176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These seems to not affect the end result anymore |
||
|
||
.btn-secondary { | ||
border-color: transparent; | ||
background-color: transparent; | ||
|
@@ -200,13 +166,17 @@ | |
&:not(:disabled, .disabled) { | ||
&:hover, | ||
&:focus, | ||
&.focus, | ||
&:active, | ||
&.active { | ||
&.focus { | ||
background-color: $btn-secondary-bg; | ||
border-color: $btn-secondary-bg; | ||
color: $text-muted; | ||
} | ||
&:active, | ||
&.active { | ||
background-color: var(--bs-btn-active-bg); | ||
border-color: var(--bs-btn-active-border-color); | ||
color: var(--bs-btn-active-color); | ||
} | ||
Comment on lines
-203
to
+179
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
} | ||
|
||
|
@@ -281,14 +251,14 @@ | |
|
||
// Close buttons | ||
// Bootstrap close button customizations | ||
.close { | ||
.btn-close { | ||
Comment on lines
-284
to
+254
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#close-button
|
||
font-size: ($font-size-base * 1.8); | ||
opacity: .3; | ||
line-height: 20px; | ||
display: block; | ||
} | ||
|
||
button.close { | ||
button.btn-close { | ||
padding: $input-btn-padding-y $input-btn-padding-x; | ||
} | ||
|
||
|
@@ -312,7 +282,7 @@ button.close { | |
} | ||
|
||
.actions-warning { | ||
color: #856404; // in bootstrap: theme-color-level(map-get($theme-colors, "yellow"), 6) | ||
color: #856404; // in bootstrap: shift-color(map-get($theme-colors, "yellow"), 6) | ||
Comment on lines
-315
to
+285
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#sass
https://getbootstrap.com/docs/5.0/migration/#color-system
|
||
|
||
// override .btn styles | ||
&.btn { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.message-box .close { | ||
.message-box .btn-close { | ||
cursor: pointer; | ||
padding-bottom: 0.9rem; | ||
padding-top: 0.6rem; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ class GridFieldActions extends PureComponent { | |
return groupsList; | ||
}, []); | ||
|
||
const dropdownMenuProps = { right: true }; | ||
const dropdownMenuProps = { end: true }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://reactstrap.github.io/?path=/story/home-upgrading--page
|
||
const dropdownToggleClassNames = [ | ||
'action-menu__toggle', | ||
'btn', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ test('GridFieldActions.render() should render a menu, if there is more than one | |
}} | ||
/> | ||
); | ||
expect(container.querySelector('.action-menu__toggle .sr-only').innerHTML).toBe('View actions'); | ||
expect(container.querySelector('.action-menu__toggle .visually-hidden').innerHTML).toBe('View actions'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#helpers
|
||
}); | ||
|
||
test('GridFieldActions.renderSingleAction() should render a button', () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; | |
|
||
const LabelField = ({ id, className, title, extraClass, data }) => { | ||
const htmlFor = data && data.target; | ||
const classes = `${className} ${extraClass}`; | ||
const classes = `form-label ${className} ${extraClass}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://getbootstrap.com/docs/5.0/migration/#forms
|
||
|
||
return ( | ||
<label id={id} className={classes} htmlFor={htmlFor}>{title}</label> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://getbootstrap.com/docs/5.0/migration/#javascript
Other
data-*
attributes that need changing seem to only need to be changed ifdata-bs-toggle
is also present - see this third-party script which seems to list all the relevant attributes (I didn't run this, just used it as a guide)