diff --git a/src/assets/images/theme7.webp b/src/assets/images/background-theme-placeholder.webp similarity index 100% rename from src/assets/images/theme7.webp rename to src/assets/images/background-theme-placeholder.webp diff --git a/src/assets/images/theme1.webp b/src/assets/images/basic-theme-placeholder.webp similarity index 100% rename from src/assets/images/theme1.webp rename to src/assets/images/basic-theme-placeholder.webp diff --git a/src/assets/images/theme6.webp b/src/assets/images/mobile-theme-placeholder.webp similarity index 100% rename from src/assets/images/theme6.webp rename to src/assets/images/mobile-theme-placeholder.webp diff --git a/src/assets/images/theme2.webp b/src/assets/images/modern-theme-placeholder.webp similarity index 100% rename from src/assets/images/theme2.webp rename to src/assets/images/modern-theme-placeholder.webp diff --git a/src/assets/images/theme5.webp b/src/assets/images/outline-theme-placeholder.webp similarity index 100% rename from src/assets/images/theme5.webp rename to src/assets/images/outline-theme-placeholder.webp diff --git a/src/assets/images/theme4.webp b/src/assets/images/preview-theme-placeholder.webp similarity index 100% rename from src/assets/images/theme4.webp rename to src/assets/images/preview-theme-placeholder.webp diff --git a/src/assets/images/theme3.webp b/src/assets/images/stylish-theme-placeholder.webp similarity index 100% rename from src/assets/images/theme3.webp rename to src/assets/images/stylish-theme-placeholder.webp diff --git a/src/components/Editor.js b/src/components/Editor.js index df12dd6..f3d0f7a 100644 --- a/src/components/Editor.js +++ b/src/components/Editor.js @@ -6,14 +6,8 @@ import RandomTheme from './RandomTheme'; import { ImgProvider } from '../utils/ImgContext' import Header from "./Header"; -import theme1 from '../assets/images/theme1.webp' -import theme2 from '../assets/images/theme2.webp' -import theme3 from '../assets/images/theme3.webp' -import theme4 from '../assets/images/theme4.webp' -import theme5 from '../assets/images/theme5.webp' -import theme6 from '../assets/images/theme6.webp' -import theme7 from '../assets/images/theme7.webp' +import { THEMES } from "../utils/constants"; const defaultIcon = { 'label': 'react', 'value': 'react' } @@ -38,7 +32,7 @@ class Editor extends React.Component { state = defaultSettings; componentDidMount() { - console.log("Mount") + // console.log("Mount") fetch(devIconsUrl).then(r => r.json()).then(data => { data.push({ name: 'custom' }) this.setState({ devIconOptions: data.map(item => ({ 'value': item.name, 'label': item.name })) }) @@ -257,38 +251,21 @@ class Editor extends React.Component { -
+
- basic theme this.setState({ theme: "background" })} - className=" cursor-pointer border border-gray-100 hover:border-gray-200 hover:scale-105 duration-300 " - /> - basic theme this.setState({ theme: "basic" })} - className=" cursor-pointer border-gray-100 hover:scale-105 duration-300 hover:border-gray-200 border" - /> - basic theme this.setState({ theme: "modern" })} - className="cursor-pointer border-gray-100 hover:scale-105 hover:border-gray-200 duration-300 border " - /> - basic theme this.setState({ theme: "stylish" })} - className=" cursor-pointer border border-gray-100 hover:border-gray-200 hover:scale-105 duration-300" - /> + { + THEMES.map(themePlaceholder => ( +
- basic theme this.setState({ theme: "outline" })} - className=" cursor-pointer border border-gray-100 hover:border-gray-200 hover:scale-105 duration-300" - /> - basic theme this.setState({ theme: "preview" })} - className=" cursor-pointer border border-gray-100 hover:border-gray-200 hover:scale-105 duration-300" - /> - basic theme this.setState({ theme: "mobile" })} - className=" cursor-pointer border border-gray-100 hover:border-gray-200 hover:scale-105 duration-300" - /> + {themePlaceholder.label} this.setState({ theme: themePlaceholder.label })} + className=" cursor-pointer border border-gray-100 hover:border-gray-200 hover:scale-105 duration-300 " + /> +
+ )) + } +
diff --git a/src/utils/constants.js b/src/utils/constants.js new file mode 100644 index 0000000..550c61a --- /dev/null +++ b/src/utils/constants.js @@ -0,0 +1,41 @@ + + +import backgroundThemePlaceholder from '../assets/images/background-theme-placeholder.webp' +import basicThemePlaceholder from '../assets/images/basic-theme-placeholder.webp' +import modernThemePlaceholder from '../assets/images/modern-theme-placeholder.webp' +import stylishThemePlaceholder from '../assets/images/stylish-theme-placeholder.webp' +import outlineThemePlaceholder from '../assets/images/outline-theme-placeholder.webp' +import previewThemePlaceholder from '../assets/images/preview-theme-placeholder.webp' +import mobileThemePlaceholder from '../assets/images/mobile-theme-placeholder.webp' + + +export const THEMES = [ + { + label: 'background', + preview: backgroundThemePlaceholder + }, + { + label: 'basic', + preview: basicThemePlaceholder + }, + { + label: 'modern', + preview: modernThemePlaceholder + }, + { + label: 'stylish', + preview: stylishThemePlaceholder + }, + { + label: 'outline', + preview: outlineThemePlaceholder + }, + { + label: 'preview', + preview: previewThemePlaceholder + }, + { + label: 'mobile', + preview: mobileThemePlaceholder + }, +] \ No newline at end of file