@red-hat-developer-hub/backstage-plugin-dynamic-home-page 1.10.6 → 1.11.0
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 +14 -0
- package/README.md +93 -1
- package/dist/alpha/components/CustomizableGridLayout.esm.js +60 -0
- package/dist/alpha/components/CustomizableGridLayout.esm.js.map +1 -0
- package/dist/alpha/components/HomePageLayout.esm.js +25 -0
- package/dist/alpha/components/HomePageLayout.esm.js.map +1 -0
- package/dist/alpha/components/ReadOnlyGirdLayout.esm.js +137 -0
- package/dist/alpha/components/ReadOnlyGirdLayout.esm.js.map +1 -0
- package/dist/alpha/extensions/apis.esm.js +19 -0
- package/dist/alpha/extensions/apis.esm.js.map +1 -0
- package/dist/alpha/extensions/homePageCards.esm.js +117 -0
- package/dist/alpha/extensions/homePageCards.esm.js.map +1 -0
- package/dist/alpha/extensions/homePageLayoutExtension.esm.js +57 -0
- package/dist/alpha/extensions/homePageLayoutExtension.esm.js.map +1 -0
- package/dist/alpha/utils.esm.js +6 -0
- package/dist/alpha/utils.esm.js.map +1 -0
- package/dist/alpha.d.ts +77 -0
- package/dist/alpha.esm.js +39 -0
- package/dist/alpha.esm.js.map +1 -0
- package/dist/components/EntitySection/EntityCard.esm.js +6 -1
- package/dist/components/EntitySection/EntityCard.esm.js.map +1 -1
- package/dist/components/EntitySection/EntitySection.esm.js +149 -99
- package/dist/components/EntitySection/EntitySection.esm.js.map +1 -1
- package/dist/components/OnboardingSection/OnboardingCard.esm.js +3 -0
- package/dist/components/OnboardingSection/OnboardingCard.esm.js.map +1 -1
- package/dist/components/OnboardingSection/OnboardingSection.esm.js +33 -17
- package/dist/components/OnboardingSection/OnboardingSection.esm.js.map +1 -1
- package/dist/components/TemplateSection/TemplateSection.esm.js +87 -47
- package/dist/components/TemplateSection/TemplateSection.esm.js.map +1 -1
- package/dist/hooks/useContainerQuery.esm.js +43 -0
- package/dist/hooks/useContainerQuery.esm.js.map +1 -0
- package/dist/index.d.ts +1 -57
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/translations/index.esm.js.map +1 -1
- package/dist/translations/ref.esm.js.map +1 -1
- package/dist/utils/GridItem.esm.js +31 -0
- package/dist/utils/GridItem.esm.js.map +1 -0
- package/package.json +35 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingCard.esm.js","sources":["../../../src/components/OnboardingSection/OnboardingCard.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { FC } from 'react';\nimport { Link as RouterLink } from 'react-router-dom';\n\nimport Box from '@mui/material/Box';\nimport CardContent from '@mui/material/CardContent';\nimport Button from '@mui/material/Button';\nimport Typography from '@mui/material/Typography';\n\ninterface OnboardingCardProps {\n title: string;\n description: string;\n buttonText: string;\n buttonLink: string;\n target?: string;\n ariaLabel?: string;\n endIcon: React.ReactNode;\n}\n\nconst OnboardingCard: FC<OnboardingCardProps> = ({\n title,\n description,\n buttonText,\n buttonLink,\n target,\n ariaLabel,\n endIcon,\n}) => {\n return (\n <Box>\n <CardContent sx={{ backgroundColor: 'transparent' }}>\n <Typography\n sx={{\n fontSize: '1.75rem',\n fontWeight: 500,\n m: 0,\n }}\n >\n {title}\n </Typography>\n <Typography\n sx={{\n fontSize: '1rem',\n fontWeight: 500,\n p: '16px',\n pt: '8px',\n pl: '0px',\n display: '-webkit-box',\n webkitBoxOrient: 'vertical',\n maxWidth: '240px',\n webkitLineClamp: 2,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {description}\n </Typography>\n <Button\n component={RouterLink}\n variant=\"outlined\"\n color=\"primary\"\n to={buttonLink}\n target={target}\n aria-label={ariaLabel}\n sx={{\n padding: theme => theme.spacing(1, 1.5),\n fontSize: '16px',\n '& .v5-MuiButton-endIcon': {\n marginRight: 0,\n },\n }}\n endIcon={endIcon}\n >\n {buttonText}{' '}\n </Button>\n </CardContent>\n </Box>\n );\n};\n\nexport default OnboardingCard;\n"],"names":["RouterLink"],"mappings":";;;;;;;AAiCA,MAAM,iBAA0C,CAAC;AAAA,EAC/C,KAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EACE,uBAAA,GAAA,CAAC,OACC,QAAC,kBAAA,IAAA,CAAA,WAAA,EAAA,EAAY,IAAI,EAAE,eAAA,EAAiB,eAClC,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,EAAI,EAAA;AAAA,UACF,QAAU,EAAA,SAAA;AAAA,UACV,UAAY,EAAA,GAAA;AAAA,UACZ,CAAG,EAAA;AAAA,SACL;AAAA,QAEC,QAAA,EAAA;AAAA;AAAA,KACH;AAAA,oBACA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,EAAI,EAAA;AAAA,UACF,QAAU,EAAA,MAAA;AAAA,UACV,UAAY,EAAA,GAAA;AAAA,UACZ,CAAG,EAAA,MAAA;AAAA,UACH,EAAI,EAAA,KAAA;AAAA,UACJ,EAAI,EAAA,KAAA;AAAA,UACJ,OAAS,EAAA,aAAA;AAAA,UACT,eAAiB,EAAA,UAAA;AAAA,UACjB,QAAU,EAAA,OAAA;AAAA,UACV,eAAiB,EAAA,CAAA;AAAA,UACjB,QAAU,EAAA,QAAA;AAAA,UACV,YAAc,EAAA;AAAA,SAChB;AAAA,QAEC,QAAA,EAAA;AAAA;AAAA,KACH;AAAA,oBACA,IAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,SAAW,EAAAA,IAAA;AAAA,QACX,OAAQ,EAAA,UAAA;AAAA,QACR,KAAM,EAAA,SAAA;AAAA,QACN,EAAI,EAAA,UAAA;AAAA,QACJ,MAAA;AAAA,QACA,YAAY,EAAA,SAAA;AAAA,QACZ,EAAI,EAAA;AAAA,UACF,OAAS,EAAA,CAAA,KAAA,KAAS,KAAM,CAAA,OAAA,CAAQ,GAAG,GAAG,CAAA;AAAA,UACtC,QAAU,EAAA,MAAA;AAAA,UACV,yBAA2B,EAAA;AAAA,YACzB,WAAa,EAAA;AAAA;AACf,SACF;AAAA,QACA,OAAA;AAAA,QAEC,QAAA,EAAA;AAAA,UAAA,UAAA;AAAA,UAAY;AAAA;AAAA;AAAA;AACf,GAAA,EACF,CACF,EAAA,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"OnboardingCard.esm.js","sources":["../../../src/components/OnboardingSection/OnboardingCard.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { FC } from 'react';\nimport { Link as RouterLink } from 'react-router-dom';\n\nimport Box from '@mui/material/Box';\nimport CardContent from '@mui/material/CardContent';\nimport Button from '@mui/material/Button';\nimport Typography from '@mui/material/Typography';\n\ninterface OnboardingCardProps {\n title: string;\n description: string;\n buttonText: string;\n buttonLink: string;\n target?: string;\n ariaLabel?: string;\n endIcon: React.ReactNode;\n}\n\nconst OnboardingCard: FC<OnboardingCardProps> = ({\n title,\n description,\n buttonText,\n buttonLink,\n target,\n ariaLabel,\n endIcon,\n}) => {\n return (\n <Box>\n <CardContent sx={{ backgroundColor: 'transparent' }}>\n <Typography\n variant=\"h3\"\n sx={{\n fontSize: '1.75rem',\n fontWeight: 500,\n m: 0,\n }}\n >\n {title}\n </Typography>\n <Typography\n sx={{\n fontSize: '1rem',\n fontWeight: 500,\n p: '16px',\n pt: '8px',\n pl: '0px',\n display: '-webkit-box',\n webkitBoxOrient: 'vertical',\n maxWidth: '240px',\n webkitLineClamp: 2,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {description}\n </Typography>\n <Button\n component={RouterLink}\n variant=\"outlined\"\n color=\"primary\"\n to={buttonLink}\n target={target}\n aria-label={ariaLabel}\n sx={{\n width: 220,\n minWidth: 220,\n padding: theme => theme.spacing(1, 1.5),\n fontSize: '16px',\n '& .v5-MuiButton-endIcon': {\n marginRight: 0,\n },\n }}\n endIcon={endIcon}\n >\n {buttonText}{' '}\n </Button>\n </CardContent>\n </Box>\n );\n};\n\nexport default OnboardingCard;\n"],"names":["RouterLink"],"mappings":";;;;;;;AAiCA,MAAM,iBAA0C,CAAC;AAAA,EAC/C,KAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EACE,uBAAA,GAAA,CAAC,OACC,QAAC,kBAAA,IAAA,CAAA,WAAA,EAAA,EAAY,IAAI,EAAE,eAAA,EAAiB,eAClC,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,IAAA;AAAA,QACR,EAAI,EAAA;AAAA,UACF,QAAU,EAAA,SAAA;AAAA,UACV,UAAY,EAAA,GAAA;AAAA,UACZ,CAAG,EAAA;AAAA,SACL;AAAA,QAEC,QAAA,EAAA;AAAA;AAAA,KACH;AAAA,oBACA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,EAAI,EAAA;AAAA,UACF,QAAU,EAAA,MAAA;AAAA,UACV,UAAY,EAAA,GAAA;AAAA,UACZ,CAAG,EAAA,MAAA;AAAA,UACH,EAAI,EAAA,KAAA;AAAA,UACJ,EAAI,EAAA,KAAA;AAAA,UACJ,OAAS,EAAA,aAAA;AAAA,UACT,eAAiB,EAAA,UAAA;AAAA,UACjB,QAAU,EAAA,OAAA;AAAA,UACV,eAAiB,EAAA,CAAA;AAAA,UACjB,QAAU,EAAA,QAAA;AAAA,UACV,YAAc,EAAA;AAAA,SAChB;AAAA,QAEC,QAAA,EAAA;AAAA;AAAA,KACH;AAAA,oBACA,IAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,SAAW,EAAAA,IAAA;AAAA,QACX,OAAQ,EAAA,UAAA;AAAA,QACR,KAAM,EAAA,SAAA;AAAA,QACN,EAAI,EAAA,UAAA;AAAA,QACJ,MAAA;AAAA,QACA,YAAY,EAAA,SAAA;AAAA,QACZ,EAAI,EAAA;AAAA,UACF,KAAO,EAAA,GAAA;AAAA,UACP,QAAU,EAAA,GAAA;AAAA,UACV,OAAS,EAAA,CAAA,KAAA,KAAS,KAAM,CAAA,OAAA,CAAQ,GAAG,GAAG,CAAA;AAAA,UACtC,QAAU,EAAA,MAAA;AAAA,UACV,yBAA2B,EAAA;AAAA,YACzB,WAAa,EAAA;AAAA;AACf,SACF;AAAA,QACA,OAAA;AAAA,QAEC,QAAA,EAAA;AAAA,UAAA,UAAA;AAAA,UAAY;AAAA;AAAA;AAAA;AACf,GAAA,EACF,CACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -14,6 +14,7 @@ import HomePageIllustrationLight from '../../images/homepage-illustration-light.
|
|
|
14
14
|
import { getLearningItems } from '../../utils/constants.esm.js';
|
|
15
15
|
import useGreeting from '../../hooks/useGreeting.esm.js';
|
|
16
16
|
import { useTranslation } from '../../hooks/useTranslation.esm.js';
|
|
17
|
+
import { containerGridItemSx } from '../../utils/GridItem.esm.js';
|
|
17
18
|
|
|
18
19
|
const OnboardingSection = () => {
|
|
19
20
|
const [user, setUser] = useState();
|
|
@@ -53,17 +54,17 @@ const OnboardingSection = () => {
|
|
|
53
54
|
}
|
|
54
55
|
return name;
|
|
55
56
|
};
|
|
56
|
-
const content = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Grid, { container: true,
|
|
57
|
+
const content = /* @__PURE__ */ jsx(Box, { sx: { mt: 2 }, children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
|
|
57
58
|
/* @__PURE__ */ jsx(
|
|
58
59
|
Grid,
|
|
59
60
|
{
|
|
60
61
|
item: true,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
sx: {
|
|
63
|
+
...containerGridItemSx({ xs: 12, sm: 6, md: 3 }),
|
|
64
|
+
display: "flex",
|
|
65
|
+
justifyContent: "left",
|
|
66
|
+
alignItems: "center"
|
|
67
|
+
},
|
|
67
68
|
children: /* @__PURE__ */ jsx(
|
|
68
69
|
Box,
|
|
69
70
|
{
|
|
@@ -71,7 +72,8 @@ const OnboardingSection = () => {
|
|
|
71
72
|
src: isDarkMode ? HomePageIllustrationDark : HomePageIllustrationLight,
|
|
72
73
|
alt: "",
|
|
73
74
|
sx: {
|
|
74
|
-
width: "clamp(200px, 20vw, 264px)"
|
|
75
|
+
width: "clamp(200px, 20vw, 264px)",
|
|
76
|
+
height: "auto"
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
)
|
|
@@ -81,12 +83,12 @@ const OnboardingSection = () => {
|
|
|
81
83
|
Grid,
|
|
82
84
|
{
|
|
83
85
|
item: true,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
sx: {
|
|
87
|
+
...containerGridItemSx({ xs: 12, sm: 6, md: 3 }),
|
|
88
|
+
display: "flex",
|
|
89
|
+
justifyContent: "left",
|
|
90
|
+
alignItems: "center"
|
|
91
|
+
},
|
|
90
92
|
children: /* @__PURE__ */ jsx(
|
|
91
93
|
OnboardingCard,
|
|
92
94
|
{
|
|
@@ -110,7 +112,9 @@ const OnboardingSection = () => {
|
|
|
110
112
|
sx: {
|
|
111
113
|
padding: "24px",
|
|
112
114
|
border: (muiTheme) => `1px solid ${muiTheme.palette.grey[300]}`,
|
|
113
|
-
|
|
115
|
+
containerType: "inline-size",
|
|
116
|
+
display: "flex",
|
|
117
|
+
flexDirection: "column"
|
|
114
118
|
},
|
|
115
119
|
children: [
|
|
116
120
|
!profileLoading && /* @__PURE__ */ jsx(
|
|
@@ -121,12 +125,24 @@ const OnboardingSection = () => {
|
|
|
121
125
|
display: "flex",
|
|
122
126
|
alignItems: "center",
|
|
123
127
|
fontWeight: "500",
|
|
124
|
-
fontSize: "1.5rem"
|
|
128
|
+
fontSize: "1.5rem",
|
|
129
|
+
flexShrink: 0
|
|
125
130
|
},
|
|
126
131
|
children: `${greeting}, ${profileDisplayName() || t("onboarding.guest")}!`
|
|
127
132
|
}
|
|
128
133
|
),
|
|
129
|
-
|
|
134
|
+
/* @__PURE__ */ jsx(
|
|
135
|
+
Box,
|
|
136
|
+
{
|
|
137
|
+
sx: {
|
|
138
|
+
flex: 1,
|
|
139
|
+
minHeight: 0,
|
|
140
|
+
overflowY: "auto",
|
|
141
|
+
mt: 1
|
|
142
|
+
},
|
|
143
|
+
children: content
|
|
144
|
+
}
|
|
145
|
+
)
|
|
130
146
|
]
|
|
131
147
|
}
|
|
132
148
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingSection.esm.js","sources":["../../../src/components/OnboardingSection/OnboardingSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useEffect } from 'react';\n\nimport { useUserProfile } from '@backstage/plugin-user-settings';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { UserEntity } from '@backstage/catalog-model';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport Card from '@mui/material/Card';\nimport { useTheme } from '@mui/material/styles';\n\nimport OnboardingCard from './OnboardingCard';\nimport HomePageIllustrationDark from '../../images/homepage-illustration-dark.svg';\nimport HomePageIllustrationLight from '../../images/homepage-illustration-light.svg';\nimport { getLearningItems } from '../../utils/constants';\nimport useGreeting from '../../hooks/useGreeting';\nimport { LearningSectionItem } from '../../types';\nimport { useTranslation } from '../../hooks/useTranslation';\n\nexport const OnboardingSection = () => {\n const [user, setUser] = useState<string | null>();\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n const greeting = useGreeting();\n const { t } = useTranslation();\n const {\n displayName,\n backstageIdentity,\n loading: profileLoading,\n } = useUserProfile();\n const catalogApi = useApi(catalogApiRef);\n\n useEffect(() => {\n const fetchUserEntity = async () => {\n if (!backstageIdentity?.userEntityRef) {\n return;\n }\n try {\n const userEntity = (await catalogApi.getEntityByRef(\n backstageIdentity.userEntityRef,\n )) as unknown as UserEntity;\n setUser(\n userEntity?.spec?.profile?.displayName ?? userEntity?.metadata?.title,\n );\n } catch (_err) {\n setUser(null);\n }\n };\n\n fetchUserEntity();\n }, [backstageIdentity, catalogApi]);\n\n const profileDisplayName = () => {\n const name = user ?? displayName;\n const regex = /^[^:/]+:[^/]+\\/[^/]+$/;\n if (regex.test(name)) {\n return name\n .charAt(name.indexOf('/') + 1)\n .toLocaleUpperCase('en-US')\n .concat(name.substring(name.indexOf('/') + 2));\n }\n return name;\n };\n\n const content = (\n <Box>\n <Grid container
|
|
1
|
+
{"version":3,"file":"OnboardingSection.esm.js","sources":["../../../src/components/OnboardingSection/OnboardingSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useEffect } from 'react';\n\nimport { useUserProfile } from '@backstage/plugin-user-settings';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { UserEntity } from '@backstage/catalog-model';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport Card from '@mui/material/Card';\nimport { useTheme } from '@mui/material/styles';\n\nimport OnboardingCard from './OnboardingCard';\nimport HomePageIllustrationDark from '../../images/homepage-illustration-dark.svg';\nimport HomePageIllustrationLight from '../../images/homepage-illustration-light.svg';\nimport { getLearningItems } from '../../utils/constants';\nimport useGreeting from '../../hooks/useGreeting';\nimport { LearningSectionItem } from '../../types';\nimport { useTranslation } from '../../hooks/useTranslation';\nimport { containerGridItemSx } from '../../utils/GridItem';\n\nexport const OnboardingSection = () => {\n const [user, setUser] = useState<string | null>();\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n const greeting = useGreeting();\n const { t } = useTranslation();\n const {\n displayName,\n backstageIdentity,\n loading: profileLoading,\n } = useUserProfile();\n const catalogApi = useApi(catalogApiRef);\n\n useEffect(() => {\n const fetchUserEntity = async () => {\n if (!backstageIdentity?.userEntityRef) {\n return;\n }\n try {\n const userEntity = (await catalogApi.getEntityByRef(\n backstageIdentity.userEntityRef,\n )) as unknown as UserEntity;\n setUser(\n userEntity?.spec?.profile?.displayName ?? userEntity?.metadata?.title,\n );\n } catch (_err) {\n setUser(null);\n }\n };\n\n fetchUserEntity();\n }, [backstageIdentity, catalogApi]);\n\n const profileDisplayName = () => {\n const name = user ?? displayName;\n const regex = /^[^:/]+:[^/]+\\/[^/]+$/;\n if (regex.test(name)) {\n return name\n .charAt(name.indexOf('/') + 1)\n .toLocaleUpperCase('en-US')\n .concat(name.substring(name.indexOf('/') + 2));\n }\n return name;\n };\n\n const content = (\n <Box sx={{ mt: 2 }}>\n <Grid container spacing={2}>\n <Grid\n item\n sx={{\n ...containerGridItemSx({ xs: 12, sm: 6, md: 3 }),\n display: 'flex',\n justifyContent: 'left',\n alignItems: 'center',\n }}\n >\n <Box\n component=\"img\"\n src={\n isDarkMode ? HomePageIllustrationDark : HomePageIllustrationLight\n }\n alt=\"\"\n sx={{\n width: 'clamp(200px, 20vw, 264px)',\n height: 'auto',\n }}\n />\n </Grid>\n {getLearningItems(t).map((item: LearningSectionItem) => (\n <Grid\n item\n key={item.title}\n sx={{\n ...containerGridItemSx({ xs: 12, sm: 6, md: 3 }),\n display: 'flex',\n justifyContent: 'left',\n alignItems: 'center',\n }}\n >\n <OnboardingCard\n title={item.title}\n description={item.description}\n buttonText={item.buttonText}\n buttonLink={item.buttonLink}\n target={item.target}\n ariaLabel={item.ariaLabel}\n endIcon={<item.endIcon />}\n />\n </Grid>\n ))}\n </Grid>\n </Box>\n );\n\n return (\n <Card\n elevation={0}\n sx={{\n padding: '24px',\n border: muiTheme => `1px solid ${muiTheme.palette.grey[300]}`,\n containerType: 'inline-size',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n {!profileLoading && (\n <Typography\n variant=\"h3\"\n sx={{\n display: 'flex',\n alignItems: 'center',\n fontWeight: '500',\n fontSize: '1.5rem',\n flexShrink: 0,\n }}\n >\n {`${greeting}, ${profileDisplayName() || t('onboarding.guest')}!`}\n </Typography>\n )}\n <Box\n sx={{\n flex: 1,\n minHeight: 0,\n overflowY: 'auto',\n mt: 1,\n }}\n >\n {content}\n </Box>\n </Card>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAqCO,MAAM,oBAAoB,MAAM;AACrC,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAwB,EAAA;AAChD,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,UAAA,GAAa,KAAM,CAAA,OAAA,CAAQ,IAAS,KAAA,MAAA;AAC1C,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,EAAM,MAAA;AAAA,IACJ,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAS,EAAA;AAAA,MACP,cAAe,EAAA;AACnB,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA;AAEvC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,kBAAkB,YAAY;AAClC,MAAI,IAAA,CAAC,mBAAmB,aAAe,EAAA;AACrC,QAAA;AAAA;AAEF,MAAI,IAAA;AACF,QAAM,MAAA,UAAA,GAAc,MAAM,UAAW,CAAA,cAAA;AAAA,UACnC,iBAAkB,CAAA;AAAA,SACpB;AACA,QAAA,OAAA;AAAA,UACE,UAAY,EAAA,IAAA,EAAM,OAAS,EAAA,WAAA,IAAe,YAAY,QAAU,EAAA;AAAA,SAClE;AAAA,eACO,IAAM,EAAA;AACb,QAAA,OAAA,CAAQ,IAAI,CAAA;AAAA;AACd,KACF;AAEA,IAAgB,eAAA,EAAA;AAAA,GACf,EAAA,CAAC,iBAAmB,EAAA,UAAU,CAAC,CAAA;AAElC,EAAA,MAAM,qBAAqB,MAAM;AAC/B,IAAA,MAAM,OAAO,IAAQ,IAAA,WAAA;AACrB,IAAA,MAAM,KAAQ,GAAA,uBAAA;AACd,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,KAAA;AAAA,cACZ,QAAU,EAAA,QAAA;AAAA,cACV,UAAY,EAAA;AAAA,aACd;AAAA,YAEC,aAAG,QAAQ,CAAA,EAAA,EAAK,oBAAwB,IAAA,CAAA,CAAE,kBAAkB,CAAC,CAAA,CAAA;AAAA;AAAA,SAChE;AAAA,wBAEF,GAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,EAAI,EAAA;AAAA,cACF,IAAM,EAAA,CAAA;AAAA,cACN,SAAW,EAAA,CAAA;AAAA,cACX,SAAW,EAAA,MAAA;AAAA,cACX,EAAI,EAAA;AAAA,aACN;AAAA,YAEC,QAAA,EAAA;AAAA;AAAA;AACH;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -13,6 +13,7 @@ import { useEntities } from '../../hooks/useEntities.esm.js';
|
|
|
13
13
|
import { ViewMoreLink } from './ViewMoreLink.esm.js';
|
|
14
14
|
import { useTranslation } from '../../hooks/useTranslation.esm.js';
|
|
15
15
|
import { Trans } from '../Trans.esm.js';
|
|
16
|
+
import { containerGridItemSx } from '../../utils/GridItem.esm.js';
|
|
16
17
|
|
|
17
18
|
const StyledLink = styled(Link)(({ theme }) => ({
|
|
18
19
|
textDecoration: "none",
|
|
@@ -58,53 +59,76 @@ const TemplateSection = () => {
|
|
|
58
59
|
) });
|
|
59
60
|
} else {
|
|
60
61
|
content = /* @__PURE__ */ jsx(Box, { sx: { padding: "8px 8px 8px 0" }, children: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 1, alignItems: "stretch", children: [
|
|
61
|
-
templates?.items.map((item) => /* @__PURE__ */ jsx(
|
|
62
|
-
|
|
62
|
+
templates?.items.map((item) => /* @__PURE__ */ jsx(
|
|
63
|
+
Grid,
|
|
63
64
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
item: true,
|
|
66
|
+
sx: containerGridItemSx({
|
|
67
|
+
xs: 12,
|
|
68
|
+
sm: 6,
|
|
69
|
+
md: 3
|
|
70
|
+
}),
|
|
71
|
+
children: /* @__PURE__ */ jsx(
|
|
72
|
+
TemplateCard,
|
|
73
|
+
{
|
|
74
|
+
link: `/create/templates/${item.metadata.namespace}/${item.metadata.name}`,
|
|
75
|
+
title: item.metadata.title,
|
|
76
|
+
description: item.metadata.description,
|
|
77
|
+
kind: item.kind,
|
|
78
|
+
type: item.spec?.type
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
item.title
|
|
83
|
+
)),
|
|
84
|
+
templates?.items.length === 0 && /* @__PURE__ */ jsx(
|
|
85
|
+
Grid,
|
|
73
86
|
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
overflow: "hidden"
|
|
81
|
-
},
|
|
82
|
-
children: /* @__PURE__ */ jsxs(
|
|
83
|
-
CardContent,
|
|
87
|
+
item: true,
|
|
88
|
+
sx: containerGridItemSx({
|
|
89
|
+
xs: 12
|
|
90
|
+
}),
|
|
91
|
+
children: /* @__PURE__ */ jsx(
|
|
92
|
+
Box,
|
|
84
93
|
{
|
|
85
94
|
sx: {
|
|
86
|
-
|
|
95
|
+
height: "100%",
|
|
96
|
+
display: "flex",
|
|
97
|
+
alignItems: "center",
|
|
98
|
+
justifyContent: "center",
|
|
99
|
+
minHeight: 250,
|
|
100
|
+
border: (muiTheme) => `1px solid ${muiTheme.palette.grey[400]}`,
|
|
101
|
+
borderRadius: 3,
|
|
102
|
+
overflow: "hidden"
|
|
87
103
|
},
|
|
88
|
-
children:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
children: /* @__PURE__ */ jsxs(
|
|
105
|
+
CardContent,
|
|
106
|
+
{
|
|
107
|
+
sx: {
|
|
108
|
+
margin: "1rem"
|
|
109
|
+
},
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx(Typography, { sx: { fontSize: "1.125rem", fontWeight: 500 }, children: t("templates.empty") }),
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
Typography,
|
|
114
|
+
{
|
|
115
|
+
sx: {
|
|
116
|
+
fontSize: "0.875rem",
|
|
117
|
+
fontWeight: 400,
|
|
118
|
+
mt: "20px",
|
|
119
|
+
mb: "16px"
|
|
120
|
+
},
|
|
121
|
+
children: t("templates.emptyDescription")
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsx(StyledLink, { to: "/catalog-import", underline: "none", children: t("templates.register") })
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
)
|
|
104
128
|
}
|
|
105
129
|
)
|
|
106
130
|
}
|
|
107
|
-
)
|
|
131
|
+
)
|
|
108
132
|
] }) }) });
|
|
109
133
|
}
|
|
110
134
|
return /* @__PURE__ */ jsxs(
|
|
@@ -114,7 +138,9 @@ const TemplateSection = () => {
|
|
|
114
138
|
sx: {
|
|
115
139
|
padding: "24px",
|
|
116
140
|
border: (muiTheme) => `1px solid ${muiTheme.palette.grey[300]}`,
|
|
117
|
-
|
|
141
|
+
containerType: "inline-size",
|
|
142
|
+
display: "flex",
|
|
143
|
+
flexDirection: "column"
|
|
118
144
|
},
|
|
119
145
|
children: [
|
|
120
146
|
/* @__PURE__ */ jsx(
|
|
@@ -125,19 +151,33 @@ const TemplateSection = () => {
|
|
|
125
151
|
display: "flex",
|
|
126
152
|
alignItems: "center",
|
|
127
153
|
fontWeight: "500",
|
|
128
|
-
fontSize: "1.5rem"
|
|
154
|
+
fontSize: "1.5rem",
|
|
155
|
+
flexShrink: 0
|
|
129
156
|
},
|
|
130
157
|
children: t("templates.title")
|
|
131
158
|
}
|
|
132
159
|
),
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
Trans,
|
|
160
|
+
/* @__PURE__ */ jsxs(
|
|
161
|
+
Box,
|
|
136
162
|
{
|
|
137
|
-
|
|
138
|
-
|
|
163
|
+
sx: {
|
|
164
|
+
flex: 1,
|
|
165
|
+
minHeight: 0,
|
|
166
|
+
overflowY: "auto",
|
|
167
|
+
mt: 1
|
|
168
|
+
},
|
|
169
|
+
children: [
|
|
170
|
+
content,
|
|
171
|
+
templates?.items && templates?.items.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { pt: 2 }, children: /* @__PURE__ */ jsx(ViewMoreLink, { to: catalogTemplatesLink, underline: "always", children: /* @__PURE__ */ jsx(
|
|
172
|
+
Trans,
|
|
173
|
+
{
|
|
174
|
+
message: "templates.viewAll",
|
|
175
|
+
params: { count: templates?.totalItems?.toString() || "" }
|
|
176
|
+
}
|
|
177
|
+
) }) })
|
|
178
|
+
]
|
|
139
179
|
}
|
|
140
|
-
)
|
|
180
|
+
)
|
|
141
181
|
]
|
|
142
182
|
}
|
|
143
183
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateSection.esm.js","sources":["../../../src/components/TemplateSection/TemplateSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { ReactNode } from 'react';\n\nimport { Fragment } from 'react';\n\nimport {\n CodeSnippet,\n WarningPanel,\n Link as BackstageLink,\n} from '@backstage/core-components';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Card from '@mui/material/Card';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport CardContent from '@mui/material/CardContent';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport TemplateCard from './TemplateCard';\nimport { useEntities } from '../../hooks/useEntities';\nimport { ViewMoreLink } from './ViewMoreLink';\nimport { useTranslation } from '../../hooks/useTranslation';\nimport { Trans } from '../Trans';\n\nconst StyledLink = styled(BackstageLink)(({ theme }) => ({\n textDecoration: 'none',\n padding: theme.spacing(1, 1.5),\n fontSize: '16px',\n display: 'inline-flex',\n border: `1px solid ${theme.palette.primary.main}`,\n borderRadius: 4,\n}));\n\nexport const TemplateSection = () => {\n const { t } = useTranslation();\n const {\n data: templates,\n error,\n isLoading,\n } = useEntities({ kind: 'Template' });\n\n const params = new URLSearchParams({\n 'filters[kind]': 'template',\n limit: '20',\n });\n const catalogTemplatesLink = `/catalog?${params.toString()}`;\n\n let content: ReactNode;\n\n if (isLoading) {\n content = (\n <Box\n sx={{\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n }}\n >\n <CircularProgress />\n </Box>\n );\n } else if (!templates) {\n content = (\n <WarningPanel severity=\"error\" title={t('templates.fetchError')}>\n <CodeSnippet\n language=\"text\"\n text={error?.toString() ?? t('templates.error')}\n />\n </WarningPanel>\n );\n } else {\n content = (\n <Box sx={{ padding: '8px 8px 8px 0' }}>\n <Fragment>\n <Grid container spacing={1} alignItems=\"stretch\">\n {templates?.items.map((item: any) => (\n <Grid item xs={12} md={6} lg={3} key={item.title}>\n <TemplateCard\n link={`/create/templates/${item.metadata.namespace}/${item.metadata.name}`}\n title={item.metadata.title}\n description={item.metadata.description}\n kind={item.kind}\n type={item.spec?.type}\n />\n </Grid>\n ))}\n {templates?.items.length === 0 && (\n <Grid item xs={12} md={12}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n border: muiTheme =>\n `1px solid ${muiTheme.palette.grey[400]}`,\n borderRadius: 3,\n overflow: 'hidden',\n }}\n >\n <CardContent\n sx={{\n margin: '1rem',\n }}\n >\n <Typography sx={{ fontSize: '1.125rem', fontWeight: 500 }}>\n {t('templates.empty')}\n </Typography>\n <Typography\n sx={{\n fontSize: '0.875rem',\n fontWeight: 400,\n mt: '20px',\n mb: '16px',\n }}\n >\n {t('templates.emptyDescription')}\n </Typography>\n <StyledLink to=\"/catalog-import\" underline=\"none\">\n {t('templates.register')}\n </StyledLink>\n </CardContent>\n </Box>\n </Grid>\n )}\n </Grid>\n </Fragment>\n </Box>\n );\n }\n\n return (\n <Card\n elevation={0}\n sx={{\n padding: '24px',\n border: muiTheme => `1px solid ${muiTheme.palette.grey[300]}`,\n overflow: 'auto',\n }}\n >\n <Typography\n variant=\"h3\"\n sx={{\n display: 'flex',\n alignItems: 'center',\n fontWeight: '500',\n fontSize: '1.5rem',\n }}\n >\n {t('templates.title')}\n </Typography>\n {content}\n {templates?.items && templates?.items.length > 0 && (\n <Box sx={{ pt: 2 }}>\n <ViewMoreLink to={catalogTemplatesLink} underline=\"always\">\n <Trans\n message=\"templates.viewAll\"\n params={{ count: templates?.totalItems?.toString() || '' }}\n />\n </ViewMoreLink>\n </Box>\n )}\n </Card>\n );\n};\n"],"names":["BackstageLink"],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAM,aAAa,MAAO,CAAAA,IAAa,EAAE,CAAC,EAAE,OAAa,MAAA;AAAA,EACvD,cAAgB,EAAA,MAAA;AAAA,EAChB,OAAS,EAAA,KAAA,CAAM,OAAQ,CAAA,CAAA,EAAG,GAAG,CAAA;AAAA,EAC7B,QAAU,EAAA,MAAA;AAAA,EACV,OAAS,EAAA,aAAA;AAAA,EACT,MAAQ,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,QAAQ,IAAI,CAAA,CAAA;AAAA,EAC/C,YAAc,EAAA;AAChB,CAAE,CAAA,CAAA;AAEK,MAAM,kBAAkB,MAAM;AACnC,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,iBAAiB;AAAA;AAAA,SACtB;AAAA,QACC,OAAA;AAAA,QACA,WAAW,KAAS,IAAA,SAAA,EAAW,MAAM,MAAS,GAAA,CAAA,wBAC5C,GAAI,EAAA,EAAA,EAAA,EAAI,EAAE,EAAA,EAAI,GACb,EAAA,QAAA,kBAAA,GAAA,CAAC,gBAAa,EAAI,EAAA,oBAAA,EAAsB,WAAU,QAChD,EAAA,QAAA,kBAAA,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,OAAQ,EAAA,mBAAA;AAAA,YACR,QAAQ,EAAE,KAAA,EAAO,WAAW,UAAY,EAAA,QAAA,MAAc,EAAG;AAAA;AAAA,WAE7D,CACF,EAAA;AAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"TemplateSection.esm.js","sources":["../../../src/components/TemplateSection/TemplateSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { ReactNode } from 'react';\n\nimport { Fragment } from 'react';\n\nimport {\n CodeSnippet,\n WarningPanel,\n Link as BackstageLink,\n} from '@backstage/core-components';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Card from '@mui/material/Card';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport CardContent from '@mui/material/CardContent';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport TemplateCard from './TemplateCard';\nimport { useEntities } from '../../hooks/useEntities';\nimport { ViewMoreLink } from './ViewMoreLink';\nimport { useTranslation } from '../../hooks/useTranslation';\nimport { Trans } from '../Trans';\nimport { containerGridItemSx } from '../../utils/GridItem';\n\nconst StyledLink = styled(BackstageLink)(({ theme }) => ({\n textDecoration: 'none',\n padding: theme.spacing(1, 1.5),\n fontSize: '16px',\n display: 'inline-flex',\n border: `1px solid ${theme.palette.primary.main}`,\n borderRadius: 4,\n}));\n\nexport const TemplateSection = () => {\n const { t } = useTranslation();\n const {\n data: templates,\n error,\n isLoading,\n } = useEntities({ kind: 'Template' });\n\n const params = new URLSearchParams({\n 'filters[kind]': 'template',\n limit: '20',\n });\n const catalogTemplatesLink = `/catalog?${params.toString()}`;\n\n let content: ReactNode;\n\n if (isLoading) {\n content = (\n <Box\n sx={{\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n }}\n >\n <CircularProgress />\n </Box>\n );\n } else if (!templates) {\n content = (\n <WarningPanel severity=\"error\" title={t('templates.fetchError')}>\n <CodeSnippet\n language=\"text\"\n text={error?.toString() ?? t('templates.error')}\n />\n </WarningPanel>\n );\n } else {\n content = (\n <Box sx={{ padding: '8px 8px 8px 0' }}>\n <Fragment>\n <Grid container spacing={1} alignItems=\"stretch\">\n {templates?.items.map((item: any) => (\n <Grid\n item\n sx={containerGridItemSx({\n xs: 12,\n sm: 6,\n md: 3,\n })}\n key={item.title}\n >\n <TemplateCard\n link={`/create/templates/${item.metadata.namespace}/${item.metadata.name}`}\n title={item.metadata.title}\n description={item.metadata.description}\n kind={item.kind}\n type={item.spec?.type}\n />\n </Grid>\n ))}\n {templates?.items.length === 0 && (\n <Grid\n item\n sx={containerGridItemSx({\n xs: 12,\n })}\n >\n <Box\n sx={{\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 250,\n border: muiTheme =>\n `1px solid ${muiTheme.palette.grey[400]}`,\n borderRadius: 3,\n overflow: 'hidden',\n }}\n >\n <CardContent\n sx={{\n margin: '1rem',\n }}\n >\n <Typography sx={{ fontSize: '1.125rem', fontWeight: 500 }}>\n {t('templates.empty')}\n </Typography>\n <Typography\n sx={{\n fontSize: '0.875rem',\n fontWeight: 400,\n mt: '20px',\n mb: '16px',\n }}\n >\n {t('templates.emptyDescription')}\n </Typography>\n <StyledLink to=\"/catalog-import\" underline=\"none\">\n {t('templates.register')}\n </StyledLink>\n </CardContent>\n </Box>\n </Grid>\n )}\n </Grid>\n </Fragment>\n </Box>\n );\n }\n\n return (\n <Card\n elevation={0}\n sx={{\n padding: '24px',\n border: muiTheme => `1px solid ${muiTheme.palette.grey[300]}`,\n containerType: 'inline-size',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <Typography\n variant=\"h3\"\n sx={{\n display: 'flex',\n alignItems: 'center',\n fontWeight: '500',\n fontSize: '1.5rem',\n flexShrink: 0,\n }}\n >\n {t('templates.title')}\n </Typography>\n <Box\n sx={{\n flex: 1,\n minHeight: 0,\n overflowY: 'auto',\n mt: 1,\n }}\n >\n {content}\n {templates?.items && templates?.items.length > 0 && (\n <Box sx={{ pt: 2 }}>\n <ViewMoreLink to={catalogTemplatesLink} underline=\"always\">\n <Trans\n message=\"templates.viewAll\"\n params={{ count: templates?.totalItems?.toString() || '' }}\n />\n </ViewMoreLink>\n </Box>\n )}\n </Box>\n </Card>\n );\n};\n"],"names":["BackstageLink"],"mappings":";;;;;;;;;;;;;;;;;AAwCA,MAAM,aAAa,MAAO,CAAAA,IAAa,EAAE,CAAC,EAAE,OAAa,MAAA;AAAA,EACvD,cAAgB,EAAA,MAAA;AAAA,EAChB,OAAS,EAAA,KAAA,CAAM,OAAQ,CAAA,CAAA,EAAG,GAAG,CAAA;AAAA,EAC7B,QAAU,EAAA,MAAA;AAAA,EACV,OAAS,EAAA,aAAA;AAAA,EACT,MAAQ,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,QAAQ,IAAI,CAAA,CAAA;AAAA,EAC/C,YAAc,EAAA;AAChB,CAAE,CAAA,CAAA;AAEK,MAAM,kBAAkB,MAAM;AACnC,EAAM,MAAA,EAAE,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g: 1200,
|
|
11
|
+
// ≥1200
|
|
12
|
+
xl: 1536
|
|
13
|
+
// ≥1536
|
|
14
|
+
};
|
|
15
|
+
const resolveContainerSize = (width) => {
|
|
16
|
+
if (width >= CONTAINER_BREAKPOINTS.xl) return "xl";
|
|
17
|
+
if (width >= CONTAINER_BREAKPOINTS.lg) return "lg";
|
|
18
|
+
if (width >= CONTAINER_BREAKPOINTS.md) return "md";
|
|
19
|
+
if (width >= CONTAINER_BREAKPOINTS.sm) return "sm";
|
|
20
|
+
return "xs";
|
|
21
|
+
};
|
|
22
|
+
const useContainerQuery = (ref) => {
|
|
23
|
+
const [containerSize, setContainerSize] = useState("lg");
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
const el = ref.current;
|
|
26
|
+
if (!el) return undefined;
|
|
27
|
+
const updateSize = (width) => {
|
|
28
|
+
const next = resolveContainerSize(width);
|
|
29
|
+
setContainerSize((prev) => prev === next ? prev : next);
|
|
30
|
+
};
|
|
31
|
+
updateSize(el.getBoundingClientRect().width);
|
|
32
|
+
const observer = new ResizeObserver((entries) => {
|
|
33
|
+
if (!entries.length) return;
|
|
34
|
+
updateSize(entries[0].contentRect.width);
|
|
35
|
+
});
|
|
36
|
+
observer.observe(el);
|
|
37
|
+
return () => observer.disconnect();
|
|
38
|
+
}, [ref]);
|
|
39
|
+
return containerSize;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { CONTAINER_BREAKPOINTS, useContainerQuery };
|
|
43
|
+
//# sourceMappingURL=useContainerQuery.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContainerQuery.esm.js","sources":["../../src/hooks/useContainerQuery.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * A React hook that observes the width of a DOM element and\n * returns a responsive \"container size\" (`xs | sm | md | lg | xl`)\n * based on predefined breakpoints.\n *\n * Unlike window-based media queries, this hook is **container-based**:\n * the returned size depends on the element's own width, not the viewport.\n *\n * Internally, it:\n * - Reads the element's initial layout width on mount\n * - Uses ResizeObserver to track width changes\n * - Maps the width to MUI-like breakpoints\n * - Updates state only when the breakpoint actually changes\n * */\n\nimport { useLayoutEffect, useState, RefObject } from 'react';\n\n// Container Breakpoints (MUI-like, but container-based)\nexport type ContainerSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport const CONTAINER_BREAKPOINTS = {\n xs: 0, // <600\n sm: 600, // ≥600\n md: 900, // ≥900\n lg: 1200, // ≥1200\n xl: 1536, // ≥1536\n} as const;\n\n// Width → containerSize mapper\nconst resolveContainerSize = (width: number): ContainerSize => {\n if (width >= CONTAINER_BREAKPOINTS.xl) return 'xl';\n if (width >= CONTAINER_BREAKPOINTS.lg) return 'lg';\n if (width >= CONTAINER_BREAKPOINTS.md) return 'md';\n if (width >= CONTAINER_BREAKPOINTS.sm) return 'sm';\n return 'xs';\n};\n\n// Hook: useContainerQuery\n\nexport const useContainerQuery = (\n ref: RefObject<HTMLElement>,\n): ContainerSize => {\n const [containerSize, setContainerSize] = useState<ContainerSize>('lg');\n\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return undefined;\n\n const updateSize = (width: number) => {\n const next = resolveContainerSize(width);\n setContainerSize(prev => (prev === next ? prev : next));\n };\n\n // Initial read\n updateSize(el.getBoundingClientRect().width);\n\n const observer = new ResizeObserver(entries => {\n if (!entries.length) return;\n updateSize(entries[0].contentRect.width);\n });\n\n observer.observe(el);\n return () => observer.disconnect();\n }, [ref]);\n\n return containerSize;\n};\n"],"names":[],"mappings":";;AAoCO,MAAM,qB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WAAA,CAAY,KAAK,CAAA;AAAA,KACxC,CAAA;AAED,IAAA,QAAA,CAAS,QAAQ,EAAE,CAAA;AACnB,IAAO,OAAA,MAAM,SAAS,UAAW,EAAA;AAAA,GACnC,EAAG,CAAC,GAAG,CAAC,CAAA;AAER,EAAO,OAAA,aAAA;AACT;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { ClockConfig, StarredEntitiesProps, VisitedByTypeProps, FeaturedDocsCard
|
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
4
|
import { ComponentType } from 'react';
|
|
5
|
-
import * as _backstage_core_plugin_api_alpha from '@backstage/core-plugin-api/alpha';
|
|
6
5
|
import { CardLayout, CardSettings } from '@backstage/plugin-home-react';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -242,59 +241,4 @@ declare const EntitySection: () => react_jsx_runtime.JSX.Element;
|
|
|
242
241
|
*/
|
|
243
242
|
declare const TemplateSection: () => react_jsx_runtime.JSX.Element;
|
|
244
243
|
|
|
245
|
-
|
|
246
|
-
* Reference translation for Homepage.
|
|
247
|
-
* Defines all the translation keys used in the plugin.
|
|
248
|
-
* @public
|
|
249
|
-
*/
|
|
250
|
-
declare const homepageTranslationRef: _backstage_core_plugin_api_alpha.TranslationRef<"plugin.homepage", {
|
|
251
|
-
readonly "header.local": string;
|
|
252
|
-
readonly "header.welcome": string;
|
|
253
|
-
readonly "header.welcomePersonalized": string;
|
|
254
|
-
readonly "search.placeholder": string;
|
|
255
|
-
readonly "homePage.empty": string;
|
|
256
|
-
readonly "quickAccess.title": string;
|
|
257
|
-
readonly "quickAccess.error": string;
|
|
258
|
-
readonly "quickAccess.fetchError": string;
|
|
259
|
-
readonly "featuredDocs.learnMore": string;
|
|
260
|
-
readonly "templates.title": string;
|
|
261
|
-
readonly "templates.error": string;
|
|
262
|
-
readonly "templates.empty": string;
|
|
263
|
-
readonly "templates.fetchError": string;
|
|
264
|
-
readonly "templates.emptyDescription": string;
|
|
265
|
-
readonly "templates.register": string;
|
|
266
|
-
readonly "templates.viewAll": string;
|
|
267
|
-
readonly "onboarding.greeting.goodMorning": string;
|
|
268
|
-
readonly "onboarding.greeting.goodAfternoon": string;
|
|
269
|
-
readonly "onboarding.greeting.goodEvening": string;
|
|
270
|
-
readonly "onboarding.guest": string;
|
|
271
|
-
readonly "onboarding.getStarted.title": string;
|
|
272
|
-
readonly "onboarding.getStarted.description": string;
|
|
273
|
-
readonly "onboarding.getStarted.buttonText": string;
|
|
274
|
-
readonly "onboarding.getStarted.ariaLabel": string;
|
|
275
|
-
readonly "onboarding.explore.title": string;
|
|
276
|
-
readonly "onboarding.explore.description": string;
|
|
277
|
-
readonly "onboarding.explore.buttonText": string;
|
|
278
|
-
readonly "onboarding.explore.ariaLabel": string;
|
|
279
|
-
readonly "onboarding.learn.title": string;
|
|
280
|
-
readonly "onboarding.learn.description": string;
|
|
281
|
-
readonly "onboarding.learn.buttonText": string;
|
|
282
|
-
readonly "onboarding.learn.ariaLabel": string;
|
|
283
|
-
readonly "entities.title": string;
|
|
284
|
-
readonly "entities.description": string;
|
|
285
|
-
readonly "entities.error": string;
|
|
286
|
-
readonly "entities.close": string;
|
|
287
|
-
readonly "entities.empty": string;
|
|
288
|
-
readonly "entities.fetchError": string;
|
|
289
|
-
readonly "entities.emptyDescription": string;
|
|
290
|
-
readonly "entities.register": string;
|
|
291
|
-
readonly "entities.viewAll": string;
|
|
292
|
-
}>;
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* The translation resource for the Homepage plugin.
|
|
296
|
-
* @public
|
|
297
|
-
*/
|
|
298
|
-
declare const homepageTranslations: _backstage_core_plugin_api_alpha.TranslationResource<"plugin.homepage">;
|
|
299
|
-
|
|
300
|
-
export { Breakpoint, CatalogStarredEntitiesCard, DynamicCustomizableHomePage, type DynamicCustomizableHomePageProps, DynamicHomePage, type DynamicHomePageProps, EntitySection, FeaturedDocsCard, Headline, type HeadlineProps, type HomePageCardMountPoint, type HomePageCardMountPointConfig, JokeCard, type Layout, type LocalClockProps, Markdown, MarkdownCard, type MarkdownCardProps, type MarkdownProps, OnboardingSection, Placeholder, type PlaceholderProps, QuickAccessCard, type QuickAccessCardProps, RecentlyVisitedCard, SearchBar, type SearchBarProps, TemplateSection, TopVisitedCard, VisitListener, WorldClock, type WorldClockProps, dynamicHomePagePlugin, homepageTranslationRef, homepageTranslations };
|
|
244
|
+
export { Breakpoint, CatalogStarredEntitiesCard, DynamicCustomizableHomePage, type DynamicCustomizableHomePageProps, DynamicHomePage, type DynamicHomePageProps, EntitySection, FeaturedDocsCard, Headline, type HeadlineProps, type HomePageCardMountPoint, type HomePageCardMountPointConfig, JokeCard, type Layout, type LocalClockProps, Markdown, MarkdownCard, type MarkdownCardProps, type MarkdownProps, OnboardingSection, Placeholder, type PlaceholderProps, QuickAccessCard, type QuickAccessCardProps, RecentlyVisitedCard, SearchBar, type SearchBarProps, TemplateSection, TopVisitedCard, VisitListener, WorldClock, type WorldClockProps, dynamicHomePagePlugin };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export { CatalogStarredEntitiesCard, DynamicCustomizableHomePage, DynamicHomePage, EntitySection, FeaturedDocsCard, Headline, JokeCard, Markdown, MarkdownCard, OnboardingSection, Placeholder, QuickAccessCard, RecentlyVisitedCard, SearchBar, TemplateSection, TopVisitedCard, VisitListener, WorldClock, dynamicHomePagePlugin } from './plugin.esm.js';
|
|
2
|
-
export { homepageTranslations } from './translations/index.esm.js';
|
|
3
|
-
export { homepageTranslationRef } from './translations/ref.esm.js';
|
|
4
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/translations/index.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTranslationResource } from '@backstage/core-plugin-api/alpha';\n\nimport { homepageTranslationRef } from './ref';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/translations/index.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTranslationResource } from '@backstage/core-plugin-api/alpha';\n\nimport { homepageTranslationRef } from './ref';\n\n/**\n * Translation resource for the Dynamic Home Page plugin (en, de, es, fr, it, ja).\n *\n * @public\n */\nexport const homepageTranslations = createTranslationResource({\n ref: homepageTranslationRef,\n translations: {\n de: () => import('./de'),\n es: () => import('./es'),\n fr: () => import('./fr'),\n it: () => import('./it'),\n ja: () => import('./ja'),\n },\n});\n\nexport { homepageTranslationRef };\n"],"names":[],"mappings":";;;AAyBO,MAAM,uBAAuB,yBAA0B,CAAA;AAAA,EAC5D,GAAK,EAAA,sBAAA;AAAA,EACL,YAAc,EAAA;AAAA,IACZ,EAAA,EAAI,MAAM,OAAO,aAAM,CAAA;AAAA,IACvB,EAAA,EAAI,MAAM,OAAO,aAAM,CAAA;AAAA,IACvB,EAAA,EAAI,MAAM,OAAO,aAAM,CAAA;AAAA,IACvB,EAAA,EAAI,MAAM,OAAO,aAAM,CAAA;AAAA,IACvB,EAAA,EAAI,MAAM,OAAO,aAAM;AAAA;AAE3B,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.esm.js","sources":["../../src/translations/ref.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/**\n * Messages object containing all English translations.\n * This is our single source of truth for translations.\n * @public\n */\nexport const homepageMessages = {\n header: {\n welcome: 'Welcome back!',\n welcomePersonalized: 'Welcome back, {{name}}!',\n local: 'Local',\n },\n homePage: {\n empty: 'No home page cards (mount points) configured or found.',\n },\n search: {\n placeholder: 'Search',\n },\n quickAccess: {\n title: 'Quick Access',\n fetchError: 'Could not fetch data.',\n error: 'Unknown error',\n },\n featuredDocs: {\n learnMore: ' Learn more',\n },\n templates: {\n title: 'Explore Templates',\n fetchError: 'Could not fetch data.',\n error: 'Unknown error',\n empty: 'No templates added yet',\n emptyDescription:\n 'Once templates are added, this space will showcase relevant content tailored to your experience.',\n register: 'Register a template',\n viewAll: 'View all {{count}} templates',\n },\n onboarding: {\n greeting: {\n goodMorning: 'Good morning',\n goodAfternoon: 'Good afternoon',\n goodEvening: 'Good evening',\n },\n guest: 'Guest',\n getStarted: {\n title: 'Get started',\n description: 'Learn about Red Hat Developer Hub.',\n buttonText: 'Read documentation',\n ariaLabel: 'Read documentation (opens in a new tab)',\n },\n explore: {\n title: 'Explore',\n description: 'Explore components, APIs and templates.',\n buttonText: 'Go to Catalog',\n ariaLabel: 'Go to Catalog',\n },\n learn: {\n title: 'Learn',\n description: 'Explore and develop new skills.',\n buttonText: 'Go to Learning Paths',\n ariaLabel: 'Go to Learning Paths',\n },\n },\n entities: {\n title: 'Explore Your Software Catalog',\n fetchError: 'Could not fetch data.',\n error: 'Unknown error',\n description:\n 'Browse the Systems, Components, Resources, and APIs that are available in your organization.',\n close: 'close',\n empty: 'No software catalog added yet',\n emptyDescription:\n 'Once software catalogs are added, this space will showcase relevant content tailored to your experience.',\n register: 'Register a component',\n viewAll: 'View all {{count}} catalog entities',\n },\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"ref.esm.js","sources":["../../src/translations/ref.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/**\n * Messages object containing all English translations.\n * This is our single source of truth for translations.\n *\n * @public\n */\nexport const homepageMessages = {\n header: {\n welcome: 'Welcome back!',\n welcomePersonalized: 'Welcome back, {{name}}!',\n local: 'Local',\n },\n homePage: {\n empty: 'No home page cards (mount points) configured or found.',\n },\n search: {\n placeholder: 'Search',\n },\n quickAccess: {\n title: 'Quick Access',\n fetchError: 'Could not fetch data.',\n error: 'Unknown error',\n },\n featuredDocs: {\n learnMore: ' Learn more',\n },\n templates: {\n title: 'Explore Templates',\n fetchError: 'Could not fetch data.',\n error: 'Unknown error',\n empty: 'No templates added yet',\n emptyDescription:\n 'Once templates are added, this space will showcase relevant content tailored to your experience.',\n register: 'Register a template',\n viewAll: 'View all {{count}} templates',\n },\n onboarding: {\n greeting: {\n goodMorning: 'Good morning',\n goodAfternoon: 'Good afternoon',\n goodEvening: 'Good evening',\n },\n guest: 'Guest',\n getStarted: {\n title: 'Get started',\n description: 'Learn about Red Hat Developer Hub.',\n buttonText: 'Read documentation',\n ariaLabel: 'Read documentation (opens in a new tab)',\n },\n explore: {\n title: 'Explore',\n description: 'Explore components, APIs and templates.',\n buttonText: 'Go to Catalog',\n ariaLabel: 'Go to Catalog',\n },\n learn: {\n title: 'Learn',\n description: 'Explore and develop new skills.',\n buttonText: 'Go to Learning Paths',\n ariaLabel: 'Go to Learning Paths',\n },\n },\n entities: {\n title: 'Explore Your Software Catalog',\n fetchError: 'Could not fetch data.',\n error: 'Unknown error',\n description:\n 'Browse the Systems, Components, Resources, and APIs that are available in your organization.',\n close: 'close',\n empty: 'No software catalog added yet',\n emptyDescription:\n 'Once software catalogs are added, this space will showcase relevant content tailored to your experience.',\n register: 'Register a component',\n viewAll: 'View all {{count}} catalog entities',\n },\n};\n\n/**\n * Translation ref for the Dynamic Home Page plugin.\n * Defines all translation keys used in the plugin.\n *\n * @public\n */\nexport const homepageTranslationRef = createTranslationRef({\n id: 'plugin.homepage',\n messages: homepageMessages,\n});\n"],"names":[],"mappings":";;AAwBO,MAAM,gBAAmB,GAAA;AAAA,EAC9B,MAAQ,EAAA;AAAA,IACN,OAAS,EAAA,eAAA;AAAA,IACT,mBAAqB,EAAA,yBAAA;AAAA,IACrB,KAAO,EAAA;AAAA,GACT;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA;AAAA,GACT;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,WAAa,EAAA;AAAA,GACf;AAAA,EACA,WAAa,EAAA;AAAA,IACX,KAAO,EAAA,cAAA;AAAA,IACP,UAAY,EA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AA;AAAA;AAEb;AAQO,MAAM,yBAAyB,oBAAqB,CAAA;AAAA,EACzD,EAAI,EAAA,iBAAA;AAAA,EACJ,QAAU,EAAA;AACZ,CAAC;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const col = (n) => {
|
|
2
|
+
if (!n) return undefined;
|
|
3
|
+
return `${n / 12 * 100}%`;
|
|
4
|
+
};
|
|
5
|
+
const resolveCol = (current, fallback) => {
|
|
6
|
+
return col(current ?? fallback);
|
|
7
|
+
};
|
|
8
|
+
const containerGridItemSx = ({
|
|
9
|
+
xs = 12,
|
|
10
|
+
sm,
|
|
11
|
+
md,
|
|
12
|
+
lg,
|
|
13
|
+
xl
|
|
14
|
+
}) => ({
|
|
15
|
+
width: col(xs),
|
|
16
|
+
"@container (min-width: 600px)": {
|
|
17
|
+
width: resolveCol(sm, xs)
|
|
18
|
+
},
|
|
19
|
+
"@container (min-width: 900px)": {
|
|
20
|
+
width: resolveCol(md, sm ?? xs)
|
|
21
|
+
},
|
|
22
|
+
"@container (min-width: 1200px)": {
|
|
23
|
+
width: resolveCol(lg, md ?? sm ?? xs)
|
|
24
|
+
},
|
|
25
|
+
"@container (min-width: 1536px)": {
|
|
26
|
+
width: resolveCol(xl, lg ?? md ?? sm ?? xs)
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export { containerGridItemSx };
|
|
31
|
+
//# sourceMappingURL=GridItem.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridItem.esm.js","sources":["../../src/utils/GridItem.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n* Generates an MUI `sx` object for a Grid **item** that supports\n* container-based responsive columns (`xs | sm | md | lg | xl`).\n*\n* This utility mimics MUI Grid's breakpoint inheritance behavior,\n* but uses **CSS Container Queries** instead of viewport media queries.\n*\n* How it works:\n* - Accepts column counts (1–12) per breakpoint\n* - Converts columns into percentage widths\n* - Falls back to the nearest smaller breakpoint if a value is missing\n* - Applies widths using `@container (min-width: ...)` rules\n*\n* Breakpoint mapping:\n* - xs → base width\n* - sm → ≥600px\n* - md → ≥900px\n* - lg → ≥1200px\n* - xl → ≥1536px\n*\n* Example:\n* containerGridItemSx({ xs: 12, sm: 6, md: 4 })\n\n*/\n\n// Breakpoint props (xs / sm / md / lg / xl)\nexport type ContainerGridCols = {\n xs?: number;\n sm?: number;\n md?: number;\n lg?: number;\n xl?: number;\n};\n\n// Convert column count to percentage width\nconst col = (n?: number): string | undefined => {\n if (!n) return undefined;\n return `${(n / 12) * 100}%`;\n};\n\n// Resolve breakpoint value with fallback (MUI-style inheritance)\nconst resolveCol = (\n current?: number,\n fallback?: number,\n): string | undefined => {\n return col(current ?? fallback);\n};\n\n// SX generator for MUI Grid Item using container queries\nexport const containerGridItemSx = ({\n xs = 12,\n sm,\n md,\n lg,\n xl,\n}: ContainerGridCols) => ({\n width: col(xs),\n\n '@container (min-width: 600px)': {\n width: resolveCol(sm, xs),\n },\n\n '@container (min-width: 900px)': {\n width: resolveCol(md, sm ?? xs),\n },\n\n '@container (min-width: 1200px)': {\n width: resolveCol(lg, md ?? sm ?? xs),\n },\n\n '@container (min-width: 1536px)': {\n width: resolveCol(xl, lg ?? md ?? sm ?? xs),\n },\n});\n"],"names":[],"mappings":"AAmDA,MAAM,GAAA,GAAM,CAAC,CAAmC,KAAA;AAC9C,EAAI,IAAA,CAAC,GAAU,OAAA,SAAA;AACf,EAAO,OAAA,CAAA,EAAI,CAAI,GAAA,EAAA,GAAM,GAAG,CAAA,CAAA,CAAA;AAC1B,CAAA;AAGA,MAAM,UAAA,GAAa,CACjB,OAAA,EACA,QACuB,KAAA;AACvB,EAAO,OAAA,GAAA,CAAI,WAAW,QAAQ,CAAA;AAChC,CAAA;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC,EAAK,GAAA,EAAA;AAAA,EACL,EAAA;AAAA,EACA,EAAA;AAAA,EACA,EAAA;AAAA,EACA;AACF,CAA0B,MAAA;AAAA,EACxB,KAAA,EAAO,IAAI,EAAE,CAAA;AAAA,EAEb,+BAAiC,EAAA;AAAA,IAC/B,KAAA,EAAO,UAAW,CAAA,EAAA,EAAI,EAAE;AAAA,GAC1B;AAAA,EAEA,+BAAiC,EAAA;AAAA,IAC/B,KAAO,EAAA,UAAA,CAAW,EAAI,EAAA,EAAA,IAAM,EAAE;AAAA,GAChC;AAAA,EAEA,gCAAkC,EAAA;AAAA,IAChC,KAAO,EAAA,UAAA,CAAW,EAAI,EAAA,EAAA,IAAM,MAAM,EAAE;AAAA,GACtC;AAAA,EAEA,gCAAkC,EAAA;AAAA,IAChC,OAAO,UAAW,CAAA,EAAA,EAAI,EAAM,IAAA,EAAA,IAAM,MAAM,EAAE;AAAA;AAE9C,CAAA;;;;"}
|