@backstage/core-components 0.9.4-next.1 → 0.9.4-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @backstage/core-components
2
2
 
3
+ ## 0.9.4-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 52c02ac02b: Don't set the background color on an Avatar component that has a picture.
8
+ - 3603014e0e: Add ARIA landmark( <main>), & label and a heading to OAuthRequestDialog. Removed nested interactive control (button).
9
+ - 2025d7c123: Properly highlight `SidebarSubmenuItem` dropdown items on hover, use ellipsis styling on long labels in `SidebarSubmenu`, allow `icon` and `to` properties to be optional on `SidebarSubmenuItem`, and fix `SidebarPage` padding to be responsive to pinned state
10
+
3
11
  ## 0.9.4-next.1
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1522,8 +1522,8 @@ declare type SidebarSubmenuItemDropdownItem = {
1522
1522
  */
1523
1523
  declare type SidebarSubmenuItemProps = {
1524
1524
  title: string;
1525
- to: string;
1526
- icon: IconComponent;
1525
+ to?: string;
1526
+ icon?: IconComponent;
1527
1527
  dropdownItems?: SidebarSubmenuItemDropdownItem[];
1528
1528
  };
1529
1529
  /**
package/dist/index.esm.js CHANGED
@@ -193,14 +193,18 @@ const useStyles$S = makeStyles((theme) => createStyles({
193
193
  function Avatar(props) {
194
194
  const { displayName, picture, customStyles } = props;
195
195
  const classes = useStyles$S();
196
+ let styles = { ...customStyles };
197
+ if (!picture) {
198
+ styles = {
199
+ backgroundColor: stringToColor(displayName || ""),
200
+ ...customStyles
201
+ };
202
+ }
196
203
  return /* @__PURE__ */ React.createElement(MaterialAvatar, {
197
204
  alt: displayName,
198
205
  src: picture,
199
206
  className: classes.avatar,
200
- style: {
201
- backgroundColor: stringToColor(displayName || picture || ""),
202
- ...customStyles
203
- }
207
+ style: styles
204
208
  }, displayName && extractInitials(displayName));
205
209
  }
206
210
 
@@ -1718,7 +1722,6 @@ const LoginRequestListItem = ({ request, busy, setBusy }) => {
1718
1722
  };
1719
1723
  const IconComponent = request.provider.icon;
1720
1724
  return /* @__PURE__ */ React.createElement(ListItem, {
1721
- button: true,
1722
1725
  disabled: busy,
1723
1726
  classes: { root: classes.root }
1724
1727
  }, /* @__PURE__ */ React.createElement(ListItemAvatar, null, /* @__PURE__ */ React.createElement(IconComponent, {
@@ -1742,6 +1745,9 @@ const useStyles$A = makeStyles((theme) => ({
1742
1745
  title: {
1743
1746
  minWidth: 0
1744
1747
  },
1748
+ titleHeading: {
1749
+ fontSize: theme.typography.h6.fontSize
1750
+ },
1745
1751
  contentList: {
1746
1752
  padding: 0
1747
1753
  },
@@ -1761,10 +1767,15 @@ function OAuthRequestDialog(_props) {
1761
1767
  open: Boolean(requests.length),
1762
1768
  fullWidth: true,
1763
1769
  maxWidth: "xs",
1764
- classes: { paper: classes.dialog }
1765
- }, /* @__PURE__ */ React.createElement(DialogTitle, {
1766
- classes: { root: classes.title }
1767
- }, "Login Required"), /* @__PURE__ */ React.createElement(DialogContent, {
1770
+ classes: { paper: classes.dialog },
1771
+ "aria-labelledby": "oauth-req-dialog-title"
1772
+ }, /* @__PURE__ */ React.createElement("main", null, /* @__PURE__ */ React.createElement(DialogTitle, {
1773
+ classes: { root: classes.title },
1774
+ id: "oauth-req-dialog-title"
1775
+ }, /* @__PURE__ */ React.createElement(Typography, {
1776
+ className: classes.titleHeading,
1777
+ variant: "h1"
1778
+ }, "Login Required")), /* @__PURE__ */ React.createElement(DialogContent, {
1768
1779
  dividers: true,
1769
1780
  classes: { root: classes.contentList }
1770
1781
  }, /* @__PURE__ */ React.createElement(List, null, requests.map((request) => /* @__PURE__ */ React.createElement(LoginRequestListItem, {
@@ -1772,7 +1783,7 @@ function OAuthRequestDialog(_props) {
1772
1783
  request,
1773
1784
  busy,
1774
1785
  setBusy
1775
- })))), /* @__PURE__ */ React.createElement(DialogActions, {
1786
+ }))))), /* @__PURE__ */ React.createElement(DialogActions, {
1776
1787
  classes: { root: classes.actionButtons }
1777
1788
  }, /* @__PURE__ */ React.createElement(Button$1, {
1778
1789
  onClick: handleRejectAll
@@ -3069,17 +3080,17 @@ const LocalStorage = {
3069
3080
  };
3070
3081
 
3071
3082
  const useStyles$n = makeStyles((theme) => ({
3072
- root: (props) => ({
3083
+ root: {
3073
3084
  width: "100%",
3074
3085
  transition: "padding-left 0.1s ease-out",
3075
3086
  isolation: "isolate",
3076
3087
  [theme.breakpoints.up("sm")]: {
3077
- paddingLeft: () => props.isPinned ? props.sidebarConfig.drawerWidthOpen : props.sidebarConfig.drawerWidthClosed
3088
+ paddingLeft: (props) => props.isPinned ? props.sidebarConfig.drawerWidthOpen : props.sidebarConfig.drawerWidthClosed
3078
3089
  },
3079
3090
  [theme.breakpoints.down("xs")]: {
3080
- paddingBottom: props.sidebarConfig.mobileSidebarHeight
3091
+ paddingBottom: (props) => props.sidebarConfig.mobileSidebarHeight
3081
3092
  }
3082
- }),
3093
+ },
3083
3094
  content: {
3084
3095
  zIndex: 0,
3085
3096
  isolation: "isolate",
@@ -3478,7 +3489,10 @@ const useStyles$j = makeStyles((theme) => ({
3478
3489
  label: {
3479
3490
  margin: 14,
3480
3491
  marginLeft: 7,
3481
- fontSize: 14
3492
+ fontSize: 14,
3493
+ whiteSpace: "nowrap",
3494
+ overflow: "hidden",
3495
+ "text-overflow": "ellipsis"
3482
3496
  },
3483
3497
  dropdownArrow: {
3484
3498
  position: "absolute",
@@ -3491,17 +3505,20 @@ const useStyles$j = makeStyles((theme) => ({
3491
3505
  },
3492
3506
  dropdownItem: {
3493
3507
  width: "100%",
3494
- padding: "10px 0 10px 0"
3508
+ padding: "10px 0 10px 0",
3509
+ "&:hover": {
3510
+ background: "#6f6f6f",
3511
+ color: theme.palette.navigation.selectedColor
3512
+ }
3495
3513
  },
3496
3514
  textContent: {
3497
3515
  color: theme.palette.navigation.color,
3498
- display: "flex",
3499
- justifyContent: "center",
3500
- [theme.breakpoints.down("xs")]: {
3501
- display: "block",
3502
- paddingLeft: theme.spacing(4)
3503
- },
3504
- fontSize: "14px"
3516
+ paddingLeft: theme.spacing(4),
3517
+ paddingRight: theme.spacing(1),
3518
+ fontSize: "14px",
3519
+ whiteSpace: "nowrap",
3520
+ overflow: "hidden",
3521
+ "text-overflow": "ellipsis"
3505
3522
  }
3506
3523
  }), { name: "BackstageSidebarSubmenuItem" });
3507
3524
  const SidebarSubmenuItem = (props) => {
@@ -3511,7 +3528,7 @@ const SidebarSubmenuItem = (props) => {
3511
3528
  const closeSubmenu = () => {
3512
3529
  setIsHoveredOn(false);
3513
3530
  };
3514
- const toLocation = useResolvedPath(to);
3531
+ const toLocation = useResolvedPath(to != null ? to : "");
3515
3532
  const currentLocation = useLocation();
3516
3533
  let isActive = isLocationMatch(currentLocation, toLocation);
3517
3534
  const [showDropDown, setShowDropDown] = useState(false);
@@ -3526,11 +3543,15 @@ const SidebarSubmenuItem = (props) => {
3526
3543
  });
3527
3544
  return /* @__PURE__ */ React.createElement("div", {
3528
3545
  className: classes.itemContainer
3546
+ }, /* @__PURE__ */ React.createElement(Tooltip, {
3547
+ title,
3548
+ enterDelay: 500,
3549
+ enterNextDelay: 500
3529
3550
  }, /* @__PURE__ */ React.createElement("button", {
3530
3551
  onClick: handleClickDropdown,
3531
3552
  onTouchStart: (e) => e.stopPropagation(),
3532
3553
  className: classNames(classes.item, isActive ? classes.selected : void 0)
3533
- }, /* @__PURE__ */ React.createElement(Icon, {
3554
+ }, Icon && /* @__PURE__ */ React.createElement(Icon, {
3534
3555
  fontSize: "small"
3535
3556
  }), /* @__PURE__ */ React.createElement(Typography, {
3536
3557
  variant: "subtitle1",
@@ -3539,33 +3560,41 @@ const SidebarSubmenuItem = (props) => {
3539
3560
  className: classes.dropdownArrow
3540
3561
  }) : /* @__PURE__ */ React.createElement(ArrowDropDownIcon, {
3541
3562
  className: classes.dropdownArrow
3542
- })), dropdownItems && showDropDown && /* @__PURE__ */ React.createElement("div", {
3563
+ }))), dropdownItems && showDropDown && /* @__PURE__ */ React.createElement("div", {
3543
3564
  className: classes.dropdown
3544
- }, dropdownItems.map((object, key) => /* @__PURE__ */ React.createElement(Link, {
3565
+ }, dropdownItems.map((object, key) => /* @__PURE__ */ React.createElement(Tooltip, {
3566
+ key,
3567
+ title: object.title,
3568
+ enterDelay: 500,
3569
+ enterNextDelay: 500
3570
+ }, /* @__PURE__ */ React.createElement(Link, {
3545
3571
  to: object.to,
3546
3572
  underline: "none",
3547
3573
  className: classes.dropdownItem,
3548
3574
  onClick: closeSubmenu,
3549
- onTouchStart: (e) => e.stopPropagation(),
3550
- key
3575
+ onTouchStart: (e) => e.stopPropagation()
3551
3576
  }, /* @__PURE__ */ React.createElement(Typography, {
3552
3577
  className: classes.textContent
3553
- }, object.title)))));
3578
+ }, object.title))))));
3554
3579
  }
3555
3580
  return /* @__PURE__ */ React.createElement("div", {
3556
3581
  className: classes.itemContainer
3582
+ }, /* @__PURE__ */ React.createElement(Tooltip, {
3583
+ title,
3584
+ enterDelay: 500,
3585
+ enterNextDelay: 500
3557
3586
  }, /* @__PURE__ */ React.createElement(Link, {
3558
3587
  to,
3559
3588
  underline: "none",
3560
3589
  className: classNames(classes.item, isActive ? classes.selected : void 0),
3561
3590
  onClick: closeSubmenu,
3562
3591
  onTouchStart: (e) => e.stopPropagation()
3563
- }, /* @__PURE__ */ React.createElement(Icon, {
3592
+ }, Icon && /* @__PURE__ */ React.createElement(Icon, {
3564
3593
  fontSize: "small"
3565
3594
  }), /* @__PURE__ */ React.createElement(Typography, {
3566
3595
  variant: "subtitle1",
3567
3596
  className: classes.label
3568
- }, title)));
3597
+ }, title))));
3569
3598
  };
3570
3599
 
3571
3600
  const useStyles$i = makeStyles((theme) => ({