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

Migrate to css-in-js with linaria #2256

Merged
merged 30 commits into from
Jan 21, 2021
Merged

Migrate to css-in-js with linaria #2256

merged 30 commits into from
Jan 21, 2021

Conversation

nstepien
Copy link
Contributor

@nstepien nstepien commented Dec 17, 2020

Docs: https://github.com/callstack/linaria

Rollup is set up so we inject the styles, that way users don't have to worry about manually importing a stylesheet.


I tried using polished with its babel plugin, but that didn't transpile everything away, for example:

// transpiled away :^)
darken(0.2, '#fff');

// not transpiled away :^(
const bg = '#fff';
darken(0.2, bg);

I decided to use hsl() instead, close enough.

@nstepien nstepien self-assigned this Dec 17, 2020
"*.less"
],
"scripts": {
"start": "start-storybook --quiet --no-dll -p 6006",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nstepien nstepien marked this pull request as ready for review December 18, 2020 16:06
Copy link
Contributor

@amanmahajan7 amanmahajan7 left a comment

Choose a reason for hiding this comment

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

Looks really good. A few discussion items

src/Cell.tsx Show resolved Hide resolved
src/Row.tsx Show resolved Hide resolved
tabIndex={-1}
onKeyDown={handleKeyDown}
>
{groupKey}
<svg viewBox="0 0 14 8" width="14" height="8" className="rdg-caret">
<svg viewBox="0 0 14 8" width="14" height="8" className={caretClassname}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think where possible, we can move the styles in the file that use them. This way we can encapsulate styles and I think that is what CSS-in-JS libraries promote. Wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, in some cases the styles are intertwined and need other generated class names, so I left them alone for now.

src/style/editor.ts Outdated Show resolved Hide resolved
@@ -16,10 +17,10 @@ function SummaryCell<R, SR>({
}: SummaryCellProps<R, SR>) {
const { summaryFormatter: SummaryFormatter, summaryCellClass } = column;
const className = clsx(
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should create a helper component that can render the default styles for example

export function DefaultCell({ column, className, props }) {
className = clsx(
    cellClassname,
    {
      [cellFrozenClassname]: column.frozen,
      [cellFrozenLastClassname]: column.isLastFrozenColumn
    },
    className
  );

  return (
    <div
      role="gridcell"
      aria-colindex={column.idx + 1}
      className={className}
      {...props}
    >
     {children}
    </div>
  );
}

Wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's more stuff for react to render, not sure 🤔

Copy link
Contributor

@amanmahajan7 amanmahajan7 left a comment

Choose a reason for hiding this comment

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

Looks great 👍

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.

2 participants