Skip to content

Commit

Permalink
Merge pull request #321 from GTBitsOfGood/component/text
Browse files Browse the repository at this point in the history
Component/text
  • Loading branch information
thanasis457 authored Nov 3, 2024
2 parents 6179d75 + 37ea6bb commit 19c265f
Show file tree
Hide file tree
Showing 19 changed files with 1,687 additions and 196 deletions.
37 changes: 29 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,34 @@
"@reactour/tour": "^3.3.0",
"@sentry/react": "^5.19.1",
"@slack/client": "^5.0.2",
"@tiptap/extension-bullet-list": "^2.8.0",
"@tiptap/core": "^2.9.1",
"@tiptap/extension-blockquote": "^2.9.1",
"@tiptap/extension-bold": "^2.9.1",
"@tiptap/extension-bullet-list": "^2.9.1",
"@tiptap/extension-code": "^2.9.1",
"@tiptap/extension-color": "^2.8.0",
"@tiptap/extension-image": "^2.8.0",
"@tiptap/extension-link": "^2.8.0",
"@tiptap/extension-list-item": "^2.8.0",
"@tiptap/extension-ordered-list": "^2.8.0",
"@tiptap/extension-document": "^2.9.1",
"@tiptap/extension-heading": "^2.9.1",
"@tiptap/extension-highlight": "^2.9.1",
"@tiptap/extension-history": "^2.9.1",
"@tiptap/extension-horizontal-rule": "^2.9.1",
"@tiptap/extension-image": "^2.9.1",
"@tiptap/extension-italic": "^2.9.1",
"@tiptap/extension-link": "^2.9.1",
"@tiptap/extension-list-item": "^2.9.1",
"@tiptap/extension-ordered-list": "^2.9.1",
"@tiptap/extension-paragraph": "^2.9.1",
"@tiptap/extension-strike": "^2.9.1",
"@tiptap/extension-subscript": "^2.9.1",
"@tiptap/extension-superscript": "^2.9.1",
"@tiptap/extension-task-item": "^2.9.1",
"@tiptap/extension-task-list": "^2.9.1",
"@tiptap/extension-text": "^2.9.1",
"@tiptap/extension-text-align": "^2.9.1",
"@tiptap/extension-text-style": "^2.8.0",
"@tiptap/extension-underline": "^2.8.0",
"@tiptap/react": "^2.8.0",
"@tiptap/starter-kit": "^2.8.0",
"@tiptap/extension-underline": "^2.9.1",
"@tiptap/react": "^2.9.1",
"@tiptap/starter-kit": "^2.9.1",
"@types/react": "^17.0.30",
"@types/react-modal": "^3.16.3",
"autoprefixer": "9.8.0",
Expand Down Expand Up @@ -106,6 +124,9 @@
"redux-freeze": "^0.1.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"tiptap-extension-resize-image": "^1.1.9",
"tiptap-imagresize": "^1.1.0",
"tiptap-resize-image": "^2.0.1",
"typescript": "^4.0.2",
"url-loader": "^4.0.0",
"uuid": "^7.0.3",
Expand Down
6 changes: 6 additions & 0 deletions src/assets/svg/blockquote.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/components/dashboard/AddProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { storage } from "../../store";
import { Store } from "reducers/types";
const { v4: uuidv4 } = require("uuid");

import { SimpleEditor } from "./TextComponent/SimpleEditor";

let steps = [
"Map",
"Hours",
Expand Down
16 changes: 16 additions & 0 deletions src/components/dashboard/ContentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ChartComponentForm from "components/subcomponents/chartcomponents/ChartCo
import Collapsible from "components/collapsible";
import ProviderGallery from "./ProviderGallery";
import EmbedForm from "./embed-component/EmbedForm";
import { SimpleEditor } from "./TextComponent/SimpleEditor";

const EditableText = ({ text, setText, isEditing, setIsEditing }) => {
const inputRef = useRef(null);
Expand Down Expand Up @@ -223,6 +224,21 @@ const SectionCard = ({
<EmbedForm/>
</Collapsible>
])}>Embed</Dropdown.Item>
<Dropdown.Item onClick={() =>
setComponents([...components,
<Collapsible
style={{ width: "100%" }}
titleStyle={{
background: "white",
color: "var(--chart-blue)",
fontSize: "1.25rem",
fontStyle: "normal",
lineHeight: "24px"
}}
label={"Text"}>
<SimpleEditor />
</Collapsible>
])}>Text</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Row>
Expand Down
18 changes: 18 additions & 0 deletions src/components/dashboard/EventInfoComponent.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.event-info-container {
border-radius: 8px;
padding: 16px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
}

.event-description {
font-family: Arial, sans-serif;
font-size: 16px;
color: #7f8c8d;
line-height: 1.6;
margin-bottom: 12px;
}


15 changes: 15 additions & 0 deletions src/components/dashboard/EventInfoComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import './EventInfoComponent.css';
import Collapsible from 'components/collapsible';

interface EventInfoComponentProps {
description: string;
}

const EventInfoComponent: React.FC<EventInfoComponentProps> = ({ description }) => {
return (
<p className="event-description">{description}</p>
);
};

export default EventInfoComponent;
1 change: 0 additions & 1 deletion src/components/dashboard/RowForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import GoogleSuggest from "./GoogleSuggest";
import ImageModal from "./ImageModal";
import Modal from "react-bootstrap/Modal";
import Button from "react-bootstrap/Button";

import ActionForm from "./ActionForm";
import ContentForm from "./ContentForm";

Expand Down
94 changes: 94 additions & 0 deletions src/components/dashboard/TextComponent/CustomDropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import React, { useState } from "react";
import * as Icons from "./Icons";

interface CustomDropdownProps {
onChange: (value: string) => void;
options: { label: string; value: string; icon?: React.ReactNode }[];
defaultValue: string;
labelType?: "icon" | "text";
}

const CustomDropdown: React.FC<CustomDropdownProps> = ({ onChange, options, defaultValue, labelType = "text" }) => {
const [isOpen, setIsOpen] = useState(false);
const [selectedOption, setSelectedOption] = useState(
options.find((option) => option.value === defaultValue) || options[0]
);

const handleOptionClick = (option: { label: string; value: string }) => {
setSelectedOption(option);
onChange(option.value);
setIsOpen(false);
};

return (
<div style={{ position: "relative", display: "inline-block"}}>
<div
onClick={() => setIsOpen(!isOpen)}
style={{
display: "flex",
alignItems: "center",
cursor: "pointer",
padding: "4px 8px",
color: "black",
fontSize: "14px",
overflow: "scroll"
}}
>
{labelType === "icon" && selectedOption.icon ? (
<>
{selectedOption.icon}
<span style={{ marginLeft: "6px", display: "flex", alignItems: "center" }}>
<Icons.DropdownArrow />
</span>
</>
) : (
<>
<span>{selectedOption.label}</span>
<span style={{ marginLeft: "6px", display: "flex", alignItems: "center" }}>
<Icons.DropdownArrow />
</span>
</>
)}
</div>
{isOpen && (
<div
style={{
overflow: "scroll",
position: "absolute",
top: "100%",
left: 0,
marginTop: "4px",
padding: "4px",
backgroundColor: "var(--color-white)",
border: "1px solid var(--color-gray-4)",
borderRadius: "4px",
zIndex: 1,
display: "flex",
flexDirection: labelType === "icon" ? "row" : "column",
gap: "4px",
}}
>
{options.map((option) => (
<button
key={option.value}
onClick={() => handleOptionClick(option)}
style={{
cursor: "pointer",
color: "black",
display: "flex",
alignItems: "center",
padding: "8px",
background: "none",
border: "none",
}}
>
{option.icon ? option.icon : option.label}
</button>
))}
</div>
)}
</div>
);
};

export default CustomDropdown;
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,106 @@ export const X = ({ size = 16, color = "currentColor" }) => (
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
);

export const DropdownArrow = () => (
<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fillRule="evenodd" clipRule="evenodd" d="M12.7803 6.71967C13.0732 7.01256 13.0732 7.48744 12.7803 7.78033L8.53033 12.0303C8.23744 12.3232 7.76256 12.3232 7.46967 12.0303L3.21967 7.78033C2.92678 7.48744 2.92678 7.01256 3.21967 6.71967C3.51256 6.42678 3.98744 6.42678 4.28033 6.71967L8 10.4393L11.7197 6.71967C12.0126 6.42678 12.4874 6.42678 12.7803 6.71967Z" fill="#333333"/>
</svg>
);

export const TextIcon = () => (
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 5h18v2H3V5zm4 4h10v2H7V9zm0 4h10v2H7v-2zm0 4h10v2H7v-2z" fill="#333333"/>
</svg>
);

export const AlignLeftIcon = () => (
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 5h18v2H3V5zm0 4h12v2H3V9zm0 4h18v2H3v-2zm0 4h12v2H3v-2z" fill="#333333"/>
</svg>
);

export const AlignCenterIcon = () => (
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 5h18v2H3V5zm3 4h12v2H6V9zm-3 4h18v2H3v-2zm3 4h12v2H6v-2z" fill="#333333"/>
</svg>
);

export const AlignRightIcon = () => (
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 5h18v2H3V5zm6 4h12v2H9V9zm-6 4h18v2H3v-2zm6 4h12v2H9v-2z" fill="#333333"/>
</svg>
);

export const JustifyIcon = () => (
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 5h18v2H3V5zm0 4h18v2H3V9zm0 4h18v2H3v-2zm0 4h18v2H3v-2z" fill="#333333"/>
</svg>
);

export const BulletListIcon = ({ size = 16, color = "currentColor" }) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
stroke={color}
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<circle cx="3" cy="6" r="1" />
<circle cx="3" cy="18" r="1" />
<line x1="8" y1="6" x2="21" y2="6" />
<line x1="8" y1="18" x2="21" y2="18" />
</svg>
);

export const NumberedListIcon = ({ size = 16, color = "currentColor" }) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
stroke={color}
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<line x1="8" y1="6" x2="21" y2="6" />
<line x1="8" y1="18" x2="21" y2="18" />

<text x="1" y="8" fontSize="8" fill={color} fontFamily="Arial">1</text>
<text x="1" y="20" fontSize="8" fill={color} fontFamily="Arial">2</text>
</svg>
);

export const ImageIcon = ({ size = 16, color = "currentColor" }) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
stroke={color}
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
{/* Frame of the image */}
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
{/* Circle inside the image to represent an object */}
<circle cx="8.5" cy="8.5" r="1.5"></circle>
{/* Line representing a mountain or shape */}
<path d="M21 15l-5-5L5 21"></path>
</svg>
);







46 changes: 46 additions & 0 deletions src/components/dashboard/TextComponent/LinkModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from "react";
import ReactModal from "react-modal";
import * as Icons from "../TextComponent/Icons";
import { Modal } from "../TextComponent/Modal";


interface IProps extends ReactModal.Props {
url: string;
closeModal: () => void;
onChangeUrl: (e: React.ChangeEvent<HTMLInputElement>) => void;
onSaveLink: (e: React.MouseEvent<HTMLButtonElement>) => void;
onRemoveLink: (e: React.MouseEvent<HTMLButtonElement>) => void;
}

export function LinkModal(props: IProps) {
const {
url,
closeModal,
onChangeUrl,
onSaveLink,
onRemoveLink,
...rest
} = props;
return (
<Modal {...rest}>
<h2 className="modal-title">Edit link</h2>
<button className="modal-close" type="button" onClick={closeModal}>
<Icons.X />
</button>
<input
className="modal-input"
autoFocus
value={url}
onChange={onChangeUrl}
/>
<div className="modal-buttons">
<button className="button-remove" type="button" onClick={onRemoveLink}>
Remove
</button>
<button className="button-save" type="button" onClick={onSaveLink}>
Save
</button>
</div>
</Modal>
);
}
Loading

0 comments on commit 19c265f

Please sign in to comment.