Skip to content

Commit

Permalink
Merge pull request #26 from WDAqua/fix/itzbund-theme-corrections
Browse files Browse the repository at this point in the history
Store theme choice in localstorage, use env for default
  • Loading branch information
Wutras authored Oct 17, 2023
2 parents fa73e89 + 5a0324f commit d307425
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ARG DEFAULT_CHATBOT_BACKEND_URL
ARG DEFAULT_CHATBOT_COMPONENTS
ARG INITIAL_QUESTION_PARAMETER_NAME
ARG DEFAULT_BACKEND_TYPE
ARG DEFAULT_THEME

WORKDIR /app
COPY ./package*.json ./
Expand Down
4 changes: 3 additions & 1 deletion src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
defaultBackendType,
defaultChatbotComponents,
initialQuestionParameter,
defaultTheme,
} from "../../helpers/constants";
import {
supportedServiceNames,
Expand Down Expand Up @@ -61,7 +62,7 @@ class App extends Component {
backendUrl,
isSending: false,
backendType,
currentTheme: "default",
currentTheme: localStorage.getItem("currentTheme") ?? defaultTheme,
iconUrl,
};

Expand Down Expand Up @@ -186,6 +187,7 @@ class App extends Component {
setTheme(themeName) {
if (!supportedThemes.includes(themeName)) return;

localStorage.setItem("currentTheme", themeName);
this.setState({
currentTheme: themeName,
});
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ export const defaultRasaBackendUrl =

export const defaultBackendType =
window._env_?.DEFAULT_BACKEND_TYPE ?? "qanary";

export const defaultTheme =
window._env_?.DEFAULT_THEME ?? "default";

0 comments on commit d307425

Please sign in to comment.