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

feat: CSS-in-JS pt 2 #712

Conversation

muselesscreator
Copy link
Contributor

@muselesscreator muselesscreator commented May 6, 2021

Migrates all scss variables into theme.js file, and modifies them with applyTheme method stored in brand repo (PRs active in both brand-openedx and brand-edx.org).
Uses emotion theme values to style the StatusAlert, FormText, and FormControlSet components.

JIRA:
https://openedx.atlassian.net/browse/PAR-450
https://openedx.atlassian.net/browse/PAR-451
https://openedx.atlassian.net/browse/PAR-452
https://openedx.atlassian.net/browse/PAR-454

@muselesscreator muselesscreator changed the title feat: CSS-in-JS (base theme, brand layering, applied to StatusAlert) feat: CSS-in-JS pt 2 May 6, 2021
const _whiteMix = (color, perc) => _mix(
colors.white, colors[color], perc,
);
const genColorLevels = (colorKey) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this produce the same hex values for all the colors as the original theme? (I'm not familiar with how it generates colors)

_elementColorLevels = theme.elementColorLevels;
}

let baseColor = '#808080';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just a default in case something valid wasn't specified? Should it maybe be based on grey 500, rather than in between grey color levels?

// Set the number of columns and specify the width of the gutters.
const grid = {
columns: 12,
gutterWidth: '30px',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be expressed in terms of the spacer?

marginY: spacer,
},
mark: {
padding: '.2em',
Copy link
Contributor

Choose a reason for hiding this comment

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

Intentional that this is em instead of rem?

@abutterworth abutterworth changed the base branch from master to abutterworth/css-in-js May 17, 2021 18:18
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { jsx, useTheme } from '@emotion/react';
import { formControlSetStyle } from './style';
Copy link
Contributor

Choose a reason for hiding this comment

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

Why put this in a separate file?

const style = formControlSetStyle(useTheme());
return jsx(as, {
className: classNames(className, 'pgn__form-control-set'),
css: isInline ? style.inline : style.base,
Copy link
Contributor

Choose a reason for hiding this comment

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

the css prop can be a function that accepts theme. It's probably better to use that form instead of grabbing the theme with useTheme

Suggested change
css: isInline ? style.inline : style.base,
css: (theme) => {
const style = formControlSetStyle(theme);
if (isInline)
return style.inline;
}
return style.base;
},

Comment on lines +60 to +62
const className = classNames(props.className);
const style = formTextStyle(useTheme());
const css = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar feedback/point of discussion as above.

@@ -23,13 +29,13 @@ const ParagonProvider = ({
ParagonProvider.propTypes = {
locale: PropTypes.string,
// eslint-disable-next-line react/forbid-prop-types
theme: PropTypes.object,
theme: PropTypes.func,
Copy link
Contributor

Choose a reason for hiding this comment

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

In this change you're suggesting theme must be a function?

Comment on lines +95 to +100
assertStatusAlertOpen(true);
wrapper.find('withDeprecatedProps(Button)').at(0).simulate(
'keyDown',
{ ...event, key: 'Enter' },
);
assertStatusAlertOpen(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Changes in this file seem unrelated to the purpose of this PR. Is there a reason this is all needed?

Comment on lines +16 to +18
bgLevel: -10,
borderLevel: -9,
colorLevel: 6,
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these for?

Comment on lines 2 to 5
// The default theme.js for Paragon. The structure of this object follows the
// theme specification found here: https://system-ui.com/theme/. We prefer to add
// to this theme over time rather than all valid keys at once to ensure everything
// present here is used in the system.
Copy link
Contributor

Choose a reason for hiding this comment

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

What exists below is a departure from the strategy articulated in this comment. And what's below doesn't follow the theme specification from system-ui. Let's discuss if this direct port of Bootstrap is desirable and if so, what next steps should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants