refactor(web): UI code pruning and clean up round #3#1540
Conversation
936b10e to
e097836
Compare
| type ResponsiveFlexProps = { | ||
| [Key in keyof Omit<FlexProps, "download" | "inlist"> as FlexProps[Key] extends { | ||
| default?: unknown; | ||
| } | ||
| ? Key | ||
| : // @ts-ignore | ||
| never]: FlexProps[Key]["default"] | FlexProps[Key]; | ||
| }; |
There was a problem hiding this comment.
Just in case of doubt, what this advanced type is doing is something like:
- Asking for all FlexProps and capturing these that somehow looks like a responsive one. I.e., capturing only the ones that are objects with a
defaultoptional prop. As said in the comment, don't know why "download" and "inlist" are captured although they does not look like mentioned object. So, just ignore them. - If the prop was captured, uses an union of its own type and the type of the default key.
- If the prop was not captured, just ignore it in the new type by using never.
There was a problem hiding this comment.
don't know why "download" and "inlist" are captured although they does not look like mentioned object.
The problem is that they are typed as any, see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L2923-L3001 (interface FlexProps extends React.HTMLProps, https://github.com/patternfly/patternfly-react/blob/7b64b054146bfffde5bcddda317f2381a6ef540e/packages/react-core/src/layouts/Flex/Flex.tsx#L8)
Sadly (and kind of expected) any matches the above extends constraint. So, would be nice to have a way to ignore the properties of type any but for now it's ok ignoring these two by using the <Omit> helper instead of investing so much time on it. The wrapper works as expected and we could improve it later if finally get merged.
e097836 to
0e02268
Compare
0e02268 to
cee7cb4
Compare
In order to being able to use it with shortcuts for responsive props
instead of having to write the `propName={{ default: "propValue" }}` all
the time.
For replacing the current one by doing things a bit better. Still WIP, reason why it's in a PageNext.tsx file.
cee7cb4 to
e2e21f1
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Which still imported from core/PageNext.
e2e21f1 to
e4624d7
Compare
Mainly to avoid the tricky workaround for the ReactRouterDom#navigate overloading. See remix-run/react-router#10505 (comment)
Useful for using the aria-labelledby when no aria-label is given.
By using the PF/Card#component prop.
Instead of an HTML <section> to avoid having too much nested sections. This change might not be final and changed back again later, once we have more clear the better structure for a better a11y.
Among other minor improvements, the aria-labelledby attribute is now added only when needed.
And also use constants for sticky top and bottom values.
Replaced by Page.Section.
And also adds basic unit testing for such a new Page component.
682f411 to
cefda03
Compare
Those .jsx files that were touched in previous commits on the context of #1540.
Also drop a bunch of not needed `async` keywords in Page.test.tsx
round #3round #3
imobachgs
left a comment
There was a problem hiding this comment.
I like the new Page component :-)
Thanks a lot! I think it's looking better than before, even though there is a lot of work to do yet. But yes, I'm happy with this new Page version, much simpler than before. Also, having the "section" thingy as part of it instead of the "CardField" component helps to write Agama pages IMHO. |
Co-authored-by: Imobach González Sosa <igonzalezsosa@suse.com>
Changes sent in #1540 made some temporary core/Page internal components obsolete, making needing an adaptation of zFCP pages too. The commit also updates some copyright headers and drop no longer needed cspell exceptions.
Prepare for releasing Agama 10· * #1263 * #1330 * #1407 * #1408 * #1410 * #1411 * #1412 * #1416 * #1417 * #1419 * #1420 * #1421 * #1422 * #1423 * #1424 * #1425 * #1428 * #1429 * #1430 * #1431 * #1432 * #1433 * #1436 * #1437 * #1438 * #1439 * #1440 * #1441 * #1443 * #1444 * #1445 * #1449 * #1450 * #1451 * #1452 * #1453 * #1454 * #1455 * #1456 * #1457 * #1459 * #1460 * #1462 * #1464 * #1465 * #1466 * #1467 * #1468 * #1469 * #1470 * #1471 * #1472 * #1473 * #1475 * #1476 * #1477 * #1478 * #1479 * #1480 * #1481 * #1482 * #1483 * #1484 * #1485 * #1486 * #1487 * #1488 * #1489 * #1491 * #1492 * #1493 * #1494 * #1496 * #1497 * #1498 * #1499 * #1500 * #1501 * #1502 * #1503 * #1504 * #1505 * #1506 * #1507 * #1508 * #1510 * #1511 * #1512 * #1513 * #1514 * #1515 * #1516 * #1517 * #1518 * #1519 * #1520 * #1522 * #1523 * #1524 * #1525 * #1526 * #1527 * #1528 * #1529 * #1530 * #1531 * #1532 * #1533 * #1534 * #1535 * #1536 * #1537 * #1540 * #1541 * #1543 * #1544 * #1545 * #1546 * #1547 * #1548 * #1549 * #1550 * #1552 * #1553 * #1554 * #1555 * #1556 * #1557 * #1558 * #1559 * #1560 * #1562 * #1563 * #1565 * #1566 * #1567 * #1568 * #1569 * #1570 * #1571 * #1572 * #1573 * #1574 * #1575 * #1576 * #1577 * #1578 * #1579 * #1580 * #1581 * #1583 * #1584 * #1585 * #1586 * #1587 * #1588 * #1589 * #1590 * #1591 * #1592 * #1593 * #1596 * #1597 * #1598 * #1600 * #1602 * #1605 * #1606 * #1607 * #1608 * #1610 * #1611 * #1612 * #1613 * #1614 * #1619 * #1620 * #1621
Apart from a bit of clean up, this PR is intended for start writing better core components that has been on hold for a few months already.
It's the case of core/Page component, which has been rewritten almost for scratch and now makes the weird core/CardField transitioning component obsolete.
Please, note that this set of changes continues with the migration to TypeScript for touched files and also introduce a PatternFly/Flex wrapper in order to ease the work with its responsive props. It's a bit complex because the (ab)use of advanced types but it does the job without introducing props unknown by PF/Flex. As said in the file comments, ideally
Reviewers: Look at it (core/Flex.tsx) as a PoC to see if we are willing to introduce it and similar ones for the other PatternFly components using responsive props.
Related to #1441 and #1494