@registrucentras/rc-ses-react-components 2.0.0-rc.5 → 2.0.0-rc.6
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/dist/components/common/TitleBlock/types.d.ts +3 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +320 -320
- package/dist/stories/components/display/TitleBlock.stories.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/common/TitleBlock/index.test.tsx +33 -0
- package/src/components/common/TitleBlock/index.tsx +3 -2
- package/src/components/common/TitleBlock/types.ts +3 -1
- package/src/stories/components/display/TitleBlock.stories.tsx +66 -0
|
@@ -16,5 +16,6 @@ export declare const HorizontalTitleBlockWithArrowAndSunkenCardShellTheme: Story
|
|
|
16
16
|
export declare const ClickableHorizontalTitleBlockWithCardShellBase: Story;
|
|
17
17
|
export declare const VerticalTitleBlockWithCardShellBase: Story;
|
|
18
18
|
export declare const VerticalTitleBlock: Story;
|
|
19
|
+
export declare const BodyScaleTitleInCard: Story;
|
|
19
20
|
export declare const MobileViewport: Story;
|
|
20
21
|
export declare const TabletViewport: Story;
|
package/package.json
CHANGED
|
@@ -131,6 +131,39 @@ describe('RcSesTitleBlock', () => {
|
|
|
131
131
|
})
|
|
132
132
|
})
|
|
133
133
|
|
|
134
|
+
test('heading title variants keep the card-header weight', () => {
|
|
135
|
+
const variants = ['h4', 'h5', 'h6'] as const
|
|
136
|
+
|
|
137
|
+
variants.forEach((variant) => {
|
|
138
|
+
const { unmount } = renderTitleBlock(
|
|
139
|
+
<RcSesTitleBlock title={`${variant} Title`} titleVariant={variant} />,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
expect(screen.getByText(`${variant} Title`)).toHaveStyle({ fontWeight: '600' })
|
|
143
|
+
unmount()
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
test('titleVariant="body1" drops the header weight for the body type scale', () => {
|
|
148
|
+
renderTitleBlock(<RcSesTitleBlock title='Test Title' titleVariant='body1' />)
|
|
149
|
+
|
|
150
|
+
expect(screen.getByText('Test Title')).toHaveStyle({
|
|
151
|
+
fontSize: '0.9375rem',
|
|
152
|
+
fontWeight: '400',
|
|
153
|
+
lineHeight: '1.125rem',
|
|
154
|
+
})
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
test('titleVariant="body1" still renders a heading at the requested level', () => {
|
|
158
|
+
renderTitleBlock(
|
|
159
|
+
<RcSesTitleBlock headingLevel={2} title='Test Title' titleVariant='body1' />,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
expect(
|
|
163
|
+
screen.getByRole('heading', { level: 2, name: 'Test Title' }),
|
|
164
|
+
).toBeInTheDocument()
|
|
165
|
+
})
|
|
166
|
+
|
|
134
167
|
test('count renders a badge inside the heading accessible name', () => {
|
|
135
168
|
renderTitleBlock(<RcSesTitleBlock count={4} title='Pasirinktos teisės' />)
|
|
136
169
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Box, Stack, Typography } from '@mui/material'
|
|
2
|
-
import { type ReactNode } from 'react'
|
|
3
2
|
|
|
4
3
|
import RcSesBadge from '@/components/common/Badge'
|
|
5
4
|
import cards from '@/theme/cards'
|
|
@@ -25,6 +24,8 @@ function RcSesTitleBlock({
|
|
|
25
24
|
const hasCount = count !== undefined && count !== null
|
|
26
25
|
const hasDescription = description !== undefined && description !== null
|
|
27
26
|
const isVertical = orientation === 'vertical'
|
|
27
|
+
// The card-header weight belongs to the heading variants only.
|
|
28
|
+
const isHeadingScale = titleVariant !== 'body1'
|
|
28
29
|
|
|
29
30
|
const iconNode = icon ? (
|
|
30
31
|
<Box aria-hidden data-testid={testIds?.icon} sx={{ display: 'flex', flexShrink: 0 }}>
|
|
@@ -42,7 +43,7 @@ function RcSesTitleBlock({
|
|
|
42
43
|
color: titleTone === 'brand' ? palette.primary[700] : palette.grey[900],
|
|
43
44
|
// inline only when the badge has to sit on the heading's last line
|
|
44
45
|
display: hasCount ? 'inline' : 'block',
|
|
45
|
-
fontWeight: cards.header.titleFontWeight,
|
|
46
|
+
fontWeight: isHeadingScale ? cards.header.titleFontWeight : undefined,
|
|
46
47
|
overflowWrap: 'anywhere',
|
|
47
48
|
}}
|
|
48
49
|
>
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from 'react'
|
|
|
2
2
|
|
|
3
3
|
export type TitleBlockHeadingLevel = 2 | 3 | 4 | 5 | 6
|
|
4
4
|
|
|
5
|
-
export type TitleBlockTitleVariant = 'h4' | 'h5' | 'h6'
|
|
5
|
+
export type TitleBlockTitleVariant = 'h4' | 'h5' | 'h6' | 'body1'
|
|
6
6
|
|
|
7
7
|
export type TitleBlockOrientation = 'horizontal' | 'vertical'
|
|
8
8
|
|
|
@@ -22,6 +22,8 @@ export type RcSesTitleBlockBaseProps = {
|
|
|
22
22
|
* Visual size of the title, independent of `headingLevel`. The semantic tag
|
|
23
23
|
* (`headingLevel`) sets document structure; this sets the type scale.
|
|
24
24
|
* Defaults to `h6` (18px).
|
|
25
|
+
* `body1` (15px) draws the title as running copy: body scale, and the
|
|
26
|
+
* type scale's own weight instead of the card-header one.
|
|
25
27
|
*/
|
|
26
28
|
titleVariant?: TitleBlockTitleVariant
|
|
27
29
|
/**
|
|
@@ -427,6 +427,72 @@ export const VerticalTitleBlock: Story = {
|
|
|
427
427
|
),
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
+
// Card title as running body copy: `titleVariant` moves the type scale only,
|
|
431
|
+
// `headingLevel` keeps the heading.
|
|
432
|
+
export const BodyScaleTitleInCard: Story = {
|
|
433
|
+
render: () => {
|
|
434
|
+
const services = [
|
|
435
|
+
{
|
|
436
|
+
id: 'body-scale-title-a',
|
|
437
|
+
title: 'Pažymos apie asmens duomenis Gyventojų registre užsakymas',
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
id: 'body-scale-title-b',
|
|
441
|
+
title: 'Nekilnojamojo turto registro išrašo užsakymas',
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
id: 'body-scale-title-c',
|
|
445
|
+
title: 'Pažymos santuokai sudaryti užsienyje užsakymas',
|
|
446
|
+
},
|
|
447
|
+
]
|
|
448
|
+
|
|
449
|
+
return (
|
|
450
|
+
<Box
|
|
451
|
+
sx={{
|
|
452
|
+
display: 'grid',
|
|
453
|
+
gap: 2,
|
|
454
|
+
gridTemplateColumns: { xs: '1fr', md: 'repeat(3, 1fr)' },
|
|
455
|
+
}}
|
|
456
|
+
>
|
|
457
|
+
{services.map((service) => (
|
|
458
|
+
<RcSesCardShell
|
|
459
|
+
key={service.id}
|
|
460
|
+
variant='card'
|
|
461
|
+
theme='brand'
|
|
462
|
+
fullHeight
|
|
463
|
+
header={
|
|
464
|
+
<RcSesTitleBlock
|
|
465
|
+
headingId={service.id}
|
|
466
|
+
headingLevel={3}
|
|
467
|
+
title={service.title}
|
|
468
|
+
titleVariant='body1'
|
|
469
|
+
titleTone='brand'
|
|
470
|
+
/>
|
|
471
|
+
}
|
|
472
|
+
footer={
|
|
473
|
+
<RcSesCardFooter align='start'>
|
|
474
|
+
<RcSesButton
|
|
475
|
+
id={`${service.id}-order`}
|
|
476
|
+
aria-labelledby={`${service.id}-order ${service.id}`}
|
|
477
|
+
>
|
|
478
|
+
Užsakyti
|
|
479
|
+
</RcSesButton>
|
|
480
|
+
<RcSesButton
|
|
481
|
+
variant='link'
|
|
482
|
+
id={`${service.id}-more`}
|
|
483
|
+
aria-labelledby={`${service.id}-more ${service.id}`}
|
|
484
|
+
>
|
|
485
|
+
Plačiau
|
|
486
|
+
</RcSesButton>
|
|
487
|
+
</RcSesCardFooter>
|
|
488
|
+
}
|
|
489
|
+
/>
|
|
490
|
+
))}
|
|
491
|
+
</Box>
|
|
492
|
+
)
|
|
493
|
+
},
|
|
494
|
+
}
|
|
495
|
+
|
|
430
496
|
// Responsive baselines for SAV-6509 / SAV-6480 DoD ("Responsive patikra 375 /
|
|
431
497
|
// 768 / 1440"). Exercises the mobile stacking of the actions slot
|
|
432
498
|
// (direction={{ xs: 'column', sm: 'row' }}) so both the two-action and
|