Reduce calls of flattenColorPalette

This commit is contained in:
Irene Lin 2020-05-07 00:22:07 +10:00
parent 99a5fea06d
commit 2ba2b72fc8
6 changed files with 20 additions and 12 deletions

View File

@ -4,9 +4,11 @@ import withAlphaVariable from '../util/withAlphaVariable'
export default function() {
return function({ addUtilities, e, theme, variants, target, corePlugins }) {
const colors = flattenColorPalette(theme('backgroundColor'))
if (target('backgroundColor') === 'ie11') {
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('backgroundColor')), (value, modifier) => {
_.map(colors, (value, modifier) => {
return [`.${e(`bg-${modifier}`)}`, { 'background-color': value }]
})
)
@ -17,7 +19,7 @@ export default function() {
}
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('backgroundColor')), (value, modifier) => {
_.map(colors, (value, modifier) => {
return [
`.${e(`bg-${modifier}`)}`,
corePlugins('backgroundOpacity')

View File

@ -4,9 +4,9 @@ import withAlphaVariable from '../util/withAlphaVariable'
export default function() {
return function({ addUtilities, e, theme, variants, target, corePlugins }) {
if (target('borderColor') === 'ie11') {
const colors = flattenColorPalette(theme('borderColor'))
const colors = flattenColorPalette(theme('borderColor'))
if (target('borderColor') === 'ie11') {
const utilities = _.fromPairs(
_.map(_.omit(colors, 'default'), (value, modifier) => {
return [`.${e(`border-${modifier}`)}`, { 'border-color': value }]
@ -18,8 +18,6 @@ export default function() {
return
}
const colors = flattenColorPalette(theme('borderColor'))
const utilities = _.fromPairs(
_.map(_.omit(colors, 'default'), (value, modifier) => {
return [

View File

@ -3,8 +3,10 @@ import flattenColorPalette from '../util/flattenColorPalette'
export default function() {
return function({ addUtilities, e, theme, variants }) {
const colors = flattenColorPalette(theme('fill'))
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('fill')), (value, modifier) => {
_.map(colors, (value, modifier) => {
return [
`.${e(`fill-${modifier}`)}`,
{

View File

@ -4,9 +4,11 @@ import withAlphaVariable from '../util/withAlphaVariable'
export default function() {
return function({ addUtilities, e, theme, variants, target, corePlugins }) {
const colors = flattenColorPalette(theme('placeholderColor'))
if (target('placeholderColor') === 'ie11') {
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('placeholderColor')), (value, modifier) => {
_.map(colors, (value, modifier) => {
return [`.${e(`placeholder-${modifier}`)}::placeholder`, { color: value }]
})
)
@ -17,7 +19,7 @@ export default function() {
}
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('placeholderColor')), (value, modifier) => {
_.map(colors, (value, modifier) => {
return [
`.${e(`placeholder-${modifier}`)}::placeholder`,
corePlugins('placeholderOpacity')

View File

@ -3,8 +3,10 @@ import flattenColorPalette from '../util/flattenColorPalette'
export default function() {
return function({ addUtilities, e, theme, variants }) {
const colors = flattenColorPalette(theme('stroke'))
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('stroke')), (value, modifier) => {
_.map(colors, (value, modifier) => {
return [
`.${e(`stroke-${modifier}`)}`,
{

View File

@ -4,9 +4,11 @@ import withAlphaVariable from '../util/withAlphaVariable'
export default function() {
return function({ addUtilities, e, theme, variants, target, corePlugins }) {
const colors = flattenColorPalette(theme('textColor'))
if (target('textColor') === 'ie11') {
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('textColor')), (value, modifier) => {
_.map(colors, (value, modifier) => {
return [`.${e(`text-${modifier}`)}`, { color: value }]
})
)
@ -17,7 +19,7 @@ export default function() {
}
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('textColor')), (value, modifier) => {
_.map(colors, (value, modifier) => {
return [
`.${e(`text-${modifier}`)}`,
corePlugins('textOpacity')