Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved the issue with the formatting on the description input on the … #237

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions components/blocks/expandable-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export const ExpandableContainer = (props: ExpandableContainerProps) => {
const [height, setHeight] = useState(0)
const ref = useRef()
// Hide the button if the content height is less than
// props.lines, assuming each line has a height of 22
const lineHeight = 22 * props.lines
// props.lines, assuming each line has a height of 20
// plus 16 for the margin-top & margin-bottom (8px each)
const lineHeight = (20 * props.lines + 16 * props.lines)
useLayoutEffect(() => {
if (ref.current) {
const element = ref.current as Element
Expand All @@ -34,15 +35,15 @@ export const ExpandableContainer = (props: ExpandableContainerProps) => {
return (
<Row gutter='xs'>
<Col xs={12}>
<TextContainer
ref={ref}
isExpanded={isExpanded}
{...props}
>
<Text size='sm' weight='light' color='dark-blue'>
<MarkDownViewer content={props.children} />
</Text>
</TextContainer>
<TextContainer
ref={ref}
isExpanded={isExpanded}
{...props}
>
<Text size='sm' weight='light' color='dark-blue'>
<MarkDownViewer content={props.children} />
</Text>
</TextContainer>
</Col>
{height > lineHeight &&
<Col justify='start'>
Expand All @@ -54,24 +55,28 @@ export const ExpandableContainer = (props: ExpandableContainerProps) => {
</Row>
)
}

const getLineClamp = (props: IContainerProps) => {
if (!props.isExpanded && props.lines) {
return props.lines
}
return 'initial'
}

const getMaxHeight = (props: IContainerProps) => {
if (!props.isExpanded && props.maxHeight) {
return props.maxHeight
}
return undefined
}

const getTransition = (props: IContainerProps) => {
if (!props.isExpanded) {
return 'max-height 0.15s ease-out'
}
return 'max-height 0.25s ease-in'
}

const TextContainer = styled.div <IContainerProps>`
margin-bottom: 8px;
display: -webkit-box;
Expand Down
6 changes: 3 additions & 3 deletions components/blocks/mark-down-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import MarkDownIt from 'markdown-it'

export const MarkDownViewer = ({ content }) => {
const wrapperRef = React.useRef(null)
const md = new MarkDownIt()
const html = md.render(content || '')
// const md = new MarkDownIt()
// const html = md.render(content || '')

const handleClickEvent = (event) => {
if (event.target.tagName === 'A') {
Expand All @@ -21,7 +21,7 @@ export const MarkDownViewer = ({ content }) => {
}
}, [])

return (<MarkdownWrapper dangerouslySetInnerHTML={{ __html: html }} ref={wrapperRef}></MarkdownWrapper>)
return (<MarkdownWrapper dangerouslySetInnerHTML={{ __html: content }} ref={wrapperRef}></MarkdownWrapper>)
}

// & p {
Expand Down
5 changes: 3 additions & 2 deletions components/blocks/text-editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export const TextEditor = ({ onChange, content, markdown, deps }: TextEditorProp
content,
onUpdate: function ({ editor }) {
if (markdown) {
onChange(turndownService.current.turndown(editor.getHTML()))
//onChange(turndownService.current.turndown(editor.getHTML()))
onChange(editor.getHTML())
} else {
onChange(sanitizeHtml(editor.getHTML()));
}
Expand All @@ -53,4 +54,4 @@ export const TextEditor = ({ onChange, content, markdown, deps }: TextEditorProp
const TextEditorContentWrapper = styled.div`
border: solid 1px ${({ theme }) => theme.lightBorder};
border-radius: 8px;
`
`
1 change: 1 addition & 0 deletions components/blocks/vote-description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const VoteDescription = () => {
}
</Row>
</Col>

{/* DATE AND SETTINGS CARDS */}
<Col xs={12}>
{/* INSIDE ROW TO ADJUST GUTTER */}
Expand Down