Allow new props for Ordered/Unordered List components #4300
-
Hi team! Awhile ago we got a request from the Flex team to follow Google's docs standards for sublists and render nested ordered lists using a cycling rotation of list style types (numeric, alphabetical, roman numerals, back to numeric, etc). This isn't possible with Paste out of the box (as far as we can tell) because the import * as React from 'react';
import { OrderedListProps, List } from '@twilio-paste/core/list';
import { safelySpreadTextProps } from '@twilio-paste/core/text';
import { ListStyleType } from '@twilio-paste/core/style-props';
const listStyleMap: Record<NonNullable<OrderedListProps['type']>, ListStyleType> = {
1: 'decimal',
a: 'lower-alpha',
A: 'upper-alpha',
i: 'lower-roman',
I: 'upper-roman',
};
export const OrderedList = React.forwardRef<HTMLOListElement, OrderedListProps>(
({ children, element = 'ORDERED_LIST', marginTop, marginBottom = 'space70', type = '1', ...props }, ref) => {
return (
<List
{...safelySpreadTextProps(props)}
as="ol"
element={element}
marginTop={marginTop}
marginBottom={marginBottom}
listStyleType={listStyleMap[type]}
type={type}
ref={ref}
>
{children}
</List>
);
},
); Recently we got yet another request, this time to render circles instead of solid discs in nested unordered lists. As you can guess, the blocker here from using Paste's component directly is the decision to hardcode Now, we could certainly build yet another custom component that is a copy-paste of
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Disclaimer: This is a very experimental bot using OpenAI's GPT-4. The answers may not be correct, a human will review the answer and update it if necessary. Hi there! It sounds like you've encountered a common challenge when trying to extend the functionality of design system components to meet specific product needs. Your approach to creating a custom Regarding your questions:
In summary, your proactive approach to solving these challenges is admirable, and reaching out to the Paste team for discussion and potential contribution could lead to beneficial outcomes for both your team and the broader Paste community. I also did a search, and I managed to find these other Discussions that might be similar or related to your question. Give them a read to see if they answer your question. If they do, head back here and update this discussion and mark it as answered, pointing others to the related discussion:
|
Beta Was this translation helpful? Give feedback.
-
Hi @stern-shawn I see from you description you have explored the With this component you can set the Will this work for your use case or is there something this will not provide that the other components would? |
Beta Was this translation helpful? Give feedback.
-
Hey @stern-shawn! Checking back in here - did Kris's suggestions help you figure out a path forward? If there's anything else we can discuss here, let us know, otherwise I'll mark this discussion as answered. Thanks! |
Beta Was this translation helpful? Give feedback.
Hey @stern-shawn, more background we added this change because of this issue in flex. they are building using the
OrderedList
andUnorderedList
components though so removing default inList
shouldn't break anything (it's not even in our docs, hopefully no one uses it).We decided it's ok to remove it our end and you should be able to pass anything you like to it. The types are messed up because it's inheriting from one of our foundational libs but I've added the link to the list in the JSDoc so you should get it in the tooltip.
Here is a link to the PR. It will get merged soon and be included as part of the next release scheduled for 2025.05.27. We haven't included docs in this as we'd ne…