Skip to content

Commit

Permalink
added icon to themes
Browse files Browse the repository at this point in the history
  • Loading branch information
cicirello committed Aug 19, 2022
1 parent 393e80c commit e7cb39e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 21 deletions.
1 change: 1 addition & 0 deletions octicons/mark-github-16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 43 additions & 21 deletions src/Colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,86 +77,108 @@
# for list of named colors.

colorMapping = {

# Contributor: cicirello (part of initial theme set)
"dark" : {
"bg" : "#010409",
"border" : "rgba(56,139,253,0.4)",
"icons" : "#1f6feb",
"text" : "#c9d1d9",
"title" : "#58a6ff"
},
"title" : "#58a6ff",
"title-icon" : "github"
},

# Contributor: cicirello (updated theme set)
"dark-colorblind" : {
"bg" : "#010409",
"border" : "rgba(56,139,253,0.4)",
"icons" : "#1f6feb",
"text" : "#c9d1d9",
"title" : "#58a6ff"
},
"title" : "#58a6ff",
"title-icon" : "github"
},

# Contributor: cicirello (part of initial theme set)
"dark-dimmed" : {
"bg" : "#1c2128",
"border" : "rgba(65,132,228,0.4)",
"icons" : "#316dca",
"text" : "#adbac7",
"title" : "#539bf5"
},
"title" : "#539bf5",
"title-icon" : "github"
},

# Contributor: cicirello (updated theme set)
"dark-high-contrast" : {
"bg" : "#010409",
"border" : "#409eff",
"icons" : "#409eff",
"text" : "#f0f3f6",
"title" : "#71b7ff"
},
"title" : "#71b7ff",
"title-icon" : "github"
},

# Contributor: cicirello (updated theme set)
"dark-tritanopia" : {
"bg" : "#010409",
"border" : "rgba(56,139,253,0.4)",
"icons" : "#1f6feb",
"text" : "#c9d1d9",
"title" : "#58a6ff"
},
"title" : "#58a6ff",
"title-icon" : "github"
},

# Contributor: cicirello (part of initial theme set)
"light" : {
"bg" : "#f6f8fa",
"border" : "rgba(84,174,255,0.4)",
"icons" : "#0969da",
"text" : "#24292f",
"title" : "#0969da"
},
"title" : "#0969da",
"title-icon" : "github"
},

# Contributor: cicirello (updated theme set)
"light-colorblind" : {
"bg" : "#f6f8fa",
"border" : "rgba(84,174,255,0.4)",
"icons" : "#0969da",
"text" : "#24292f",
"title" : "#0969da"
},
"title" : "#0969da",
"title-icon" : "github"
},

# Contributor: cicirello (updated theme set)
"light-high-contrast" : {
"bg" : "#ffffff",
"border" : "#368cf9",
"icons" : "#0349b4",
"text" : "#0E1116",
"title" : "#0349b4"
},
"title" : "#0349b4",
"title-icon" : "github"
},

# Contributor: cicirello (updated theme set)
"light-tritanopia" : {
"bg" : "#f6f8fa",
"border" : "rgba(84,174,255,0.4)",
"icons" : "#0969da",
"text" : "#24292f",
"title" : "#0969da"
}

}
"title" : "#0969da",
"title-icon" : "github"
},
}

# These are template strings for the icons available for the title line.
# Each color theme has an associated icon. User can also override the default
# for the theme by name.
#
# The template strings each have up to 3 inputs, {0}, {1}, and {2}.
# {0} is the x position in pixels.
# {1} is the y position in pixels.
# {2}, if present, is the fill color, which will be populated with the high
# contrasting color relative to the background (e.g., for github, it will
# either be white or black depending upon background, which is consistent
# with GitHub's logo usage guidelines.
iconTemplates = {
"github" : """<svg x="{0}" y="{1}" width="32" height="32" viewBox="0 0 16 16"><path fill="{2}" fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>""",
}
11 changes: 11 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ def test_color_themes(self) :
}
for theme in originalThemes :
self._colorValidation(colorMapping[theme])
self._iconValidation(colorMapping[theme])
for theme in colorMapping :
if theme not in originalThemes :
self._colorValidation(colorMapping[theme])
self._iconValidation(colorMapping[theme])

def test_color_contrast_text_vs_bg(self) :
for theme, colors in colorMapping.items() :
Expand Down Expand Up @@ -327,6 +329,15 @@ def _colorValidation(self, theme) :
for p in props :
color = theme[p]
self.assertTrue(isValidColor(color))

def _iconValidation(self, theme) :
self.assertTrue("title-icon" in theme)
iconKey = theme["title-icon"]
self.assertTrue(iconKey in iconTemplates)
formattedIconString = iconTemplates[iconKey].format(42, 53, "fake-color-to-confirm-inserted")
self.assertTrue(formattedIconString.find('x="42"') >= 0)
self.assertTrue(formattedIconString.find('y="53"') >= 0)
self.assertTrue(iconTemplates[iconKey].find("{2}") < 0 or formattedIconString.find('fill="fake-color-to-confirm-inserted"') >= 0)

def _validate(self, stats, skip=False) :
self.assertEqual("repo23", stats._user["mostStarred"][0])
Expand Down

0 comments on commit e7cb39e

Please sign in to comment.