Logo Voyage

Module:TypeToColor Voyage Tips and guide

You can check the original Wikivoyage article Here
[view] [edit] [history] [purge] Documentation

    This template converts a "type" value to a color, using the supported icon set. It is used in Template:Marker and Template:Listing.

    All colors should pass WCAG AA guidelines for color contrast.

    Overview of colors used in Wikivoyage
    Type CSS3 color name Example
    see #387bb2   
    do #757070   
    buy #008080   
    eat #b1591b   
    drink #000000   
    sleep #000080   
    listing #258825   
    go #A52A2A   
    city #0000FF   
    other #258825   
    view #4169E1   
    vicinity #800000   
    around #800080   
    gold #FFD700   
    lime #BFFF00   
    red #FF0000   
    silver #C0C0C0   
    Example color outputs
    Input Output Comment
    #{{#invoke:TypeToColor|convert|sleep}} #000080 type to color
    #{{#invoke:TypeToColor|convert|red}} #FF0000 color to color
    #{{#invoke:TypeToColor|convert|wrong}} #C0C0C0 wrong to default
    #{{#invoke:TypeToColor|convert|}} #C0C0C0 no to default

    local p = {}
    
    function p.convert( frame )
    	return p.convertImpl(frame.args[1])
    end
    
    function p.convertImpl(type)
    	type = type:lower()
    	local types = {
    		['do'] = '757070',
    		around = '800080',
    		buy = '008080',
    		city = '0000FF',
    		drink = '000000',
    		eat = 'b1591b',
    		go = 'A52A2A',
    		listing = '258825',
    		other = '258825',
    		see = '387bb2',
    		sleep = '000080',
    		vicinity = '800000',
    		view = '4169E1',
    
    		launchsite = 'FF8C00',
    	}
    
    	local result = types[type]
    	if result then
    		return result
    	end
    	
    	-- Deprecated usage - trace it
    	types = {
    		black = '000000',
    		blue = '0000FF',
    		brown = 'A52A2A',
    		chocolate = 'D2691E',
    		forestgreen = '228B22',
    		gold = 'FFD700',
    		gray = '808080',
    		grey = '808080',
    		lime = 'BFFF00',
    		magenta = 'FF00FF',
    		maroon = '800000',
    		mediumaquamarine = '66CDAA',
    		navy = '000080',
    		orange = 'FFA500',
    		plum = 'DDA0DD',
    		purple = '800080',
    		red = 'FF0000',
    		royalblue = '4169E1',
    		silver = 'C0C0C0',
    		steelblue = '4682B4',
    		teal = '008080',
    	}
    
    	local result = types[type]
    	if result then
    		return result --  .. '[[category:Fixme TypeToColor]]'
    	end
    
    	return 'C0C0C0' -- .. '[[category:Fixme TypeToColor Unknown]]'
    end
    
    return p
    


    Discover



    Powered by GetYourGuide