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

[css-grid] Handle [align/justify]-[content/items] appropriately #1118

Closed
Dan503 opened this issue Sep 16, 2018 · 11 comments
Closed

[css-grid] Handle [align/justify]-[content/items] appropriately #1118

Dan503 opened this issue Sep 16, 2018 · 11 comments
Labels

Comments

@Dan503
Copy link
Contributor

Dan503 commented Sep 16, 2018

IE does not supporting any of these properties:

  • align-content
  • align-items
  • justify-content
  • justify-items

For align-items and justify-items, you can often work around the issue by using align-self and justify-self instead:

/* This: */
.grid {
  justify-items: center;
  align-items: center;
}

/* Is very similar to this: */
.grid > * {
  align-self: center;
  justify-self: center;
}

It doesn't work in 100% of circumstances but it does work most of the time. If Autoprefixer knows that the element is a grid container then it should be prefixed like so:

Input CSS

.grid {
  display: grid;
  justify-items: center;
  align-items: center;
}

Expected output CSS

.grid {
  display: -ms-grid;
  display: grid;
  justify-items: center;
  align-items: center;
}
.grid > * {
  -ms-grid-column-align: center;
  -ms-grid-row-align: center;
}

If justify-items or align-items is used in the same rule as any of the following properties, then it is safe to assume that it is a grid container element:

  • display: grid
  • display: inline-grid
  • grid-template-columns
  • grid-template-rows
  • grid-template-areas
  • grid-template
  • grid-column-gap
  • grid-row-gap
  • grid-gap

For align-content and justify-content Autoprefixer should warn users that IE does not support those properties if it detects that they are being used on a grid container and grid translations are enabled.

Example Warning:

IE does not support align-content and justify-content on grid containers

@Dan503
Copy link
Contributor Author

Dan503 commented Sep 17, 2018

If the author uses place-items: center; Autoprefixer should treat that in the same way as if the author wrote justify-items: center; align-items: center;.

@ai ai added the support label Sep 17, 2018
@ai
Copy link
Member

ai commented Sep 17, 2018

Maybe we should show the warning on both cases? It is not so hard for user to move justify-self into grid children.

@Dan503
Copy link
Contributor Author

Dan503 commented Sep 17, 2018

We could but Autoprefixer is all about automating as much as possible so users don't have to think about IE as much.

I don't see any downsides to prefixing the align/justify-items property in this way so I don't really see much reason not to do it.

Can you think of any significant downsides?

@ai
Copy link
Member

ai commented Sep 17, 2018

Can you think of any significant downsides?

.child {
  align-self: start;
}
.parent {
  display: grid;
  align-items: center;
}

@Dan503
Copy link
Contributor Author

Dan503 commented Sep 17, 2018

🤔...😵 right.

Ok maybe just warnings for both then.

@Dan503
Copy link
Contributor Author

Dan503 commented Sep 17, 2018

If we give a warning for align/justify-items then in that warning we should also recommend trying align/justify-self on the child elements instead so that people know that it is an option.

@ai
Copy link
Member

ai commented Sep 18, 2018

I sent this task to our Cult of Martians

@andrIvash
Copy link

Is it possible to run some testing method each time while checking property?
andrIvash@fd23781

@bogdan0083
Copy link
Contributor

@andrIvash I'm not sure I understood you correctly, but If you want to run some function for a test stylesheet and compare the output, you need to check out autoprefixer.test.js file which contains many examples and where most of properties are tested.

Also check out test/cases folder. This is where css files are located for testing.

@Dan503
Copy link
Contributor Author

Dan503 commented Sep 21, 2018

The easiest way to do quick tests using the current code base is by running the gulp play command and writing input CSS into playground/input.css.

Check the output in playground/output.css.

@fanich37
Copy link
Contributor

Maybe it should look smth like this:
fanich37@3864f68

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

No branches or pull requests

5 participants