@centreon/ui 26.12.4 → 26.12.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "26.12.4",
3
+ "version": "26.12.5",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -51,6 +51,15 @@ export const WithDescription: Story = {
51
51
  render: Default.render
52
52
  };
53
53
 
54
+ export const WithInlineDescription: Story = {
55
+ args: {
56
+ description: 'Configure the hosts monitored by your platform',
57
+ descriptionPosition: 'inline',
58
+ title: 'Hosts'
59
+ },
60
+ render: Default.render
61
+ };
62
+
54
63
  export const WithMenu: Story = {
55
64
  args: {
56
65
  ...WithDescription.args,
@@ -7,9 +7,11 @@ type PageHeaderMainProps = {
7
7
  };
8
8
 
9
9
  const PageHeaderMain = ({ children }: PageHeaderMainProps): ReactElement => {
10
- const { classes } = useStyles();
10
+ const { classes, cx } = useStyles();
11
11
 
12
- return <div className={classes.pageHeaderMain}>{children}</div>;
12
+ return (
13
+ <div className={cx(classes.pageHeaderMain, 'min-w-0')}>{children}</div>
14
+ );
13
15
  };
14
16
 
15
17
  export { PageHeaderMain };
@@ -8,37 +8,80 @@ import { useStyles } from './PageHeader.styles';
8
8
  type PageHeaderTitleProps = {
9
9
  actions?: ReactNode;
10
10
  description?: string;
11
+ descriptionPosition?: 'below' | 'inline';
11
12
  title: string;
12
13
  };
13
14
 
14
15
  const PageHeaderTitle = ({
15
16
  actions,
16
17
  title,
17
- description
18
+ description,
19
+ descriptionPosition = 'below'
18
20
  }: PageHeaderTitleProps): ReactElement => {
19
21
  const { classes } = useStyles();
20
22
 
23
+ const isInline = descriptionPosition === 'inline';
24
+
25
+ const descriptionElement = description && (
26
+ <TextOverflowTooltip label={description}>
27
+ <MuiTypography
28
+ aria-label="page header description"
29
+ className={classes.pageHeaderTitleDescription}
30
+ variant="body2"
31
+ >
32
+ {description}
33
+ </MuiTypography>
34
+ </TextOverflowTooltip>
35
+ );
36
+
37
+ // Inline, the title owns its typography: the `pageHeaderTitle` rules that
38
+ // style the `h1` of the stacked layout only apply to that layout.
39
+ const titleElement = isInline ? (
40
+ <MuiTypography
41
+ aria-label="page header title"
42
+ className="m-0 shrink-0 font-bold leading-none"
43
+ component="h1"
44
+ variant="h5"
45
+ >
46
+ {title}
47
+ </MuiTypography>
48
+ ) : (
49
+ <MuiTypography aria-label="page header title" variant="h1">
50
+ {title}
51
+ </MuiTypography>
52
+ );
53
+
54
+ const actionsElement = actions && (
55
+ <div className={classes.pageHeaderTitleActions}>{actions}</div>
56
+ );
57
+
58
+ if (isInline) {
59
+ return (
60
+ <div className="flex min-w-0 items-baseline gap-4 self-start">
61
+ {titleElement}
62
+ {description && (
63
+ <>
64
+ <span
65
+ aria-hidden
66
+ className="shrink-0 text-2xl font-light leading-none text-header-page-description"
67
+ >
68
+ |
69
+ </span>
70
+ <div className="min-w-0">{descriptionElement}</div>
71
+ </>
72
+ )}
73
+ {actionsElement}
74
+ </div>
75
+ );
76
+ }
77
+
21
78
  return (
22
79
  <div className={classes.pageHeaderTitle}>
23
80
  <span>
24
- <MuiTypography aria-label="page header title" variant="h1">
25
- {title}
26
- </MuiTypography>
27
- {actions && (
28
- <div className={classes.pageHeaderTitleActions}>{actions}</div>
29
- )}
81
+ {titleElement}
82
+ {actionsElement}
30
83
  </span>
31
- {description && (
32
- <TextOverflowTooltip label={description}>
33
- <MuiTypography
34
- aria-label="page header description"
35
- className={classes.pageHeaderTitleDescription}
36
- variant="body2"
37
- >
38
- {description}
39
- </MuiTypography>
40
- </TextOverflowTooltip>
41
- )}
84
+ {descriptionElement}
42
85
  </div>
43
86
  );
44
87
  };