@redneckz/wildless-cms-uni-blocks 0.10.7 → 0.10.8
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/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +59 -40
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/CarouselRecommendationCard/CarouselRecommendationCard.mobile.d.ts +5 -0
- package/bundle/components/CarouselRecommendationCard/cardStyle.d.ts +1 -0
- package/bundle/components/CarouselTariffsCard/getPaddingStyle.d.ts +1 -1
- package/bundle/components/Tabs/CenteredTabs.d.ts +7 -0
- package/bundle/components/Tabs/LinkTab.d.ts +2 -2
- package/bundle/components/Tabs/TabsContent.d.ts +3 -2
- package/bundle/components/Tabs/renderGroupTab.d.ts +2 -2
- package/bundle/components/Tabs/renderTab.d.ts +3 -3
- package/bundle/components/Tabs/tabItemClasses.d.ts +3 -2
- package/dist/components/Blocks.mobile.js +2 -0
- package/dist/components/Blocks.mobile.js.map +1 -1
- package/dist/components/CarouselRecommendationCard/CarouselRecommendationCard.js +2 -2
- package/dist/components/CarouselRecommendationCard/CarouselRecommendationCard.js.map +1 -1
- package/dist/components/CarouselRecommendationCard/CarouselRecommendationCard.mobile.d.ts +5 -0
- package/dist/components/CarouselRecommendationCard/CarouselRecommendationCard.mobile.js +17 -0
- package/dist/components/CarouselRecommendationCard/CarouselRecommendationCard.mobile.js.map +1 -0
- package/dist/components/CarouselRecommendationCard/cardStyle.d.ts +1 -0
- package/dist/components/CarouselRecommendationCard/cardStyle.js +4 -0
- package/dist/components/CarouselRecommendationCard/cardStyle.js.map +1 -0
- package/dist/components/CarouselTariffsCard/getPaddingStyle.d.ts +1 -1
- package/dist/components/CarouselTariffsCard/getPaddingStyle.js +1 -1
- package/dist/components/CarouselTariffsCard/getPaddingStyle.js.map +1 -1
- package/dist/components/CarouselTariffsCard/getPaddingStyle.mobile.js +1 -1
- package/dist/components/CarouselTariffsCard/getPaddingStyle.mobile.js.map +1 -1
- package/dist/components/Footer/Footer.mobile.js +1 -1
- package/dist/components/Footer/Footer.mobile.js.map +1 -1
- package/dist/components/Footer/SocialMedia.mobile.js +1 -1
- package/dist/components/Footer/SocialMedia.mobile.js.map +1 -1
- package/dist/components/Tabs/CenteredTabs.d.ts +7 -0
- package/dist/components/Tabs/CenteredTabs.js +7 -0
- package/dist/components/Tabs/CenteredTabs.js.map +1 -0
- package/dist/components/Tabs/LinkTab.d.ts +2 -2
- package/dist/components/Tabs/LinkTab.js +2 -2
- package/dist/components/Tabs/LinkTab.js.map +1 -1
- package/dist/components/Tabs/ScrollableTabs.js +3 -9
- package/dist/components/Tabs/ScrollableTabs.js.map +1 -1
- package/dist/components/Tabs/Tabs.js +14 -7
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tabs/TabsContent.d.ts +3 -2
- package/dist/components/Tabs/renderGroupTab.d.ts +2 -2
- package/dist/components/Tabs/renderGroupTab.js +4 -4
- package/dist/components/Tabs/renderGroupTab.js.map +1 -1
- package/dist/components/Tabs/renderTab.d.ts +3 -3
- package/dist/components/Tabs/renderTab.js +3 -3
- package/dist/components/Tabs/renderTab.js.map +1 -1
- package/dist/components/Tabs/tabItemClasses.d.ts +3 -2
- package/dist/components/Tabs/tabItemClasses.js +26 -10
- package/dist/components/Tabs/tabItemClasses.js.map +1 -1
- package/dist/hooks/useLink.js +1 -1
- package/dist/hooks/useLink.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/Blocks.mobile.js +2 -0
- package/lib/components/Blocks.mobile.js.map +1 -1
- package/lib/components/CarouselRecommendationCard/CarouselRecommendationCard.fixture.mobile.d.ts +16 -0
- package/lib/components/CarouselRecommendationCard/CarouselRecommendationCard.js +1 -1
- package/lib/components/CarouselRecommendationCard/CarouselRecommendationCard.js.map +1 -1
- package/lib/components/CarouselRecommendationCard/CarouselRecommendationCard.mobile.d.ts +5 -0
- package/lib/components/CarouselRecommendationCard/CarouselRecommendationCard.mobile.js +15 -0
- package/lib/components/CarouselRecommendationCard/CarouselRecommendationCard.mobile.js.map +1 -0
- package/lib/components/CarouselRecommendationCard/cardStyle.d.ts +1 -0
- package/lib/components/CarouselRecommendationCard/cardStyle.js +2 -0
- package/lib/components/CarouselRecommendationCard/cardStyle.js.map +1 -0
- package/lib/components/CarouselTariffsCard/getPaddingStyle.d.ts +1 -1
- package/lib/components/CarouselTariffsCard/getPaddingStyle.js +1 -1
- package/lib/components/CarouselTariffsCard/getPaddingStyle.js.map +1 -1
- package/lib/components/CarouselTariffsCard/getPaddingStyle.mobile.js +1 -1
- package/lib/components/CarouselTariffsCard/getPaddingStyle.mobile.js.map +1 -1
- package/lib/components/Footer/Footer.mobile.js +1 -1
- package/lib/components/Footer/Footer.mobile.js.map +1 -1
- package/lib/components/Footer/SocialMedia.mobile.js +1 -1
- package/lib/components/Footer/SocialMedia.mobile.js.map +1 -1
- package/lib/components/Tabs/CenteredTabs.d.ts +7 -0
- package/lib/components/Tabs/CenteredTabs.js +5 -0
- package/lib/components/Tabs/CenteredTabs.js.map +1 -0
- package/lib/components/Tabs/LinkTab.d.ts +2 -2
- package/lib/components/Tabs/LinkTab.js +2 -2
- package/lib/components/Tabs/LinkTab.js.map +1 -1
- package/lib/components/Tabs/ScrollableTabs.js +3 -9
- package/lib/components/Tabs/ScrollableTabs.js.map +1 -1
- package/lib/components/Tabs/Tabs.fixture.d.ts +1 -0
- package/lib/components/Tabs/Tabs.js +14 -7
- package/lib/components/Tabs/Tabs.js.map +1 -1
- package/lib/components/Tabs/TabsContent.d.ts +3 -2
- package/lib/components/Tabs/renderGroupTab.d.ts +2 -2
- package/lib/components/Tabs/renderGroupTab.js +5 -5
- package/lib/components/Tabs/renderGroupTab.js.map +1 -1
- package/lib/components/Tabs/renderTab.d.ts +3 -3
- package/lib/components/Tabs/renderTab.js +3 -3
- package/lib/components/Tabs/renderTab.js.map +1 -1
- package/lib/components/Tabs/tabItemClasses.d.ts +3 -2
- package/lib/components/Tabs/tabItemClasses.js +26 -10
- package/lib/components/Tabs/tabItemClasses.js.map +1 -1
- package/lib/hooks/useLink.js +1 -1
- package/lib/hooks/useLink.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +143 -135
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/CarouselRecommendationCard/cardStyle.d.ts +1 -0
- package/mobile/bundle/components/Tabs/CenteredTabs.d.ts +7 -0
- package/mobile/bundle/components/Tabs/LinkTab.d.ts +2 -2
- package/mobile/bundle/components/Tabs/TabsContent.d.ts +3 -2
- package/mobile/bundle/components/Tabs/renderGroupTab.d.ts +2 -2
- package/mobile/bundle/components/Tabs/renderTab.d.ts +3 -3
- package/mobile/bundle/components/Tabs/tabItemClasses.d.ts +3 -2
- package/mobile/dist/components/Blocks.js +2 -0
- package/mobile/dist/components/Blocks.js.map +1 -1
- package/mobile/dist/components/CarouselRecommendationCard/CarouselRecommendationCard.js +4 -4
- package/mobile/dist/components/CarouselRecommendationCard/CarouselRecommendationCard.js.map +1 -1
- package/mobile/dist/components/CarouselRecommendationCard/cardStyle.d.ts +1 -0
- package/mobile/dist/components/CarouselRecommendationCard/cardStyle.js +4 -0
- package/mobile/dist/components/CarouselRecommendationCard/cardStyle.js.map +1 -0
- package/mobile/dist/components/CarouselTariffsCard/getPaddingStyle.js +1 -1
- package/mobile/dist/components/CarouselTariffsCard/getPaddingStyle.js.map +1 -1
- package/mobile/dist/components/Footer/Footer.js +1 -1
- package/mobile/dist/components/Footer/Footer.js.map +1 -1
- package/mobile/dist/components/Footer/SocialMedia.js +1 -1
- package/mobile/dist/components/Footer/SocialMedia.js.map +1 -1
- package/mobile/dist/components/Tabs/CenteredTabs.d.ts +7 -0
- package/mobile/dist/components/Tabs/CenteredTabs.js +7 -0
- package/mobile/dist/components/Tabs/CenteredTabs.js.map +1 -0
- package/mobile/dist/components/Tabs/LinkTab.d.ts +2 -2
- package/mobile/dist/components/Tabs/LinkTab.js +2 -2
- package/mobile/dist/components/Tabs/LinkTab.js.map +1 -1
- package/mobile/dist/components/Tabs/ScrollableTabs.js +3 -9
- package/mobile/dist/components/Tabs/ScrollableTabs.js.map +1 -1
- package/mobile/dist/components/Tabs/Tabs.js +14 -7
- package/mobile/dist/components/Tabs/Tabs.js.map +1 -1
- package/mobile/dist/components/Tabs/TabsContent.d.ts +3 -2
- package/mobile/dist/components/Tabs/renderGroupTab.d.ts +2 -2
- package/mobile/dist/components/Tabs/renderGroupTab.js +4 -4
- package/mobile/dist/components/Tabs/renderGroupTab.js.map +1 -1
- package/mobile/dist/components/Tabs/renderTab.d.ts +3 -3
- package/mobile/dist/components/Tabs/renderTab.js +3 -3
- package/mobile/dist/components/Tabs/renderTab.js.map +1 -1
- package/mobile/dist/components/Tabs/tabItemClasses.d.ts +3 -2
- package/mobile/dist/components/Tabs/tabItemClasses.js +26 -10
- package/mobile/dist/components/Tabs/tabItemClasses.js.map +1 -1
- package/mobile/dist/hooks/useLink.js +1 -1
- package/mobile/dist/hooks/useLink.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/Blocks.js +2 -0
- package/mobile/lib/components/Blocks.js.map +1 -1
- package/mobile/lib/components/CarouselRecommendationCard/CarouselRecommendationCard.js +4 -4
- package/mobile/lib/components/CarouselRecommendationCard/CarouselRecommendationCard.js.map +1 -1
- package/mobile/lib/components/CarouselRecommendationCard/cardStyle.d.ts +1 -0
- package/mobile/lib/components/CarouselRecommendationCard/cardStyle.js +2 -0
- package/mobile/lib/components/CarouselRecommendationCard/cardStyle.js.map +1 -0
- package/mobile/lib/components/CarouselTariffsCard/getPaddingStyle.js +1 -1
- package/mobile/lib/components/CarouselTariffsCard/getPaddingStyle.js.map +1 -1
- package/mobile/lib/components/Footer/Footer.js +1 -1
- package/mobile/lib/components/Footer/Footer.js.map +1 -1
- package/mobile/lib/components/Footer/SocialMedia.js +1 -1
- package/mobile/lib/components/Footer/SocialMedia.js.map +1 -1
- package/mobile/lib/components/Tabs/CenteredTabs.d.ts +7 -0
- package/mobile/lib/components/Tabs/CenteredTabs.js +5 -0
- package/mobile/lib/components/Tabs/CenteredTabs.js.map +1 -0
- package/mobile/lib/components/Tabs/LinkTab.d.ts +2 -2
- package/mobile/lib/components/Tabs/LinkTab.js +2 -2
- package/mobile/lib/components/Tabs/LinkTab.js.map +1 -1
- package/mobile/lib/components/Tabs/ScrollableTabs.js +3 -9
- package/mobile/lib/components/Tabs/ScrollableTabs.js.map +1 -1
- package/mobile/lib/components/Tabs/Tabs.js +14 -7
- package/mobile/lib/components/Tabs/Tabs.js.map +1 -1
- package/mobile/lib/components/Tabs/TabsContent.d.ts +3 -2
- package/mobile/lib/components/Tabs/renderGroupTab.d.ts +2 -2
- package/mobile/lib/components/Tabs/renderGroupTab.js +5 -5
- package/mobile/lib/components/Tabs/renderGroupTab.js.map +1 -1
- package/mobile/lib/components/Tabs/renderTab.d.ts +3 -3
- package/mobile/lib/components/Tabs/renderTab.js +3 -3
- package/mobile/lib/components/Tabs/renderTab.js.map +1 -1
- package/mobile/lib/components/Tabs/tabItemClasses.d.ts +3 -2
- package/mobile/lib/components/Tabs/tabItemClasses.js +26 -10
- package/mobile/lib/components/Tabs/tabItemClasses.js.map +1 -1
- package/mobile/lib/hooks/useLink.js +1 -1
- package/mobile/lib/hooks/useLink.js.map +1 -1
- package/mobile/src/components/Blocks.ts +2 -0
- package/mobile/src/components/CarouselRecommendationCard/CarouselRecommendationCard.tsx +14 -20
- package/mobile/src/components/CarouselRecommendationCard/cardStyle.ts +2 -0
- package/mobile/src/components/CarouselTariffsCard/getPaddingStyle.tsx +2 -2
- package/mobile/src/components/Footer/Footer.tsx +1 -1
- package/mobile/src/components/Footer/SocialMedia.tsx +1 -1
- package/mobile/src/components/Tabs/CenteredTabs.tsx +12 -0
- package/mobile/src/components/Tabs/LinkTab.tsx +5 -5
- package/mobile/src/components/Tabs/ScrollableTabs.tsx +5 -13
- package/mobile/src/components/Tabs/Tabs.tsx +21 -19
- package/mobile/src/components/Tabs/TabsContent.ts +3 -2
- package/mobile/src/components/Tabs/renderGroupTab.tsx +11 -10
- package/mobile/src/components/Tabs/renderTab.tsx +5 -13
- package/mobile/src/components/Tabs/tabItemClasses.ts +28 -10
- package/mobile/src/hooks/useLink.ts +1 -1
- package/package.json +1 -1
- package/src/components/Blocks.mobile.ts +2 -0
- package/src/components/CarouselRecommendationCard/CarouselRecommendationCard.fixture.mobile.tsx +148 -0
- package/src/components/CarouselRecommendationCard/CarouselRecommendationCard.mobile.tsx +63 -0
- package/src/components/CarouselRecommendationCard/CarouselRecommendationCard.tsx +1 -3
- package/src/components/CarouselRecommendationCard/cardStyle.ts +2 -0
- package/src/components/CarouselTariffsCard/getPaddingStyle.mobile.tsx +2 -2
- package/src/components/CarouselTariffsCard/getPaddingStyle.tsx +1 -1
- package/src/components/Footer/Footer.mobile.tsx +1 -1
- package/src/components/Footer/SocialMedia.mobile.tsx +1 -1
- package/src/components/Tabs/CenteredTabs.tsx +12 -0
- package/src/components/Tabs/LinkTab.tsx +5 -5
- package/src/components/Tabs/ScrollableTabs.tsx +5 -13
- package/src/components/Tabs/Tabs.fixture.tsx +27 -0
- package/src/components/Tabs/Tabs.tsx +21 -19
- package/src/components/Tabs/TabsContent.ts +3 -2
- package/src/components/Tabs/renderGroupTab.tsx +11 -10
- package/src/components/Tabs/renderTab.tsx +5 -13
- package/src/components/Tabs/tabItemClasses.ts +28 -10
- package/src/hooks/useLink.ts +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import { useLink } from '../../hooks/useLink';
|
|
3
3
|
import { getLinkTabClassName } from './tabItemClasses';
|
|
4
|
-
import type { LinkTabData, TabData } from './TabsContent';
|
|
4
|
+
import type { LinkTabData, TabData, TabsMode } from './TabsContent';
|
|
5
5
|
|
|
6
6
|
interface LinkTabProps {
|
|
7
7
|
tab: LinkTabData;
|
|
8
8
|
currentTab?: TabData;
|
|
9
|
-
isScrollable?: boolean;
|
|
10
9
|
onClick: (tab: TabData) => void;
|
|
10
|
+
tabsMode?: TabsMode;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const LinkTab = JSX<LinkTabProps>((props) => {
|
|
14
|
-
const { tab, currentTab, onClick,
|
|
14
|
+
const { tab, currentTab, onClick, tabsMode } = props;
|
|
15
15
|
const active = currentTab?.type === 'link' && currentTab.href === tab.href;
|
|
16
16
|
|
|
17
17
|
const link = useLink();
|
|
@@ -25,12 +25,12 @@ export const LinkTab = JSX<LinkTabProps>((props) => {
|
|
|
25
25
|
return (
|
|
26
26
|
<a
|
|
27
27
|
role="tab"
|
|
28
|
-
className={getLinkTabClassName('link', active,
|
|
28
|
+
className={getLinkTabClassName('link', active, tabsMode)}
|
|
29
29
|
target={tab.target}
|
|
30
30
|
href={adjustedProps.href}
|
|
31
31
|
onClick={handleClick}
|
|
32
32
|
>
|
|
33
|
-
<span className={getLinkTabClassName('text', active,
|
|
33
|
+
<span className={getLinkTabClassName('text', active, tabsMode)}>{tab.text}</span>
|
|
34
34
|
</a>
|
|
35
35
|
);
|
|
36
36
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import
|
|
3
|
-
import type { TabData } from './TabsContent';
|
|
2
|
+
import { ScrollLeftButton, ScrollRightButton } from '../../ui-kit/Button/ArrowButton';
|
|
4
3
|
import { SwipeListContainer } from '../../ui-kit/SwipeListControl/SwipeListContainer';
|
|
5
4
|
import { useSwipeListScroll } from '../../ui-kit/SwipeListControl/useSwipeListScroll';
|
|
6
|
-
import {
|
|
5
|
+
import type { RenderTabProps } from './renderTab';
|
|
7
6
|
import { renderTab } from './renderTab';
|
|
7
|
+
import type { TabData } from './TabsContent';
|
|
8
8
|
|
|
9
9
|
interface ScrollableTabsProps extends RenderTabProps {
|
|
10
10
|
tabs?: TabData[];
|
|
@@ -15,7 +15,7 @@ export type IsScrollButtonsShown = boolean[];
|
|
|
15
15
|
const scrollButtonStyle = 'absolute z-40 top-0';
|
|
16
16
|
|
|
17
17
|
export const ScrollableTabs = JSX<ScrollableTabsProps>((props) => {
|
|
18
|
-
const { tabs,
|
|
18
|
+
const { tabs, ...rest } = props;
|
|
19
19
|
|
|
20
20
|
const [containerRef, scroll] = useSwipeListScroll<HTMLDivElement>({
|
|
21
21
|
itemCount: tabs?.length || 0,
|
|
@@ -30,15 +30,7 @@ export const ScrollableTabs = JSX<ScrollableTabsProps>((props) => {
|
|
|
30
30
|
snapAlign="snap-start"
|
|
31
31
|
onVisibleIndicesChange={scroll.handleVisibleIndicesChange}
|
|
32
32
|
>
|
|
33
|
-
{tabs?.map(
|
|
34
|
-
renderTab({
|
|
35
|
-
onClick,
|
|
36
|
-
currentTab,
|
|
37
|
-
showCounter,
|
|
38
|
-
page,
|
|
39
|
-
isScrollable: true,
|
|
40
|
-
}),
|
|
41
|
-
)}
|
|
33
|
+
{tabs?.map(renderTab({ ...rest }))}
|
|
42
34
|
</SwipeListContainer>
|
|
43
35
|
</div>
|
|
44
36
|
{scroll.canScrollLeft ? (
|
|
@@ -12,6 +12,7 @@ export default {
|
|
|
12
12
|
{ type: 'link', href: 'https://google.com', text: 'Вкладка 3' },
|
|
13
13
|
{ type: 'group', ref: 'tab3', title: 'Вкладка 4' },
|
|
14
14
|
]}
|
|
15
|
+
tabsMode="wideScreen"
|
|
15
16
|
/>
|
|
16
17
|
</div>
|
|
17
18
|
),
|
|
@@ -36,4 +37,30 @@ export default {
|
|
|
36
37
|
/>
|
|
37
38
|
</div>
|
|
38
39
|
),
|
|
40
|
+
centered: (
|
|
41
|
+
<div className="container grid grid-cols-12">
|
|
42
|
+
<Tabs
|
|
43
|
+
className="col-span-12"
|
|
44
|
+
tabs={[
|
|
45
|
+
{ type: 'group', ref: 'tab1', title: '2021' },
|
|
46
|
+
{ type: 'link', href: 'https://google.com', text: '2020' },
|
|
47
|
+
{ type: 'group', ref: 'tab3', title: '2019' },
|
|
48
|
+
{ type: 'link', href: 'https://yandex.com', text: '2018' },
|
|
49
|
+
{ type: 'group', ref: 'tab5', title: '2017' },
|
|
50
|
+
{ type: 'link', href: 'https://ya.com', text: '2016' },
|
|
51
|
+
{ type: 'link', href: 'https://habr.com', text: '2014' },
|
|
52
|
+
{ type: 'group', ref: 'tab3', title: '2013' },
|
|
53
|
+
{ type: 'link', href: 'https://kremlin.com', text: '2012' },
|
|
54
|
+
{ type: 'group', ref: 'tab5', title: '2011' },
|
|
55
|
+
{ type: 'link', href: 'https://ria.com', text: '2009' },
|
|
56
|
+
{ type: 'group', ref: 'tab8', title: '2008' },
|
|
57
|
+
{ type: 'group', ref: 'tab8', title: '2007' },
|
|
58
|
+
{ type: 'group', ref: 'tab8', title: '2006' },
|
|
59
|
+
{ type: 'group', ref: 'tab8', title: '2005' },
|
|
60
|
+
{ type: 'group', ref: 'tab8', title: '2004' },
|
|
61
|
+
]}
|
|
62
|
+
tabsMode="centered"
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
),
|
|
39
66
|
};
|
|
@@ -3,14 +3,20 @@ import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
|
3
3
|
import { defaultEventBus } from '../../EventBus/defaultEventBus';
|
|
4
4
|
import type { UniBlockProps } from '../../model/JSXBlock';
|
|
5
5
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
6
|
+
import { CenteredTabs } from './CenteredTabs';
|
|
6
7
|
import { renderTab } from './renderTab';
|
|
7
8
|
import { ScrollableTabs } from './ScrollableTabs';
|
|
8
9
|
import type { TabData, TabsContent } from './TabsContent';
|
|
9
10
|
|
|
10
11
|
export interface TabsBlockProps extends TabsContent, UniBlockProps {}
|
|
11
12
|
|
|
13
|
+
interface RenderTabsProps extends TabsBlockProps {
|
|
14
|
+
currentTab?: TabData;
|
|
15
|
+
onClick: (tab: TabData) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
export const Tabs = JSX<TabsBlockProps>((props) => {
|
|
13
|
-
const { className = '', tabs,
|
|
19
|
+
const { className = '', tabs, isSticky, ...rest } = props;
|
|
14
20
|
|
|
15
21
|
const [currentTab, setCurrentTab] = useState(tabs ? tabs[0] : undefined);
|
|
16
22
|
|
|
@@ -41,28 +47,24 @@ export const Tabs = JSX<TabsBlockProps>((props) => {
|
|
|
41
47
|
role="tablist"
|
|
42
48
|
{...rest}
|
|
43
49
|
>
|
|
44
|
-
{
|
|
45
|
-
<ScrollableTabs
|
|
46
|
-
tabs={tabs}
|
|
47
|
-
onClick={handleClick}
|
|
48
|
-
currentTab={currentTab}
|
|
49
|
-
showCounter={showCounter}
|
|
50
|
-
{...rest}
|
|
51
|
-
/>
|
|
52
|
-
) : (
|
|
53
|
-
tabs?.map(
|
|
54
|
-
renderTab({
|
|
55
|
-
onClick: handleClick,
|
|
56
|
-
currentTab,
|
|
57
|
-
showCounter,
|
|
58
|
-
...rest,
|
|
59
|
-
}),
|
|
60
|
-
)
|
|
61
|
-
)}
|
|
50
|
+
{renderTabs({ tabs, onClick: handleClick, currentTab, ...rest })}
|
|
62
51
|
</BlockWrapper>
|
|
63
52
|
);
|
|
64
53
|
});
|
|
65
54
|
|
|
55
|
+
const renderTabs = ({ tabsMode, tabs, ...rest }: RenderTabsProps) => {
|
|
56
|
+
switch (tabsMode) {
|
|
57
|
+
case 'wideScreen':
|
|
58
|
+
return tabs?.map(renderTab({ tabsMode, ...rest }));
|
|
59
|
+
case 'centered':
|
|
60
|
+
return <CenteredTabs tabs={tabs} tabsMode={tabsMode} {...rest} />;
|
|
61
|
+
case 'scrollable':
|
|
62
|
+
return <ScrollableTabs tabs={tabs} tabsMode={tabsMode} {...rest} />;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
67
|
+
|
|
66
68
|
const fireTabEvent = (tab: TabData) => {
|
|
67
69
|
if (tab.type === 'group') {
|
|
68
70
|
defaultEventBus.fire('tab', { type: tab.type, label: tab.ref });
|
|
@@ -31,10 +31,11 @@ export type TabData = GroupTabData | LinkTabData;
|
|
|
31
31
|
/**
|
|
32
32
|
* @enumNames [
|
|
33
33
|
* "По ширине экрана",
|
|
34
|
-
* "С прокруткой"
|
|
34
|
+
* "С прокруткой",
|
|
35
|
+
* "По центру"
|
|
35
36
|
* ]
|
|
36
37
|
*/
|
|
37
|
-
export type TabsMode = 'wideScreen' | 'scrollable';
|
|
38
|
+
export type TabsMode = 'wideScreen' | 'scrollable' | 'centered';
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* @title Вкладки
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { GroupTabData } from './TabsContent';
|
|
2
1
|
import type { RenderTabProps } from './renderTab';
|
|
3
2
|
import {
|
|
4
3
|
ACTIVE_TEXT_CLASSES,
|
|
4
|
+
getGroupTabClassName,
|
|
5
5
|
INACTIVE_TEXT_CLASSES,
|
|
6
6
|
TEXT_CLASSES,
|
|
7
7
|
WHITE_ACTIVE_TEXT_CLASSES,
|
|
8
|
-
getGroupTabClassName,
|
|
9
8
|
} from './tabItemClasses';
|
|
9
|
+
import type { GroupTabData, TabsMode } from './TabsContent';
|
|
10
10
|
|
|
11
11
|
const BADGE_CLASSES =
|
|
12
12
|
'min-w-[22px] h-[22px] rounded-full text-xs ml-2 flex justify-center items-center';
|
|
@@ -15,7 +15,7 @@ const INACTIVE_BADGE_CLASSES =
|
|
|
15
15
|
'bg-main-divider text-secondary-text group-hover/btn:text-primary-main';
|
|
16
16
|
|
|
17
17
|
export const renderGroupTab =
|
|
18
|
-
({ page, currentTab, showCounter, onClick,
|
|
18
|
+
({ page, currentTab, showCounter, onClick, tabsMode }: RenderTabProps) =>
|
|
19
19
|
(tab: GroupTabData, i: number) => {
|
|
20
20
|
const active = currentTab === tab;
|
|
21
21
|
|
|
@@ -27,7 +27,7 @@ export const renderGroupTab =
|
|
|
27
27
|
return (
|
|
28
28
|
<div
|
|
29
29
|
key={`group-${String(i)}`}
|
|
30
|
-
className={getGroupTabClassName('div', active,
|
|
30
|
+
className={getGroupTabClassName('div', active, tabsMode)}
|
|
31
31
|
role="tab"
|
|
32
32
|
aria-selected={active}
|
|
33
33
|
onClick={() => onClick(tab)}
|
|
@@ -36,21 +36,22 @@ export const renderGroupTab =
|
|
|
36
36
|
className={`flex flex-1 items-center justify-center ${getGroupTabClassName(
|
|
37
37
|
'text',
|
|
38
38
|
active,
|
|
39
|
-
|
|
39
|
+
tabsMode,
|
|
40
40
|
)}`}
|
|
41
41
|
>
|
|
42
|
-
{renderTitle(tab.title, active,
|
|
42
|
+
{renderTitle(tab.title, active, tabsMode)}
|
|
43
43
|
{renderCount(showCounter, count, active)}
|
|
44
44
|
</div>
|
|
45
45
|
</div>
|
|
46
46
|
);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
const renderTitle = (title: string | undefined, active: boolean,
|
|
49
|
+
const renderTitle = (title: string | undefined, active: boolean, tabsMode?: TabsMode) => {
|
|
50
50
|
const activeClassName = active ? WHITE_ACTIVE_TEXT_CLASSES : INACTIVE_TEXT_CLASSES;
|
|
51
|
-
const titleClassName =
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
const titleClassName =
|
|
52
|
+
tabsMode === 'scrollable'
|
|
53
|
+
? `${TEXT_CLASSES} ${activeClassName}`
|
|
54
|
+
: `${TEXT_CLASSES} ${active ? ACTIVE_TEXT_CLASSES : INACTIVE_TEXT_CLASSES}`;
|
|
54
55
|
|
|
55
56
|
return title ? <h3 className={titleClassName}>{title}</h3> : null;
|
|
56
57
|
};
|
|
@@ -2,18 +2,18 @@ import type { ContentPageDef } from '../../model/ContentPageDef';
|
|
|
2
2
|
import { assertUnreachable } from '../../utils/assertUnreachable';
|
|
3
3
|
import { LinkTab } from './LinkTab';
|
|
4
4
|
import { renderGroupTab } from './renderGroupTab';
|
|
5
|
-
import type { TabData } from './TabsContent';
|
|
5
|
+
import type { TabData, TabsMode } from './TabsContent';
|
|
6
6
|
|
|
7
7
|
export interface RenderTabProps {
|
|
8
8
|
page?: ContentPageDef;
|
|
9
9
|
currentTab?: TabData;
|
|
10
10
|
showCounter?: boolean;
|
|
11
11
|
onClick: (tab: TabData) => void;
|
|
12
|
-
|
|
12
|
+
tabsMode?: TabsMode;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const renderTab =
|
|
16
|
-
({ page,
|
|
16
|
+
({ page, showCounter, ...rest }: RenderTabProps) =>
|
|
17
17
|
(tab: TabData, i: number) => {
|
|
18
18
|
const type = tab.type;
|
|
19
19
|
|
|
@@ -23,17 +23,9 @@ export const renderTab =
|
|
|
23
23
|
|
|
24
24
|
switch (type) {
|
|
25
25
|
case 'group':
|
|
26
|
-
return renderGroupTab({ page,
|
|
26
|
+
return renderGroupTab({ page, showCounter, ...rest })(tab, i);
|
|
27
27
|
case 'link': {
|
|
28
|
-
return (
|
|
29
|
-
<LinkTab
|
|
30
|
-
key={String(i)}
|
|
31
|
-
tab={tab}
|
|
32
|
-
currentTab={currentTab}
|
|
33
|
-
isScrollable={isScrollable}
|
|
34
|
-
onClick={onClick}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
28
|
+
return <LinkTab key={String(i)} tab={tab} {...rest} />;
|
|
37
29
|
}
|
|
38
30
|
default:
|
|
39
31
|
assertUnreachable(type);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { TabsMode } from './TabsContent';
|
|
2
|
+
|
|
1
3
|
export const LINK_CLASSES = 'h-12 flex-1 flex items-center justify-center cursor-pointer';
|
|
2
4
|
export const ACTIVE_LINK_CLASSES = 'bg-primary-main';
|
|
3
5
|
export const INACTIVE_LINK_CLASSES = 'group/btn bg-white';
|
|
@@ -17,7 +19,11 @@ const GROUP_TAB_CLASSES = {
|
|
|
17
19
|
active: `inline-flex px-4 grow whitespace-nowrap ${LINK_CLASSES} ${SCROLLABLE_ACTIVE_LINK_CLASSES}`,
|
|
18
20
|
default: `inline-flex px-4 grow whitespace-nowrap ${LINK_CLASSES} ${INACTIVE_LINK_CLASSES}`,
|
|
19
21
|
},
|
|
20
|
-
|
|
22
|
+
centered: {
|
|
23
|
+
active: `px-4 rounded-md ${LINK_CLASSES} ${WIDESCREEN_ACTIVE_LINK_CLASSES} whitespace-nowrap`,
|
|
24
|
+
default: `px-4 rounded-md ${LINK_CLASSES} group/btn bg-transparent whitespace-nowrap`,
|
|
25
|
+
},
|
|
26
|
+
wideScreen: {
|
|
21
27
|
active: `${LINK_CLASSES} ${WIDESCREEN_ACTIVE_LINK_CLASSES} whitespace-nowrap`,
|
|
22
28
|
default: `${LINK_CLASSES} ${INACTIVE_LINK_CLASSES} whitespace-nowrap`,
|
|
23
29
|
},
|
|
@@ -27,7 +33,11 @@ const GROUP_TAB_CLASSES = {
|
|
|
27
33
|
active: `h-full border-0 border-b-2`,
|
|
28
34
|
default: ``,
|
|
29
35
|
},
|
|
30
|
-
|
|
36
|
+
centered: {
|
|
37
|
+
active: '',
|
|
38
|
+
default: '',
|
|
39
|
+
},
|
|
40
|
+
wideScreen: {
|
|
31
41
|
active: '',
|
|
32
42
|
default: '',
|
|
33
43
|
},
|
|
@@ -39,7 +49,11 @@ const LINK_TAB_CLASSES = {
|
|
|
39
49
|
active: `inline-flex px-4 grow whitespace-nowrap ${LINK_CLASSES} ${SCROLLABLE_ACTIVE_LINK_CLASSES}`,
|
|
40
50
|
default: `inline-flex px-4 grow whitespace-nowrap ${LINK_CLASSES} ${INACTIVE_LINK_CLASSES}`,
|
|
41
51
|
},
|
|
42
|
-
|
|
52
|
+
centered: {
|
|
53
|
+
active: `px-4 rounded-md ${LINK_CLASSES} ${WIDESCREEN_ACTIVE_LINK_CLASSES} whitespace-nowrap`,
|
|
54
|
+
default: `px-4 rounded-md ${LINK_CLASSES} group/btn bg-transparent whitespace-nowrap`,
|
|
55
|
+
},
|
|
56
|
+
wideScreen: {
|
|
43
57
|
active: `${LINK_CLASSES} ${WIDESCREEN_ACTIVE_LINK_CLASSES}`,
|
|
44
58
|
default: `${LINK_CLASSES} ${INACTIVE_LINK_CLASSES}`,
|
|
45
59
|
},
|
|
@@ -49,23 +63,27 @@ const LINK_TAB_CLASSES = {
|
|
|
49
63
|
active: `${TEXT_CLASSES} flex items-center h-full border-0 border-b-2 ${WHITE_ACTIVE_TEXT_CLASSES}`,
|
|
50
64
|
default: `${TEXT_CLASSES} ${INACTIVE_TEXT_CLASSES}`,
|
|
51
65
|
},
|
|
52
|
-
|
|
66
|
+
centered: {
|
|
67
|
+
active: `${TEXT_CLASSES} ${ACTIVE_TEXT_CLASSES}`,
|
|
68
|
+
default: `${TEXT_CLASSES} ${INACTIVE_TEXT_CLASSES}`,
|
|
69
|
+
},
|
|
70
|
+
wideScreen: {
|
|
53
71
|
active: `${TEXT_CLASSES} ${ACTIVE_TEXT_CLASSES}`,
|
|
54
72
|
default: `${TEXT_CLASSES} ${INACTIVE_TEXT_CLASSES}`,
|
|
55
73
|
},
|
|
56
74
|
},
|
|
57
75
|
};
|
|
58
76
|
|
|
59
|
-
export const getGroupTabClassName = (type: string, active: boolean,
|
|
60
|
-
const styleType = isScrollable ? 'scrollable' : 'default';
|
|
77
|
+
export const getGroupTabClassName = (type: string, active: boolean, tabsMode?: TabsMode) => {
|
|
61
78
|
const styleActive = active ? 'active' : 'default';
|
|
79
|
+
const mode = tabsMode || 'wideScreen';
|
|
62
80
|
|
|
63
|
-
return GROUP_TAB_CLASSES[type][
|
|
81
|
+
return GROUP_TAB_CLASSES[type][mode][styleActive];
|
|
64
82
|
};
|
|
65
83
|
|
|
66
|
-
export const getLinkTabClassName = (type: string, active: boolean,
|
|
67
|
-
const styleType = isScrollable ? 'scrollable' : 'default';
|
|
84
|
+
export const getLinkTabClassName = (type: string, active: boolean, tabsMode?: TabsMode) => {
|
|
68
85
|
const styleActive = active ? 'active' : 'default';
|
|
86
|
+
const mode = tabsMode || 'wideScreen';
|
|
69
87
|
|
|
70
|
-
return LINK_TAB_CLASSES[type][
|
|
88
|
+
return LINK_TAB_CLASSES[type][mode][styleActive];
|
|
71
89
|
};
|
package/src/hooks/useLink.ts
CHANGED
|
@@ -23,7 +23,7 @@ export function useLink(params: UseLinkParams = {}) {
|
|
|
23
23
|
|
|
24
24
|
return <L extends Partial<LinkProps & Clickable>>(props: L): L & Clickable => ({
|
|
25
25
|
...props,
|
|
26
|
-
href: isRemote ? props.href : adjustHref(router)(props.href, basePath),
|
|
26
|
+
href: isRemote && !basePath ? props.href : adjustHref(router)(props.href, basePath),
|
|
27
27
|
'aria-label': props.text,
|
|
28
28
|
onClick: handlerDecorator(handleHref(props), props),
|
|
29
29
|
});
|