Comments (12)
Potential solution:
Use the planned Prose component to render native html markup as a child of River, which will also have the restrictions removed.
This would assume that markdown has been pre-processed.
from brand.
@rezrah, do you have any estimates for when the Prose
component will be ready? This is blocking a few work streams we want to complete by the next two weeks.
from brand.
@sergioalvz - sorry for late response. We're drafting the prerequisite issues for Prose this week, eng to begin shortly after. ETA for the component in the published library is just an estimate at this point, but we can expedite release to within the next two weeks.
from brand.
👋 @sergioalvz - quick update for you on this topic following a discussion at Primer Brand maintainer sync on 10th July.
We discussed the trade-offs around increasing responsibility and scope of River.Content, carefully weighing up pro's and cons..
-
Decision was that enabling Prose at this time inside River.Content presents too much of a design pattern risk. For example, Prose supports more elements than River.Content is intended to handle, E.g. multiple paragraphs, multiple headings etc. The unpredictability of the input could lead to unintentionally facilitating anti-patterns.
-
The preferred approach for using Markdown input going forward is as described in an earlier post:
- Parsing the markdown AOT and mapping the relevant parts of the AST to River components like Heading, Text and Link
- The conversion of markdown isn't a responsibility of the library at this time, as we avoid taking heavy third-party dependencies to ensure maximum interop with a wider range of projects. As a result, we would expect the conversion to happen AOT. Happy to jam with you on a few different ways you could do this though! LMK.
-
Re. input from Contentful.. could you create a simple text-only mapping between dedicated heading, description and link to ensure that we only pass in the necessary data to the River.Content layer?
from brand.
Decision was that enabling Prose at this time inside River.Content presents too much of a design pattern risk. For example, Prose supports more elements than River.Content is intended to handle, E.g. multiple paragraphs, multiple headings etc. The unpredictability of the input could lead to unintentionally facilitating anti-patterns.
Heads up: we are currently working on design specs for the River
component were we define that the content should be short and concise (3 or 4 sentences tops), and avoid nested headings or multiple paragraphs as that is not the intended usage for that component.
from brand.
@sergioalvz Quick update on the Prose
component: we have started to work on the API exploration and do some research but unfortunately won't be able to ship within 2 weeks due to scheduled OOO of Primer Brand team.
cc @JoshBowdenConcepts @enstyled @rezrah
from brand.
@waynewi @sergioalvz - quick update that Prose has shipped in 0.20.1.
from brand.
👋 @sergioalvz - Prose can't be used in River.Content
just yet, as that component guards the children types to Heading
, Text
and Link
as you mentioned. Anything besides those children are ignored.
To clarify why that decision was made.. it's to ensure visual consistency of the River pattern across all marketing pages, mitigating situations where we see inconsistently sized (or levelled) headings, or even buttons that end up being used instead of links.
The use-case for Prose is limited to situations where you can't use or map against React components. I.e. you need to dangerouslySetInnerHTML
for editorial text. Even if you could use Prose in the River.Content, you would lose the ability to guardrail presentation, as the CMS could any heading level (should be h3), and the paragraph text won't inherit default styling (slightly larger than the default).
I think we could solve for the use-case in the description in a few different ways:
-
Allow Prose as a valid child of River.Content in Primer Brand, and apply the appropriate styles internally. We can action this, and is also why the issue is still open for us.
-
Use a markdown parser function instead of a React component
I recommend pre-processing the markdown outside of the return statement. Using a library like marked, you can avoid using a React component (which gets ignored) and pass the converted markdown directly to Prose, which requires html input.
import {parse} from 'marked'; parse('hola, this is just a [test](#) description for a River.'); // "<p>hola, this is just a <a href='#'>test</a> description for a River.</p>"
Then pass ☝️ straight into Prose. This helps us to maintain required guardrails around valid types, while adding new, vetted components to the safelist like Prose. It's also more performant, because you can memoise that value now.
-
Extract content in a markup-agnostic way and use Primer Brand components natively
The preferred approach - if possible - would be to extract data from the CMS without additional markup, so that you could pass the raw text directly into typographic components. Is it possible to retrieve this from Contentful using independent fields? The closer we can get to using the recommended API the better 🙏. We'll still look at enabling Prose in River in the interim. cc. @JoshBowdenConcepts @raytalks
from brand.
Thanks for the context, @rezrah!
In the long term, we are heading towards option 3) since Contentful provides a way to directly map RichText content to React elements.
Supporting markdown-generated content inside River
elements would be handy in the short/mid-term since some pages don't benefit from Contentful support yet and are developed without direct access to Primer Brand primitives. Developers use a custom River
component that forwards the content to Primer Brand's River
component. We considered improving the interface for this custom River
component to support rich text formatting by leveraging Markdown. I guess only option 1) would help on that front.
To provide some more context, we created these custom abstractions on top of Primer Brand components to make sure they are easy to connect with Contentful later this year and that the pages created following this approach are easy to migrate as well (because they are constrained to strict limitations in customization and styling).
from brand.
@raytalks and @rezrah Could you please provide an update?
from brand.
@rezrah, great news! Is it possible to use the Prose
component inside other components (for example, inside the River.Content
component)?
from brand.
Thank you, folks, and thank you for your time yesterday. I think we're cool closing this issue and parsing the Markdown AOT. With the latest shift in priorities, we'll connect things to Contentful sooner than we expect, so this becomes less of a problem (I think we won't be leveraging Markdown in the short term, either).
from brand.
Related Issues (20)
- [Accessibility] Visual name and aria-label are different for 'GitHub' control HOT 1
- [Accessibility] Add a "Skip To Content" button to `SubdomainNavBar` HOT 4
- [Accessibility] Improve overflowing of `SubdomainNavBar` on mobile
- Prose: support additional HTML tags HOT 2
- Missing `Animation.module.css` in the build and published artifact HOT 2
- Logo suite with many logos + reduced motion HOT 2
- Add support for directional border to Box
- 🐛 [BUG] - Spacing on River Breakout HOT 3
- [Feature request] Add support for other fonts
- 🐛 [BUG] - FAQ Item click area overlaps with FAQ Anser
- 🐛 [BUG] - InlineLink does not inherit size HOT 7
- [Feature request] Add support for multiple `AnchorNav.Action` HOT 3
- 🐛 [BUG] - `Prose`'s unordered lists do not play well with dark mode
- [Suggestion]: Add documentation around Stack breakpoints
- 🐛 [BUG] - Regression of `leadingVisual` on `TextInput` HOT 1
- 🐛 [BUG] - Button Gap on Medium Size should be 4px (0.25rem) instead of 12px. HOT 5
- [Feature request] Allow `<Label>` in River + Bentos HOT 1
- 🐛 [BUG] - `padding-inline-start` does not set in Timeline.Item component HOT 2
- [Accessibility] `SubdomainNavBar` misses controls when narrow HOT 3
- [Accessibility] `FAQ.Item` is not getting closed using 'ESC' key
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brand.