-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f31f4d1
commit 25dc302
Showing
32 changed files
with
749 additions
and
630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/builder/components/editor/sections/text/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { | ||
HStack, | ||
Icon, | ||
Tab, | ||
TabList, | ||
TabPanel, | ||
TabPanels, | ||
Tabs, | ||
Text, | ||
} from "@chakra-ui/react"; | ||
import TextSectionEditorColorsPanel from "components/editor/sections/text/panels/colors"; | ||
import TextSectionEditorTextPanel from "components/editor/sections/text/panels/text"; | ||
import DeleteSectionButton from "components/pages/index/right-sidebar/delete-section-button"; | ||
import React, { FC } from "react"; | ||
import { MdColorLens, MdSettings, MdTextFields } from "react-icons/md"; | ||
|
||
interface IProps { | ||
positionOfSection: number; | ||
} | ||
|
||
const TextSectionEditor: FC<IProps> = ({ positionOfSection }) => { | ||
return ( | ||
<Tabs isLazy> | ||
<TabList> | ||
<Tab> | ||
<HStack spacing={1}> | ||
<Icon as={MdTextFields} /> | ||
<Text>Text</Text> | ||
</HStack> | ||
</Tab> | ||
<Tab> | ||
<HStack spacing={1}> | ||
<Icon as={MdColorLens} /> | ||
<Text>Colors</Text> | ||
</HStack> | ||
</Tab> | ||
<Tab> | ||
<HStack spacing={1}> | ||
<Icon as={MdSettings} /> | ||
<Text>Settings</Text> | ||
</HStack> | ||
</Tab> | ||
</TabList> | ||
<TabPanels> | ||
<TabPanel> | ||
<TextSectionEditorTextPanel positionOfSection={positionOfSection} /> | ||
</TabPanel> | ||
<TabPanel> | ||
<TextSectionEditorColorsPanel positionOfSection={positionOfSection} /> | ||
</TabPanel> | ||
<TabPanel> | ||
<DeleteSectionButton positionOfSection={positionOfSection} /> | ||
</TabPanel> | ||
</TabPanels> | ||
</Tabs> | ||
); | ||
}; | ||
|
||
export default TextSectionEditor; |
50 changes: 50 additions & 0 deletions
50
packages/builder/components/editor/sections/text/panels/colors.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { FormControl, FormLabel, VStack } from "@chakra-ui/react"; | ||
import ColorPicker from "components/color-picker"; | ||
import React, { FC } from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { getCurrentPageData, getSectionData } from "selectors/site"; | ||
import { updateTemplateSectionTheme } from "slices/site"; | ||
|
||
interface IProps { | ||
positionOfSection: number; | ||
} | ||
|
||
const TextSectionEditorColorsPanel: FC<IProps> = ({ positionOfSection }) => { | ||
const dispatch = useDispatch(); | ||
const currentPageId = useSelector(getCurrentPageData()); | ||
const { theme } = useSelector( | ||
getSectionData(currentPageId, positionOfSection) | ||
); | ||
|
||
const handleChange = (itemType: string, value: string) => { | ||
dispatch( | ||
updateTemplateSectionTheme({ | ||
currentPageId, | ||
positionOfSection, | ||
key: itemType, | ||
value, | ||
}) | ||
); | ||
}; | ||
|
||
return ( | ||
<VStack spacing={4} align="stretch"> | ||
<FormControl> | ||
<FormLabel>Background</FormLabel> | ||
<ColorPicker | ||
color={theme.backgroundColor} | ||
onChange={(color: string) => handleChange("backgroundColor", color)} | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<FormLabel>Link</FormLabel> | ||
<ColorPicker | ||
color={theme.linkColor} | ||
onChange={(color: string) => handleChange("linkColor", color)} | ||
/> | ||
</FormControl> | ||
</VStack> | ||
); | ||
}; | ||
|
||
export default TextSectionEditorColorsPanel; |
77 changes: 77 additions & 0 deletions
77
packages/builder/components/editor/sections/text/panels/text.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { FormControl, FormLabel, Input, VStack } from "@chakra-ui/react"; | ||
import React, { ChangeEvent, FC } from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { getCurrentPageData, getSectionData } from "selectors/site"; | ||
import { | ||
updateTemplateSectionData, | ||
updateTemplateSectionMeta, | ||
} from "slices/site"; | ||
|
||
interface IProps { | ||
positionOfSection: number; | ||
} | ||
|
||
const TextSectionEditorTextPanel: FC<IProps> = ({ positionOfSection }) => { | ||
const dispatch = useDispatch(); | ||
const currentPageId = useSelector(getCurrentPageData()); | ||
const { meta } = useSelector( | ||
getSectionData(currentPageId, positionOfSection) | ||
); | ||
|
||
const handleMetaChange = (itemType: string, value: string) => { | ||
dispatch( | ||
updateTemplateSectionMeta({ | ||
currentPageId, | ||
positionOfSection, | ||
itemType, | ||
value, | ||
}) | ||
); | ||
}; | ||
|
||
const handleDataChange = ( | ||
itemPosition: number, | ||
itemType: string, | ||
value: string | ||
) => { | ||
dispatch( | ||
updateTemplateSectionData({ | ||
currentPageId, | ||
positionOfSection, | ||
itemType: "buttons", | ||
itemPosition, | ||
key: itemType, | ||
value, | ||
}) | ||
); | ||
}; | ||
|
||
return ( | ||
<VStack spacing={4} align="stretch"> | ||
<FormControl> | ||
<FormLabel>Heading</FormLabel> | ||
<Input | ||
size="sm" | ||
rounded="lg" | ||
value={meta.heading} | ||
onChange={(e: ChangeEvent<HTMLInputElement>) => | ||
handleMetaChange("heading", e.currentTarget.value) | ||
} | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<FormLabel>Sub heading</FormLabel> | ||
<Input | ||
size="sm" | ||
rounded="lg" | ||
value={meta.subHeading} | ||
onChange={(e: ChangeEvent<HTMLInputElement>) => | ||
handleMetaChange("subHeading", e.currentTarget.value) | ||
} | ||
/> | ||
</FormControl> | ||
</VStack> | ||
); | ||
}; | ||
|
||
export default TextSectionEditorTextPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
25dc302
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: