Skip to content

Commit

Permalink
[notice] fixed notice.text is not aligned with label, if has no title
Browse files Browse the repository at this point in the history
  • Loading branch information
ksimanov committed Jan 13, 2025
1 parent 5a2da39 commit e29cc61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions semcore/notice/src/Notice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { localizedMessages } from './translations/__intergalactic-dynamic-locale
import i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';
import { cssVariableEnhance } from '@semcore/utils/lib/useCssVariable';
import { Text } from '@semcore/typography';
import findComponent from '@semcore/utils/lib/findComponent';

import style from './style/notice.shadow.css';

Expand Down Expand Up @@ -128,9 +129,11 @@ function Title({ styles }) {
return sstyled(styles)(<STitle render={Text} tag='div' size={300} fontWeight={'bold'} />);
}

function NoticeText({ styles }) {
function NoticeText({ styles, Children }) {
const SText = Root;
return sstyled(styles)(<SText render={Text} tag='div' />);
const withoutTitle = !findComponent(Children, [Notice.Title]);

return sstyled(styles)(<SText render={Text} tag='div' withoutTitle={withoutTitle} />);
}

function Actions({ styles }) {
Expand Down Expand Up @@ -163,7 +166,7 @@ function Close({ styles, getI18nText }) {
);
}

export default createComponent(RootNotice, {
const Notice = createComponent(RootNotice, {
Label,
Title: Title,
Text: NoticeText,
Expand All @@ -172,3 +175,5 @@ export default createComponent(RootNotice, {
CloseIcon,
Close,
});

export default Notice;
5 changes: 5 additions & 0 deletions semcore/notice/src/style/notice.shadow.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,9 @@ STitle {
SText {
margin-top: var(--intergalactic-spacing-05x, 2px);
margin-bottom: var(--intergalactic-spacing-05x, 2px);
}

SText[withoutTitle] {
margin-top: var(--intergalactic-spacing-05x, 2px);
margin-bottom: var(--intergalactic-spacing-05x, 2px);
}

0 comments on commit e29cc61

Please sign in to comment.