manabuyasuda / website-template

静的Webサイト制作を少しモダンにするためのテンプレート
https://manabuyasuda-website-template.netlify.app/styleguide/
MIT License
60 stars 13 forks source link

Add: Autoprefixerオプションにgridを追加 #279

Closed manabuyasuda closed 5 years ago

manabuyasuda commented 5 years ago
function css() {
  const plugins = [flexBugsFixes(), autoprefixer({
    grid: true
  })];
manabuyasuda commented 5 years ago

grid: trueは非推奨になっていて、代わりに"no-autoplace"を使う。 もしくは自動配置サポートもする"autoplace"を使う。

options

manabuyasuda commented 5 years ago

変換前

.container {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: 50px 1fr 50px;
}

aside {
  grid-column: 1 / 2;
  grid-row: 1 / 4;
}

header {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

grid:no-autoplacetrue)で変換後

.container {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 200px 1fr;
  grid-template-columns: 200px 1fr;
  -ms-grid-rows: 50px 1fr 50px;
  grid-template-rows: 50px 1fr 50px
}
aside {
  -ms-grid-column: 1;
  -ms-grid-column-span: 1;
  grid-column: 1/2;
  -ms-grid-row: 1;
  -ms-grid-row-span: 3;
  grid-row: 1/4
}
header {
  -ms-grid-column: 2;
  -ms-grid-column-span: 1;
  grid-column: 2/3;
  -ms-grid-row: 1;
  -ms-grid-row-span: 1;
  grid-row: 1/2
}

autoplaceで変換後。no-autoplace.container > :nth-child(1)のセレクターが追加される。

.container {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 200px 1fr;
  grid-template-columns: 200px 1fr;
  -ms-grid-rows: 50px 1fr 50px;
  grid-template-rows: 50px 1fr 50px
}
.container > :nth-child(1) {
  -ms-grid-row: 1;
  -ms-grid-column: 1
}
.container > :nth-child(2) {
  -ms-grid-row: 1;
  -ms-grid-column: 2
}
.container > :nth-child(3) {
  -ms-grid-row: 2;
  -ms-grid-column: 1
}
.container > :nth-child(4) {
  -ms-grid-row: 2;
  -ms-grid-column: 2
}
.container > :nth-child(5) {
  -ms-grid-row: 3;
  -ms-grid-column: 1
}
.container > :nth-child(6) {
  -ms-grid-row: 3;
  -ms-grid-column: 2
}
aside {
  -ms-grid-column: 1;
  -ms-grid-column-span: 1;
  grid-column: 1/2;
  -ms-grid-row: 1;
  -ms-grid-row-span: 3;
  grid-row: 1/4
}
header {
  -ms-grid-column: 2;
  -ms-grid-column-span: 1;
  grid-column: 2/3;
  -ms-grid-row: 1;
  -ms-grid-row-span: 1;
  grid-row: 1/2
}