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

Extend Grid layout with custom rows and columns options and more (#149) #183

Merged
merged 3 commits into from
Nov 4, 2020

Conversation

adamkudrna
Copy link
Member

image

image

image

Closes #149.

@adamkudrna adamkudrna self-assigned this Oct 30, 2020
@github-actions github-actions bot added the BC Breaking change label Oct 30, 2020
@bedrich-schindler
Copy link
Contributor

Awesome! That' exactly what I needed.

src/gatsby-theme-docz/wrapper.js Show resolved Hide resolved
@@ -25,7 +25,8 @@
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".mdx"] }],
"react/jsx-indent": "off", // Gives false positives in MDX files.
"semi": "off" // We don't want to clutter our MDX with semicolons.
"semi": "off", // We don't want to clutter our MDX with semicolons.
"sort-keys": "off" // This rule only needs to be turned off in a few places (eg. breakpoint lists), but weirdly enough, an inline comment alerts breaking of the `indent` rule.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use sort-keys disabled inline. I do not agree with disabling it globally.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd love to do it locally, but it triggers another alert:

image

image

I don't know what to do with that…

Copy link
Contributor

Choose a reason for hiding this comment

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

If it is for MDX only, we can leave it as it is.

.eslintrc Show resolved Hide resolved
import { generateResponsiveCustomProperties } from './helpers';
import styles from './Grid.scss';

export const GridSpan = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer the destructuring syntax:

export const GridSpan = ({
    children,
    columns,
    id,
    rows,
    ...other
  }) => {

I know it is not used elsewhere, but I find it easier to read. In fact I think we should update other files to use it as well (not in this PR obviously).

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact I think we should update other files to use it as well (not in this PR obviously).

Sure, there is an issue for that: #113.

Copy link
Member Author

Choose a reason for hiding this comment

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

And thank you for pointing it out, I missed it somehow this time.

@@ -0,0 +1,19 @@
export const generateResponsiveCustomProperties = (prop, infix) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to have one named export per file where the the filename is the name of the function. So this file should be named helpers/generateResponsiveCustomProperties.js

It makes the implementation, but especially the tests much easier to read.

return null;
}

const customProperties = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

I would replace it with:

  if (typeof prop !== 'object') {
    return { [`--rui-local-${infix}-xs`]: prop };
  }

  return Object.keys(prop).reduce((acc, breakpoint) => ({
    ...acc,
    [`--rui-local-${infix}-${breakpoint}`]: prop[breakpoint],
  }), {});

The return early pattern makes it easier to follow as I can exit the function, well, early as the logical branches do not reconnect.

@@ -0,0 +1,19 @@
export const generateResponsiveCustomProperties = (prop, infix) => {
if (typeof prop === 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should add a unit test…

@adamkudrna adamkudrna requested a review from mbohal November 3, 2020 17:10
import { generateResponsiveCustomProperties } from '../generateResponsiveCustomProperties';

describe('generateResponsiveCustomProperties', () => {
it('when prop is undefined', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It is up to you. But I would use test here, it would make sense then.

@adamkudrna adamkudrna merged commit e55af80 into master Nov 4, 2020
@adamkudrna adamkudrna deleted the bc/149 branch November 4, 2020 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend Grid with column options
3 participants