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

feat(article): Add MD support #1451

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Conversation

WaDadidou
Copy link
Collaborator

@WaDadidou WaDadidou commented Dec 9, 2024

Needs, todos, etc => https://hackmd.io/@9Oh5kimjS1SP8xUWU_-Ovg/HkcuBoN4yx

We use this library to generate HTML from Markdown syntax: https://github.com/markdown-it/markdown-it
We use this library to render the HTML into JSX: https://github.com/meliorence/react-native-render-html

MarkdownIt

Here, we initialize MarkdownIt with some parameters, and use the Article message to render HTML: https://github.com/TERITORI/teritori-dapp/blob/feat-feed-article-markdown/packages/screens/FeedNewArticle/components/ArticleContentEditor/ArticleContentEditor.tsx#L53
We use the same MarkdownIt parameters at Article creation and Article consultation (WYSIWYG).

RenderHtml

We pass custom styles to RenderHtml. Each style item correspond to an html tag. So, there are a lot of customisable styles. We could customise the most used only: https://github.com/TERITORI/teritori-dapp/blob/feat-feed-article-markdown/packages/screens/FeedNewArticle/components/ArticleContentEditor/ArticleContentEditor.tsx#L169
Here are the currently customized styles: https://github.com/TERITORI/teritori-dapp/blob/feat-feed-article-markdown/packages/screens/FeedNewArticle/components/ArticleContentEditor/utils.ts#L14-L112

Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for gno-dapp ready!

Name Link
🔨 Latest commit c2b53ba
🔍 Latest deploy log https://app.netlify.com/sites/gno-dapp/deploys/676f14304770bb0008098fed
😎 Deploy Preview https://deploy-preview-1451--gno-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for teritori-dapp ready!

Name Link
🔨 Latest commit c2b53ba
🔍 Latest deploy log https://app.netlify.com/sites/teritori-dapp/deploys/676f1430e72e3e00084c63ba
😎 Deploy Preview https://deploy-preview-1451--teritori-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@WaDadidou WaDadidou force-pushed the feat-feed-article-markdown branch from 12ef521 to 271f701 Compare December 12, 2024 00:53
@WaDadidou WaDadidou changed the title wip(article): Add MD support feat(article): Add MD support Dec 12, 2024
@WaDadidou WaDadidou marked this pull request as ready for review December 12, 2024 00:54
@WaDadidou WaDadidou force-pushed the feat-feed-article-markdown branch from 2bb197f to a8cab39 Compare December 12, 2024 01:34
@WaDadidou WaDadidou force-pushed the feat-feed-article-markdown branch from a8cab39 to 6408c7a Compare December 12, 2024 01:50
@clegirar
Copy link
Collaborator

In term of UI what do you think about show borders for the editor and the preview ?

return (
<ScreenContainer
forceNetworkFeatures={[forceNetworkFeature]}
responsive
mobileTitle="NEW ARTICLE"
fullWidth
headerChildren={<ScreenTitle>New Article</ScreenTitle>}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep ScreenTitle to be consistent with the new title UI

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9c4bf23
Thx for this new component btw ^^

control={control}
rules={{
required: true,
<TextInputCustom<NewArticleFormValues>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid at maximum custom components, if it's not possible nevermind but we should trying to be consistent imo

Copy link
Collaborator Author

@WaDadidou WaDadidou Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree. I think it's better to have our custom versions of RN components, to centralize styles and logics.
(Especially with forms)
Just for this example, it's heavy to re-handle <Label/>, onHover, form control, all the feedbacks, in many components, it's better to factorize.
Maybe the term "custom" is not good ? How to name our Teritori components ?
But TextInputCustom needs some refacto, it's a mess...

@clegirar
Copy link
Collaborator

In term of behvior found that enough for a first version and we can iterate on add styles just after.
Cool to see this first version 🙂

@MikaelVallenet
Copy link
Member

Would be nice to highlight the selected mode

image

@MikaelVallenet
Copy link
Member

it would also be nice (in another PR since it's not the scope) but to use the start of the article to make a preview subtitle and let it optional to write a custom preview, if you agree i will open a new issue

@WaDadidou
Copy link
Collaborator Author

WaDadidou commented Dec 16, 2024

@clegirar

In term of UI what do you think about show borders for the editor and the preview ?

If you talk about the white borders, it's the same behavior than on other inputs.

image

I try to put this behavior on each input, I love this UI that highlights interactive elements on hover such as inputs or buttons.. In mobile format, I removed the white borders padding, because there is no hover.

If to talk about a separation between preview and edition, why not adding one, yes :) Personnaly I prefer pure without separation, it's enough excplicit

@WaDadidou
Copy link
Collaborator Author

WaDadidou commented Dec 16, 2024

image

Would be nice to highlight the selected mode

@MikaelVallenet @clegirar

These are draft buttons, I'm looking for better buttons, an other style for these buttons, maybe with icons, something cute.
I'll restyle these buttons

packages/utils/feed/markdown.ts Outdated Show resolved Hide resolved
@MikaelVallenet
Copy link
Member

MikaelVallenet commented Dec 17, 2024

@clegirar

In term of UI what do you think about show borders for the editor and the preview ?

If you talk about the white borders, it's the same behavior than on other inputs.

image

I try to put this behavior on each input, I love this UI that highlights interactive elements on hover such as inputs or buttons.. In mobile format, I removed the white borders padding, because there is no hover.

If to talk about a separation between preview and edition, why not adding one, yes :) Personnaly I prefer pure without separation, it's enough excplicit

i think we mean don't just show the border on hover and only when hover but always show a border, the border could become fully white on hover and be gray when not hover but for now when you don't hover the input, the input is mix with background making it impossible to know what is the border of the input

@clegirar
Copy link
Collaborator

I don't have final opinion on border, in fact you can do as you want, i think it can be discuss later because it could be nice to merge it asap 👍

windowWidth < RESPONSIVE_BREAKPOINT_S ? 0 : SOCIAl_CARD_BORDER_RADIUS;

const metadata = zodTryParseJSON(
ZodSocialFeedArticleMetadata,
Copy link
Collaborator

@n0izn0iz n0izn0iz Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't reuse the old type for the new article kind IMO
so create a new schema ZodSocialFeedArticleMarkdownMetadata

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but we didn't discuss about the new shape. I don't want to commit, then fix the review, then commit, then fix the review, etc. We need to status on that once

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, can you duplicate the schema for now please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WaDadidou
Copy link
Collaborator Author

it would also be nice (in another PR since it's not the scope) but to use the start of the article to make a preview subtitle and let it optional to write a custom preview, if you agree i will open a new issue

@MikaelVallenet , it was an idea at start: Using the first image as "cover image", the first h1 as title and first text under h1 as subtitle. We don't have "cover image" anymore since the user can just add an image before the h1 with markdown.

The "automatic title and subtitle" was not good with the old Article version.

We should put the preview after the content writting. It needs another PR maybe

@WaDadidou
Copy link
Collaborator Author

WaDadidou commented Dec 18, 2024

@clegirar @MikaelVallenet

i think we mean don't just show the border on hover and only when hover but always show a border, the border could become fully white on hover and be gray when not hover but for now when you don't hover the input, the input is mix with background making it impossible to know what is the border of the input

Ok I see, letting the input borders always visible as other inputs. I would like to let it epurated, I have some arguments, but it's better to debate in vocal IMO.
I show the border to have the same style than other inputs
1eff178#diff-a5f2107cc7dca5518dcf10f5760a01297a4f825a471c8d11a0102e6c944c39f0R118

@WaDadidou
Copy link
Collaborator Author

WaDadidou commented Dec 18, 2024

@MikaelVallenet
I made that. With hovered style and selected style
image

I reused these boxes to harmoinze visually, we could change, etc
image

9c42f45#diff-33ab4e16a7693f5368d5ec3b64f8b8b182598fc5b91135abcc0c228bbeac6f69R1-R74

@WaDadidou WaDadidou added enhancement New feature or request UX/UI Social Feed Everything related to the Social Feed labels Dec 23, 2024
@@ -123,6 +123,8 @@ const gradient = (type: GradientType): LinearGradientProps => {
return getMapPostTextGradient(PostCategory.Normal);
case getMapPostTextGradientType(PostCategory.Article):
return getMapPostTextGradient(PostCategory.Article);
case getMapPostTextGradientType(PostCategory.ArticleMarkdown):
return getMapPostTextGradient(PostCategory.Article);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this on purpose ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Social Feed Everything related to the Social Feed UX/UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants