Skip to content

Commit

Permalink
🔥 create module shared component theme (#729)
Browse files Browse the repository at this point in the history
* extract new module component to a shared component

* use effect deps

* respect theme palette

* refactor use effect

* add shared component dark theme

* remove dark theme
  • Loading branch information
petar-cvit authored Jan 21, 2025
1 parent 8434d87 commit 71ca190
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cyclops-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cyclopsui/cyclops-ui",
"version": "0.1.15",
"version": "0.1.21",
"private": false,
"license": "Apache-2.0",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion cyclops-ui/src/components/form/fields/object/custom.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.nested-fields.dark .ant-collapse-content-box {
background-color: #555;
background-color: #404040;
}
3 changes: 3 additions & 0 deletions cyclops-ui/src/components/pages/EditModule/EditModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const EditModule = () => {
onUpdateModuleSuccess={(moduleName) => {
window.location.href = "/modules/" + moduleName;
}}
onBackButton={(moduleName) => {
window.location.href = "/modules/" + moduleName;
}}
/>
);
};
Expand Down
26 changes: 16 additions & 10 deletions cyclops-ui/src/components/pages/NewModule/NewModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ import {

const NewModule = () => {
return (
<CreateModuleComponent
getTemplateStore={getTemplateStore}
getNamespaces={getNamespaces}
getTemplate={getTemplate}
getTemplateInitialValues={getTemplateInitialValues}
submitModule={createModule}
onSubmitModuleSuccess={(moduleName) => {
window.location.href = "/modules/" + moduleName;
}}
/>
<div>
<CreateModuleComponent
themePalette={"light"}
getTemplateStore={getTemplateStore}
getNamespaces={getNamespaces}
getTemplate={getTemplate}
getTemplateInitialValues={getTemplateInitialValues}
submitModule={createModule}
onSubmitModuleSuccess={(moduleName) => {
window.location.href = "/modules/" + moduleName;
}}
onBackButton={() => {
window.location.href = "/modules";
}}
/>
</div>
);
};
export default NewModule;
21 changes: 17 additions & 4 deletions cyclops-ui/src/components/shared/CreateModule/CreateModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export interface CreateModuleProps {
values: string,
) => Promise<any>;
onSubmitModuleSuccess: (moduleName: string) => void;
onBackButton: () => void;
}

export const CreateModuleComponent = ({
Expand All @@ -86,6 +87,7 @@ export const CreateModuleComponent = ({
getTemplateInitialValues,
submitModule,
onSubmitModuleSuccess,
onBackButton,
}: CreateModuleProps) => {
const [loading, setLoading] = useState(false);
const [config, setConfig] = useState({
Expand Down Expand Up @@ -295,6 +297,7 @@ export const CreateModuleComponent = ({
if (!loadingTemplate && !loadingTemplateInitialValues) {
return (
<TemplateFormFields
themePalette={themePalette}
isModuleEdit={false}
fields={config.root.properties}
parentFieldID={[]}
Expand Down Expand Up @@ -488,11 +491,14 @@ export const CreateModuleComponent = ({
<Col style={{ padding: "0px" }} span={16}>
<div
style={{
border: "solid 1.5px #c3c3c3",
border: themePalette === "light" ? "#c3c3c3" : "#707070",
borderWidth: "1.5px",
borderStyle: "solid",
borderRadius: "7px",
padding: "0px",
width: "100%",
backgroundColor: "#fafafa",
backgroundColor:
themePalette === "light" ? "#fafafa" : "#404040",
}}
>
<Form.Item
Expand Down Expand Up @@ -562,7 +568,14 @@ export const CreateModuleComponent = ({
</Select>
</Form.Item>
</div>
<div className={"expandadvanced"} onClick={toggleExpand}>
<div
className={"expandadvanced"}
style={{
backgroundColor:
themePalette === "light" ? "#eee" : "#595959",
}}
onClick={toggleExpand}
>
{advancedOptionsExpanded ? (
<div>
Advanced
Expand Down Expand Up @@ -616,7 +629,7 @@ export const CreateModuleComponent = ({
</Button>{" "}
<Button
htmlType="button"
onClick={() => (window.location.href = "/")}
onClick={() => onBackButton()}
disabled={loadingTemplate || loadingTemplateInitialValues}
>
Back
Expand Down
5 changes: 0 additions & 5 deletions cyclops-ui/src/components/shared/CreateModule/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ code {
.expandadvanced {
width: 100%;
height: 32px;
background-color: #eee;
border-radius: 0 0 7px 7px;
transition: background-color 0.2s ease;
display: flex;
Expand All @@ -29,7 +28,3 @@ code {
text-align: center;
cursor: pointer;
}

.expandadvanced:hover {
background-color: #e0e0e0;
}
4 changes: 3 additions & 1 deletion cyclops-ui/src/components/shared/EditModule/EditModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface EditModuleProps {
values: string,
) => Promise<any>;
onUpdateModuleSuccess: (moduleName: string) => void;
onBackButton: (moduleName: string) => void;
}

export const EditModuleComponent = ({
Expand All @@ -70,6 +71,7 @@ export const EditModuleComponent = ({
getTemplateInitialValues,
updateModule,
onUpdateModuleSuccess,
onBackButton,
themeColor,
}: EditModuleProps) => {
const [module, setModule] = useState<module>({
Expand Down Expand Up @@ -335,7 +337,7 @@ export const EditModuleComponent = ({
</Button>{" "}
<Button
htmlType="button"
onClick={() => (window.location.href = "/modules/" + moduleName)}
onClick={() => onBackButton(moduleName)}
disabled={!loadTemplate}
>
Back
Expand Down
1 change: 1 addition & 0 deletions cyclops-ui/src/components/shared/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { ModuleResourceDetails } from "./ModuleResourceDetails";
export { EditModuleComponent } from "./EditModule";
export { CreateModuleComponent } from "./CreateModule";
export { HelmReleaseDetails } from "./HelmReleaseDetails";
1 change: 1 addition & 0 deletions cyclops-ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export {
ModuleResourceDetails,
EditModuleComponent,
HelmReleaseDetails,
CreateModuleComponent,
} from "./components/shared";

0 comments on commit 71ca190

Please sign in to comment.