mia-platform / design-system Goto Github PK
View Code? Open in Web Editor NEWReact graphical components designed by Mia Platform
Home Page: https://mia-platform.github.io/design-system/
License: Apache License 2.0
React graphical components designed by Mia Platform
Home Page: https://mia-platform.github.io/design-system/
License: Apache License 2.0
Add a Collapse component.
Add a component offering functionalities similar to Antd's Collapse: https://ant.design/components/collapse.
We need a Collapse component able to hide its children based on an activeKey
, with an option for having no border and background color.
Move components prop definitions to separate files
It would help with organization to have separate files for prop definitions, in order not to clutter component implementation files.
In order to keep the default pagination the table now requires to pass
pagination={...Table.pagination, ...customPartialPagination}
while it would be better to just pass
pagination={customPartialPagination}
Easier developer experience in using the Table component
Current link is pointing to "font size" section;
correct link could be: https://developer.mozilla.org/en-US/docs/Web/CSS/font-style
Improve Table placeholder
The table placeholder when loading does not fit the shape of the table and hides all parts of the table.
The ideal result would be a placeholder that performs optimistic updates on the fixed parts of the table (pagination, header...) and shows a loader only on the table content
Unit test (with jest
and @testing-library/react
) on components that renders the Table component might fail because of the following error:
Hooks cannot be defined inside tests. Hook of type "afterAll" is nested within "...".
1 | import {useMemo} from 'react'
> 2 | import {Table} from '@mia-platform-internal/console-design-system-react'
| ^
4 |
at eventHandler (../../node_modules/react-scripts/node_modules/jest-circus/build/eventHandler.js:105:11)
at Module.Object.<anonymous> (../../node_modules/@mia-platform-internal/console-design-system-react/dist/cjs/console-design-system-react.cjs:119:4403)
at Object.<anonymous> (src/pages/Services/components/ServiceSidecars.jsx:3:73)
at Object.<anonymous> (src/pages/Services/Detail.jsx:33:59)
at Object.<anonymous> (src/containers/Services/ServiceDetail.jsx:49:60)
at Object.<anonymous> (src/containers/Services/index.jsx:10:44)
at src/containers/Design/Config/index.jsx:134:40
Weird enough, not all the tests returns this error but just one in a component that renders the Table as one of its children. It actually passes all the asserts, but returns this error nonetheless.
To solve this issue, I need to add the following import on the *.test.jsx
file:
import { testUtils } from '@mia-platform-internal/console-design-system-react'
I assume because it imports the entire @testing-library/react. But I wish there was a way to avoid unnecessary imports.
Add the possibility to proxy className
prop in each component
Pass className
to a component
For example, in the icon could be necessary to change the color depending on the hover state of the mouse. Despite it is possible with react, it is much more comfortable to address it using CSS
What do you think about?
After upgrading to v0.1.16, some snapshots were updated due to random ids changing inside classnames
Snapshots remain unchanged after upgrading to the newest DS version. Random ids inside class names might be a problem
Design system version: 0.1.16
If the color
prop is not set for an Icon, the default should be currentColor
It might be helpful to have the currentColor
as the default value so that icons inside buttons, menu items etc. automatically inherit the color based on the context in which they are placed.
design system version: 0.1.18
Build Storybook and run the command storybook-test
whenever a merge request is submitted, ensuring components are built correctly and rendered as expected.
Currently, components might be rendered incorrectly when updating dependencies.
We can improve the spacing and overall balance of the feedback message: for example, we could increase the padding, the gap between the icon and the text, as well as the distance of the message from the top of the page.
Improved look
While using the Design System to migrate part of the UI in our application, we noticed that sometimes we use the data-testid
attribute for testing purposes. However, the components in the DS does not expect this attribute, therefore we have to change our tests as well.
Do you think that the data-testid
attribute will be included in the components?
If I've a button component like the following:
<Button data-testid={'my-button-cancel'} onClick={onCancel} />
and a test (with Jest and React Testing Library) with this instruction:
userEvent.click(screen.getByTestId('my-button-cancel'))
The test will fail since the button won't have the data-testid
atrtribute.
For the Button
component, as example:
export const Button = ({
"data-testid": dataTestid,
...
}: ButtonProps): ReactElement => {
...
return (
<AntButton
...
data-testid={dataTestid}
...
/>
)
}
node: v20.11.1
os: Ubuntu 22.04
useFeedbackMessage supports afterClose
In antd's message hook, it is possible to have an afterClose
method, to be called after the message is closed, in a thenable interface, like this:
message[level](content, [duration]).then(afterClose)
This behaviour should be kept in the useFeedbackMessage
hook as well.
success({
key: 'some key',
message: 'some message',
duration: 1
}).then(() =>{...})
The resulting error is: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'then')
afterClose
can be called in thenable interface, e.g.
success(...).then(afterClose)
As a side note, in antd there is also an onClose
parameter that can be passed to specify a function that will be called when the message is closed. Maybe that could be added as well
Design system version: 0.1.15
Currently, the repository includes Lodash specific packages, while it would be easier to use only Lodash bundled with es modules:
https://www.npmjs.com/package/lodash-es
Current link is pointing to "font size" section;
correct link could be: https://developer.mozilla.org/en-US/docs/Web/CSS/font-style
We should exclude from the bundle the following files:
Lowering the bundle size by excluding unnecessary files
Insertion of horizontal padding for cards in the loading state.
When cards are in loading state, they have no horizontal padding between the skeleton and the edge of the card itself:
The cards have, even in the loading state, a horizontal padding of 24px.
node: v18.19.0
os: Ubuntu 22.04.3 LTS, 64-bit
Add the ability to customize colors for text, both in Card and Typography components as well as in external components using theme tokens.
Fix Card component text colors. Allow new components to specify different colors for their embedded text.
var(--palette-text-primary-main)
and
const {palette} = useTheme()
const color = palette?.text?.primary?.main
Creation of a Breadcrumb
component to ease navigation.
It would be nice to introduce an UI component to allow users to navigate between sections. This component should not be necessarily associated with the react-dom-router
or represent a routing, but it could be also used to navigate inside a sub-section (e.g. inside a modal or a drawer).
The expected Breadcrumb
component should have as input only an items
property, which will contain a list of breadcrumb items to be displayed. The component should have the following props:
type BreadcrumbProps = {
items: BreadcrumbItemType[]
}
Each specific item should be of type BreadcrumbItemType
, structured this way
type BreadcrumbItemType = {
icon?: ReactNode
key?: string
label?: ReactNode
menu?: BreadcrumbItemMenu
onClick?: (event: React.MouseEvent<Element, MouseEvent>) => void
}
If at least one of the icon
, label
or menu
props are not undefined and contain a valid value, the component should display the associated value. If unspecified, the key
property is set at the items
index. If more than one item is present, the items should be displayed and divided by a fixed separator (>
). As visible inside the type, each item contains an onClick
prop to allow users to define the expected behavior to be executed when clicking.
If the item contains a valid menu
value, the component should display an element containing a dropdown icon. If not specified otherwise, clicking this icon will open a dropdown, which will display the menu elements, if present, and a search bar, if specified.
The menu type should look like this:
type BreadcrumbItemMenu = {
activeKey?: string
items?: BreadcrumbItemMenuItem[]
onDropdownVisibleChange?: (open: boolean) => void
onSearch?: OnSearch
open?: boolean
searchAllowClear?: boolean
searchPlaceholder?: string
showSearch?: boolean
}
The showSearch
, searchPlaceholder
, searchAllowClear
and onSearch
props will give freedom to the user to specify if and how the search function should work. The open
and onDropdownVisibleChange
props allow to specify the dropdown behavior. If not specified, the internal state will be used to open and close the dropdown when clicking on the dropdown icon. The activeKey
prop will be used to specify if one of the sub-items has already been selected. If so, its label
will be displayed as the label of the parent BreadcrumbItem
component, otherwise, the parent label
will be displayed, if present. The items
prop should contain a list of element with the following structure:
type BreadcrumbItemMenuItem = {
icon?: ReactNode
key?: string
onClick?: (event: React.MouseEvent<Element, MouseEvent>) => void
label: string
}
As for the previous type, if the key is unspecified, the items
index will be used as key. Here as well the onClick
property of each sub-item is left to be handled by a custom function.
Issue based on the comment below
I'd map this prop to the isClosable flag.
Originally posted by @fredmaggiowski in #334 (comment)
Closing modals by clicking outside of it is a basic feature that provides ease-of-use for most of the modals we use. I understand some modals shouldn't be closable that easy but I'd not limit UX to have to click the X in the header (or the close button).
I'd consider rethinking this design choice.
design-system/src/components/Modal/Modal.tsx
Lines 65 to 75 in 5c46f2b
The modal component have three different sizes: small
, large
and fullscreen
. Since it doesn't use dynamic height, we might run in cases where we would need an intermediate size to work with to have enough space to include the content properly.
The feature would include a size medium
, where the width would be the 50-55% of the viewport and height would be reasonably the 60-65% of the viewport.
Improvement of alignment inside table columns
When using the align
property on table columns, it sets the text-align
CSS property value, which sets the horizontal alignment of the inline-level content inside a block element or table-cell box. This means that non-inline elements (e.g. divs) do not get aligned correctly.
The table cell could support a wrapper or something similar that makes its content "inline-block"
Design system version: 0.1.13
If I need to use this button as submit button of a form, it's needed to set the html type attribute to submit
and form attribute to the id of the form.
So, it would be something like:
<Button htmlType="submit" htmlForm="my-form-id">{"something"}</Button>
Add a Getting Started page, that can be read from Storybook and from the repository to understand the basic concepts behind:
Allow new users to understand how to properly use Design System components
Add a Divider component.
Add a component offering functionalities similar to Antd's Divider: https://ant.design/components/divider.
For now, we need a basic divider, but most of the Antd interface could be implemented:
{
className: string
dashed: boolean
orientation: 'left' | 'right' | 'center'
orientationMargin: string | number
plain: boolean
type: 'horizontal' | 'vertical'
}
It is currently impossible to use the table with data fetched asynchronously and pagination without explicitly set pagination.current
and keep track of it in the component using it.
With such configuration, when I change page I correctly get the page change callback, I properly download data and provide it back to the table which re-renders but sets pagination based to the defaultCurrent (so 1
) which is meant to be read only on mount, the final user of this design system is not remounting the Table, therefore this should be addressed in some way.
const MyComponent = ({...}) => {
...
const onChangePage = useCallback((page) => requestGet(`?page=${page}&per_page=${DEFAULT_PAGE_SIZE}`), [requestGet])
const paginationProps = useMemo(() => ({
...Table.pagination,
defaultCurrent: 1, <-- when loading changes the table is remounted from scratch and this overwrites the current page
defaultPageSize: DEFAULT_PAGE_SIZE,
onChange: onChangePage,
total: totalItems,
showSizeChanger: false
}), [onChangePage, totalItems])
return (
requestError ?
errorFeedback :
<Table
columns={columns}
data={historySnapshots}
isLoading={isLoading}
pagination={paginationProps}
rowKey='date'
scroll={scroll}
size='small'
/>
)
}
Since the Table knows the current page (it is provided by the pagination.onChange
callback) it should keep track of it between loading changes in order to provide a coherent UX to the final user
node: 18
os: macos
The package.json file declares a exposed index.d.ts file in dist folder that instead does not exist.
Can you add the prop for table rowClassName from antd that let add classnames on row, like adding a different background in base of state
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.