Modulo:Materialize colors examples: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
+allPalettesHTML
respect color order
Riga 252:
-- save a color flavor
function p._newFlavor( base, i, isDark )
-- index by desired order
p._KNOWN_FLAVORS[ #p._KNOWN_FLAVORS +1 ] = MaterialFlavor:new( base, i, isDark )
end
Line 257 ⟶ 258:
-- save a color by its name
function p._newColor( color, skipAccent )
-- index by name
p._KNOWN_COLORS_KNOWN_COLORS_BY_NAME[ color ] = MaterialColor:new( color, skipAccent )
 
-- index by desired order
p._KNOWN_COLORS_BY_ORDER[ #p._KNOWN_COLORS_BY_ORDER + 1 ] = p._KNOWN_COLORS_BY_NAME[ color ]
end
 
Line 281 ⟶ 286:
 
--- a complete array of known colors indexed by name
p._KNOWN_COLORS_KNOWN_COLORS_BY_ORDER = {}
p._KNOWN_COLORS_BY_NAME = {}
p._newColor( "red" )
p._newColor( "pink" )
Line 308 ⟶ 314:
-- get a color by its name
function p._getColor( name )
return p._KNOWN_COLORS_KNOWN_COLORS_BY_NAME[ name ] or error( "unknown color" )
end
 
Line 366 ⟶ 372:
 
-- generate all palettes
for i, color in pairs( p._KNOWN_COLORS_KNOWN_COLORS_BY_ORDER ) do
s = s .. containerPre
s = s .. color:createPaletteHTML( p._KNOWN_FLAVORS, containerClass )