Skip to content

Commit

Permalink
set defalut theme if $UI_THEME is not set
Browse files Browse the repository at this point in the history
- use hash for theme colors, reduce repetition, simplify adding new
  theme
- provide default theme in case $UI_THEME is missing
  • Loading branch information
alexskr committed Nov 13, 2024
1 parent 86b9c6b commit 83c3543
Showing 1 changed file with 27 additions and 53 deletions.
80 changes: 27 additions & 53 deletions app/assets/stylesheets/theme-variables.scss.erb
Original file line number Diff line number Diff line change
@@ -1,56 +1,30 @@
<%# This file contains all the color themes of ontoportal alliance%>
<% if (ui_theme = $UI_THEME.to_s.parameterize)
case ui_theme
when "agroportal" %>
:root{
--primary-color: #3CB371;
--hover-color: #41C67C;
--secondary-color: #ffc107;
--light-color: #F1F6FA;
}
<% when "stageportal" %>
:root{
--primary-color: #37AEA0;
--hover-color: #3BBDAE;
--secondary-color: #ffc107;
--light-color: #ECF7F6;
}
<% when "bioportal" %>
:root{
--primary-color: #234979;
--hover-color: #6B96B7;
--secondary-color: #ffc107;
--light-color: #F0F5F6;
}

<% when "ontoportal" , "testportal" %>
:root{
--primary-color: #5499a4;
--hover-color: #6B96B7;
--secondary-color: #ffc107;
--light-color: #F1F6FA;
}
<%# Here to add a new theme ... %>
<% end %>
<% end %>



// common variables
:root{
--error-color: #EB4335;
--warning-color: #F2BE22;
--gray-color: #888888;
--success-color: #2DC54E;
--admin-color: #145FF4;
--container-max-width: 1248px;
--bg-info-light-color: rgba(59, 130, 246, 0.1);
--bg-danger-light-color: rgba(239, 68, 68, 0.1);
--bg-warning-light-color: rgba(234, 179, 8, 0.1);
--bg-success-light-color: rgba(34, 197, 94, 0.1);
<% themes = {
"agroportal" => { primary: "#3CB371", hover: "#41C67C", secondary: "#ffc107", light: "#F1F6FA" },
"stageportal" => { primary: "#37AEA0", hover: "#3BBDAE", secondary: "#ffc107", light: "#ECF7F6" },
"bioportal" => { primary: "#76A7CC", hover: "#6B96B7", secondary: "#ffc107", light: "#F0F5F6" },
"ontoportal" => { primary: "#5499a4", hover: "#6B96B7", secondary: "#ffc107", light: "#F1F6FA" },
"testportal" => { primary: "#5499a4", hover: "#6B96B7", secondary: "#ffc107", light: "#F1F6FA" }
} %>

<% ui_theme = $UI_THEME.to_s.parameterize %>
<% selected_theme_key = themes.key?(ui_theme) ? ui_theme : "ontoportal" %>
<% selected_theme = themes[selected_theme_key] %>

:root {
--primary-color: <%= selected_theme[:primary] %>;
--hover-color: <%= selected_theme[:hover] %>;
--secondary-color: <%= selected_theme[:secondary] %>;
--light-color: <%= selected_theme[:light] %>;
--error-color: #EB4335;
--warning-color: #F2BE22;
--gray-color: #888888;
--success-color: #2DC54E;
--admin-color: #145FF4;
--container-max-width: 1248px;
--bg-info-light-color: rgba(59, 130, 246, 0.1);
--bg-danger-light-color: rgba(239, 68, 68, 0.1);
--bg-warning-light-color: rgba(234, 179, 8, 0.1);
--bg-success-light-color: rgba(34, 197, 94, 0.1);
}





0 comments on commit 83c3543

Please sign in to comment.