@meduza/ui-kit-2 0.0.1 → 0.1.1
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/README.md +7 -179
- package/dist/BookmarkButton/BookmarkButton.stories.d.ts +10 -0
- package/dist/BookmarkButton/BookmarkButton.types.d.ts +6 -0
- package/dist/BookmarkButton/index.d.ts +3 -0
- package/dist/Button/Button.stories.d.ts +10 -0
- package/dist/Button/Button.types.d.ts +2 -2
- package/dist/CardTitle/CardTitle.stories.d.ts +10 -0
- package/dist/CardTitle/CardTitle.types.d.ts +8 -0
- package/dist/CardTitle/index.d.ts +3 -0
- package/dist/ChapterBlock/ChapterBlock.stories.d.ts +10 -0
- package/dist/ChapterBlock/ChapterBlock.types.d.ts +7 -0
- package/dist/ChapterBlock/index.d.ts +3 -0
- package/dist/Cover/Cover.stories.d.ts +10 -0
- package/dist/Cover/Cover.types.d.ts +4 -0
- package/dist/Cover/index.d.ts +3 -0
- package/dist/DocumentItemsCount/DocumentItemsCount.stories.d.ts +10 -0
- package/dist/DocumentItemsCount/DocumentItemsCount.types.d.ts +7 -0
- package/dist/DocumentItemsCount/index.d.ts +3 -0
- package/dist/DotsOnImage/DotsOnImage.stories.d.ts +10 -0
- package/dist/DotsOnImage/DotsOnImage.types.d.ts +42 -0
- package/dist/DotsOnImage/index.d.ts +3 -0
- package/dist/Dropdown/Dropdown.stories.d.ts +10 -0
- package/dist/Dropdown/Dropdown.types.d.ts +6 -0
- package/dist/Dropdown/index.d.ts +4 -0
- package/dist/EmbedBlock/EmbedBlock.d.ts +3 -0
- package/dist/EmbedBlock/EmbedBlock.stories.d.ts +10 -0
- package/dist/EmbedBlock/EmbedBlock.types.d.ts +5 -0
- package/dist/EmbedBlock/IframeBlock.d.ts +3 -0
- package/dist/EmbedBlock/index.d.ts +3 -0
- package/dist/GroupedBlock/GroupedBlock.stories.d.ts +10 -0
- package/dist/GroupedBlock/GroupedBlock.types.d.ts +4 -0
- package/dist/GroupedBlock/index.d.ts +3 -0
- package/dist/HalfBlock/HalfBlock.stories.d.ts +10 -0
- package/dist/HalfBlock/HalfBlock.types.d.ts +4 -0
- package/dist/HalfBlock/index.d.ts +3 -0
- package/dist/Image/Image.stories.d.ts +10 -0
- package/dist/Image/Image.types.d.ts +38 -0
- package/dist/Image/RenderPicture.d.ts +4 -0
- package/dist/Image/index.d.ts +3 -0
- package/dist/ImportantLead/ImportantLead.stories.d.ts +10 -0
- package/dist/ImportantLead/ImportantLead.types.d.ts +4 -0
- package/dist/ImportantLead/index.d.ts +3 -0
- package/dist/Lazy/Lazy.stories.d.ts +10 -0
- package/dist/Lazy/Lazy.types.d.ts +5 -0
- package/dist/Lazy/index.d.ts +3 -0
- package/dist/ListBlock/ListBlock.stories.d.ts +10 -0
- package/dist/ListBlock/ListBlock.types.d.ts +4 -0
- package/dist/ListBlock/index.d.ts +3 -0
- package/dist/MaterialNote/MaterialNote.stories.d.ts +10 -0
- package/dist/MaterialNote/MaterialNote.types.d.ts +12 -0
- package/dist/MaterialNote/index.d.ts +3 -0
- package/dist/MaterialTitle/MaterialTitle.stories.d.ts +10 -0
- package/dist/MaterialTitle/MaterialTitle.types.d.ts +4 -0
- package/dist/MaterialTitle/index.d.ts +5 -0
- package/dist/MediaCaption/MediaCaption.stories.d.ts +10 -0
- package/dist/MediaCaption/MediaCaption.types.d.ts +5 -0
- package/dist/MediaCaption/index.d.ts +3 -0
- package/dist/Meta/Meta.stories.d.ts +10 -0
- package/dist/Meta/Meta.types.d.ts +18 -0
- package/dist/Meta/MetaContainer.d.ts +3 -0
- package/dist/Meta/index.d.ts +3 -0
- package/dist/MetaItem/MetaItem.stories.d.ts +10 -0
- package/dist/MetaItem/MetaItem.types.d.ts +7 -0
- package/dist/MetaItem/index.d.ts +3 -0
- package/dist/MetaItemLive/MetaItemLive.stories.d.ts +10 -0
- package/dist/MetaItemLive/MetaItemLive.types.d.ts +3 -0
- package/dist/MetaItemLive/index.d.ts +3 -0
- package/dist/Popover/Popover.stories.d.ts +10 -0
- package/dist/Popover/Popover.types.d.ts +5 -0
- package/dist/Popover/index.d.ts +3 -0
- package/dist/QuoteBlock/QuoteBlock.stories.d.ts +10 -0
- package/dist/QuoteBlock/QuoteBlock.types.d.ts +6 -0
- package/dist/QuoteBlock/index.d.ts +3 -0
- package/dist/RawHtmlBlock/RawHtmlBlock.stories.d.ts +10 -0
- package/dist/RawHtmlBlock/RawHtmlBlock.types.d.ts +9 -0
- package/dist/RawHtmlBlock/index.d.ts +3 -0
- package/dist/RelatedBlock/RelatedBlock.stories.d.ts +10 -0
- package/dist/RelatedBlock/RelatedBlock.types.d.ts +4 -0
- package/dist/RelatedBlock/index.d.ts +3 -0
- package/dist/RenderBlocks/RenderBlocks.stories.d.ts +10 -0
- package/dist/RenderBlocks/RenderBlocks.types.d.ts +10 -0
- package/dist/RenderBlocks/index.d.ts +3 -0
- package/dist/RichTitle/RichTitle.stories.d.ts +10 -0
- package/dist/RichTitle/RichTitle.types.d.ts +4 -0
- package/dist/RichTitle/index.d.ts +3 -0
- package/dist/SimpleBlock/SimpleBlock.stories.d.ts +10 -0
- package/dist/SimpleBlock/SimpleBlock.types.d.ts +4 -0
- package/dist/SimpleBlock/index.d.ts +3 -0
- package/dist/SimpleTitle/SimpleTitle.stories.d.ts +10 -0
- package/dist/SimpleTitle/SimpleTitle.types.d.ts +4 -0
- package/dist/SimpleTitle/index.d.ts +3 -0
- package/dist/SourceBlock/SourceBlock.stories.d.ts +10 -0
- package/dist/SourceBlock/SourceBlock.types.d.ts +4 -0
- package/dist/SourceBlock/index.d.ts +3 -0
- package/dist/Spoiler/Spoiler.stories.d.ts +10 -0
- package/dist/Spoiler/Spoiler.types.d.ts +4 -0
- package/dist/Spoiler/index.d.ts +3 -0
- package/dist/SvgSymbol/SvgSymbol.stories.d.ts +10 -0
- package/dist/SvgSymbol/SvgSymbol.types.d.ts +8 -0
- package/dist/SvgSymbol/icons.d.ts +157 -0
- package/dist/SvgSymbol/index.d.ts +3 -0
- package/dist/Switcher/Switcher.stories.d.ts +10 -0
- package/dist/Switcher/Switcher.types.d.ts +12 -0
- package/dist/Switcher/index.d.ts +3 -0
- package/dist/Table/Table.stories.d.ts +10 -0
- package/dist/Table/Table.types.d.ts +25 -0
- package/dist/Table/index.d.ts +3 -0
- package/dist/Tag/Tag.stories.d.ts +10 -0
- package/dist/Tag/Tag.types.d.ts +12 -0
- package/dist/Tag/index.d.ts +3 -0
- package/dist/Timestamp/Timestamp.stories.d.ts +10 -0
- package/dist/Timestamp/Timestamp.types.d.ts +5 -0
- package/dist/Timestamp/index.d.ts +4 -0
- package/dist/Toolbar/Toolbar.stories.d.ts +10 -0
- package/dist/Toolbar/Toolbar.types.d.ts +5 -0
- package/dist/Toolbar/index.d.ts +3 -0
- package/dist/ToolbarButton/ToolbarButton.stories.d.ts +10 -0
- package/dist/ToolbarButton/ToolbarButton.types.d.ts +9 -0
- package/dist/ToolbarButton/index.d.ts +3 -0
- package/dist/_storybook/PreviewWrapper/index.d.ts +6 -0
- package/dist/constants.d.ts +22 -0
- package/dist/index.d.ts +37 -0
- package/dist/ui-kit-2.cjs.development.css +36 -0
- package/dist/ui-kit-2.cjs.development.js +2187 -39
- package/dist/ui-kit-2.cjs.development.js.map +1 -1
- package/dist/ui-kit-2.cjs.production.min.js +1 -1
- package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
- package/dist/ui-kit-2.esm.js +2139 -32
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/utils/BlockContext.d.ts +8 -0
- package/dist/utils/DangerousHtml.d.ts +8 -0
- package/dist/utils/makeClassName.d.ts +1 -1
- package/dist/utils/makeStyleContext.d.ts +2 -0
- package/dist/utils/toCamel.d.ts +1 -0
- package/package.json +29 -13
- package/src/BookmarkButton/BookmarkButton.module.css +50 -0
- package/src/BookmarkButton/BookmarkButton.stories.module.css +5 -0
- package/src/BookmarkButton/BookmarkButton.stories.tsx +39 -0
- package/src/BookmarkButton/BookmarkButton.test.tsx +20 -0
- package/src/BookmarkButton/BookmarkButton.types.ts +6 -0
- package/src/BookmarkButton/index.tsx +37 -0
- package/src/Button/Button.stories.module.css +30 -0
- package/src/Button/Button.stories.tsx +87 -0
- package/src/Button/Button.test.tsx +42 -0
- package/src/Button/Button.types.ts +1 -3
- package/src/Button/index.tsx +2 -2
- package/src/CardTitle/CardTitle.module.css +52 -0
- package/src/CardTitle/CardTitle.stories.module.css +5 -0
- package/src/CardTitle/CardTitle.stories.tsx +36 -0
- package/src/CardTitle/CardTitle.test.tsx +20 -0
- package/src/CardTitle/CardTitle.types.ts +8 -0
- package/src/CardTitle/index.tsx +24 -0
- package/src/CardTitle/mock.json +8 -0
- package/src/ChapterBlock/ChapterBlock.module.css +70 -0
- package/src/ChapterBlock/ChapterBlock.stories.module.css +5 -0
- package/src/ChapterBlock/ChapterBlock.stories.tsx +36 -0
- package/src/ChapterBlock/ChapterBlock.test.tsx +20 -0
- package/src/ChapterBlock/ChapterBlock.types.ts +7 -0
- package/src/ChapterBlock/index.tsx +31 -0
- package/src/ChapterBlock/mock.json +5 -0
- package/src/Cover/Cover.module.css +5 -0
- package/src/Cover/Cover.stories.module.css +5 -0
- package/src/Cover/Cover.stories.tsx +34 -0
- package/src/Cover/Cover.test.tsx +20 -0
- package/src/Cover/Cover.types.ts +4 -0
- package/src/Cover/index.tsx +89 -0
- package/src/DocumentItemsCount/DocumentItemsCount.module.css +18 -0
- package/src/DocumentItemsCount/DocumentItemsCount.stories.module.css +5 -0
- package/src/DocumentItemsCount/DocumentItemsCount.stories.tsx +34 -0
- package/src/DocumentItemsCount/DocumentItemsCount.test.tsx +20 -0
- package/src/DocumentItemsCount/DocumentItemsCount.types.ts +6 -0
- package/src/DocumentItemsCount/index.tsx +54 -0
- package/src/DotsOnImage/DotsOnImage.module.css +56 -0
- package/src/DotsOnImage/DotsOnImage.stories.module.css +9 -0
- package/src/DotsOnImage/DotsOnImage.stories.tsx +37 -0
- package/src/DotsOnImage/DotsOnImage.test.tsx +19 -0
- package/src/DotsOnImage/DotsOnImage.types.ts +46 -0
- package/src/DotsOnImage/index.tsx +79 -0
- package/src/DotsOnImage/mock.json +75 -0
- package/src/Dropdown/Dropdown.module.css +82 -0
- package/src/Dropdown/Dropdown.stories.module.css +5 -0
- package/src/Dropdown/Dropdown.stories.tsx +55 -0
- package/src/Dropdown/Dropdown.test.tsx +20 -0
- package/src/Dropdown/Dropdown.types.ts +5 -0
- package/src/Dropdown/index.tsx +35 -0
- package/src/EmbedBlock/EmbedBlock.module.css +351 -0
- package/src/EmbedBlock/EmbedBlock.stories.module.css +5 -0
- package/src/EmbedBlock/EmbedBlock.stories.tsx +39 -0
- package/src/EmbedBlock/EmbedBlock.test.tsx +20 -0
- package/src/EmbedBlock/EmbedBlock.tsx +236 -0
- package/src/EmbedBlock/EmbedBlock.types.ts +5 -0
- package/src/EmbedBlock/IframeBlock.tsx +86 -0
- package/src/EmbedBlock/index.tsx +16 -0
- package/src/EmbedBlock/mock.json +89 -0
- package/src/GroupedBlock/GroupedBlock.module.css +94 -0
- package/src/GroupedBlock/GroupedBlock.stories.module.css +5 -0
- package/src/GroupedBlock/GroupedBlock.stories.tsx +34 -0
- package/src/GroupedBlock/GroupedBlock.test.tsx +20 -0
- package/src/GroupedBlock/GroupedBlock.types.ts +4 -0
- package/src/GroupedBlock/index.tsx +67 -0
- package/src/HalfBlock/HalfBlock.module.css +88 -0
- package/src/HalfBlock/HalfBlock.stories.module.css +5 -0
- package/src/HalfBlock/HalfBlock.stories.tsx +34 -0
- package/src/HalfBlock/HalfBlock.test.tsx +20 -0
- package/src/HalfBlock/HalfBlock.types.ts +4 -0
- package/src/HalfBlock/index.tsx +53 -0
- package/src/Image/Image.module.css +78 -0
- package/src/Image/Image.stories.module.css +5 -0
- package/src/Image/Image.stories.tsx +47 -0
- package/src/Image/Image.test.tsx +33 -0
- package/src/Image/Image.types.ts +40 -0
- package/src/Image/RenderPicture.tsx +70 -0
- package/src/Image/index.tsx +101 -0
- package/src/Image/mock.json +49 -0
- package/src/ImportantLead/ImportantLead.module.css +64 -0
- package/src/ImportantLead/ImportantLead.stories.module.css +5 -0
- package/src/ImportantLead/ImportantLead.stories.tsx +34 -0
- package/src/ImportantLead/ImportantLead.test.tsx +20 -0
- package/src/ImportantLead/ImportantLead.types.ts +4 -0
- package/src/ImportantLead/index.tsx +35 -0
- package/src/Lazy/Lazy.module.css +9 -0
- package/src/Lazy/Lazy.stories.module.css +5 -0
- package/src/Lazy/Lazy.stories.tsx +48 -0
- package/src/Lazy/Lazy.test.tsx +20 -0
- package/src/Lazy/Lazy.types.ts +4 -0
- package/src/Lazy/index.tsx +41 -0
- package/src/ListBlock/ListBlock.module.css +163 -0
- package/src/ListBlock/ListBlock.stories.module.css +5 -0
- package/src/ListBlock/ListBlock.stories.tsx +34 -0
- package/src/ListBlock/ListBlock.test.tsx +20 -0
- package/src/ListBlock/ListBlock.types.ts +4 -0
- package/src/ListBlock/index.tsx +33 -0
- package/src/MaterialNote/MaterialNote.module.css +139 -0
- package/src/MaterialNote/MaterialNote.stories.module.css +5 -0
- package/src/MaterialNote/MaterialNote.stories.tsx +36 -0
- package/src/MaterialNote/MaterialNote.test.tsx +20 -0
- package/src/MaterialNote/MaterialNote.types.ts +12 -0
- package/src/MaterialNote/index.tsx +30 -0
- package/src/MaterialNote/mock.json +18 -0
- package/src/MaterialTitle/MaterialTitle.module.css +33 -0
- package/src/MaterialTitle/MaterialTitle.stories.module.css +13 -0
- package/src/MaterialTitle/MaterialTitle.stories.tsx +52 -0
- package/src/MaterialTitle/MaterialTitle.test.tsx +20 -0
- package/src/MaterialTitle/MaterialTitle.types.ts +3 -0
- package/src/MaterialTitle/index.tsx +20 -0
- package/src/MediaCaption/MediaCaption.module.css +85 -0
- package/src/MediaCaption/MediaCaption.stories.module.css +5 -0
- package/src/MediaCaption/MediaCaption.stories.tsx +37 -0
- package/src/MediaCaption/MediaCaption.test.tsx +20 -0
- package/src/MediaCaption/MediaCaption.types.ts +5 -0
- package/src/MediaCaption/index.tsx +35 -0
- package/src/Meta/Meta.module.css +106 -0
- package/src/Meta/Meta.stories.module.css +7 -0
- package/src/Meta/Meta.stories.tsx +69 -0
- package/src/Meta/Meta.test.tsx +20 -0
- package/src/Meta/Meta.types.ts +19 -0
- package/src/Meta/MetaContainer.tsx +148 -0
- package/src/Meta/index.tsx +32 -0
- package/src/MetaItem/MetaItem.module.css +104 -0
- package/src/MetaItem/MetaItem.stories.module.css +5 -0
- package/src/MetaItem/MetaItem.stories.tsx +34 -0
- package/src/MetaItem/MetaItem.test.tsx +20 -0
- package/src/MetaItem/MetaItem.types.ts +6 -0
- package/src/MetaItem/index.tsx +26 -0
- package/src/MetaItemLive/MetaItemLive.module.css +124 -0
- package/src/MetaItemLive/MetaItemLive.stories.module.css +5 -0
- package/src/MetaItemLive/MetaItemLive.stories.tsx +34 -0
- package/src/MetaItemLive/MetaItemLive.test.tsx +20 -0
- package/src/MetaItemLive/MetaItemLive.types.ts +3 -0
- package/src/MetaItemLive/index.tsx +25 -0
- package/src/Popover/Popover.module.css +134 -0
- package/src/Popover/Popover.stories.module.css +5 -0
- package/src/Popover/Popover.stories.tsx +55 -0
- package/src/Popover/Popover.test.tsx +20 -0
- package/src/Popover/Popover.types.ts +4 -0
- package/src/Popover/index.tsx +78 -0
- package/src/QuoteBlock/QuoteBlock.module.css +79 -0
- package/src/QuoteBlock/QuoteBlock.stories.module.css +7 -0
- package/src/QuoteBlock/QuoteBlock.stories.tsx +36 -0
- package/src/QuoteBlock/QuoteBlock.test.tsx +20 -0
- package/src/QuoteBlock/QuoteBlock.types.ts +6 -0
- package/src/QuoteBlock/index.tsx +24 -0
- package/src/QuoteBlock/mock.json +6 -0
- package/src/RawHtmlBlock/RawHtmlBlock.stories.module.css +5 -0
- package/src/RawHtmlBlock/RawHtmlBlock.stories.tsx +34 -0
- package/src/RawHtmlBlock/RawHtmlBlock.test.tsx +20 -0
- package/src/RawHtmlBlock/RawHtmlBlock.types.ts +9 -0
- package/src/RawHtmlBlock/index.tsx +57 -0
- package/src/RelatedBlock/RelatedBlock.module.css +129 -0
- package/src/RelatedBlock/RelatedBlock.stories.module.css +5 -0
- package/src/RelatedBlock/RelatedBlock.stories.tsx +34 -0
- package/src/RelatedBlock/RelatedBlock.test.tsx +20 -0
- package/src/RelatedBlock/RelatedBlock.types.ts +4 -0
- package/src/RelatedBlock/index.tsx +45 -0
- package/src/RenderBlocks/RenderBlocks.stories.module.css +5 -0
- package/src/RenderBlocks/RenderBlocks.stories.tsx +34 -0
- package/src/RenderBlocks/RenderBlocks.test.tsx +20 -0
- package/src/RenderBlocks/RenderBlocks.types.ts +10 -0
- package/src/RenderBlocks/index.tsx +125 -0
- package/src/RichTitle/RichTitle.module.css +85 -0
- package/src/RichTitle/RichTitle.stories.module.css +5 -0
- package/src/RichTitle/RichTitle.stories.tsx +34 -0
- package/src/RichTitle/RichTitle.test.tsx +20 -0
- package/src/RichTitle/RichTitle.types.ts +4 -0
- package/src/RichTitle/index.tsx +32 -0
- package/src/SimpleBlock/FootnoteLink.css +34 -0
- package/src/SimpleBlock/SimpleBlock.module.css +393 -0
- package/src/SimpleBlock/SimpleBlock.stories.module.css +5 -0
- package/src/SimpleBlock/SimpleBlock.stories.tsx +34 -0
- package/src/SimpleBlock/SimpleBlock.test.tsx +20 -0
- package/src/SimpleBlock/SimpleBlock.types.ts +4 -0
- package/src/SimpleBlock/index.tsx +47 -0
- package/src/SimpleTitle/SimpleTitle.module.css +33 -0
- package/src/SimpleTitle/SimpleTitle.stories.module.css +5 -0
- package/src/SimpleTitle/SimpleTitle.stories.tsx +34 -0
- package/src/SimpleTitle/SimpleTitle.test.tsx +20 -0
- package/src/SimpleTitle/SimpleTitle.types.ts +4 -0
- package/src/SimpleTitle/index.tsx +29 -0
- package/src/SourceBlock/SourceBlock.module.css +110 -0
- package/src/SourceBlock/SourceBlock.stories.module.css +5 -0
- package/src/SourceBlock/SourceBlock.stories.tsx +34 -0
- package/src/SourceBlock/SourceBlock.test.tsx +20 -0
- package/src/SourceBlock/SourceBlock.types.ts +4 -0
- package/src/SourceBlock/index.tsx +44 -0
- package/src/Spoiler/Spoiler.module.css +177 -0
- package/src/Spoiler/Spoiler.stories.module.css +8 -0
- package/src/Spoiler/Spoiler.stories.tsx +36 -0
- package/src/Spoiler/Spoiler.test.tsx +20 -0
- package/src/Spoiler/Spoiler.types.ts +4 -0
- package/src/Spoiler/index.tsx +81 -0
- package/src/Spoiler/mock.json +49 -0
- package/src/SvgSymbol/SvgSymbol.module.css +240 -0
- package/src/SvgSymbol/SvgSymbol.stories.module.css +127 -0
- package/src/SvgSymbol/SvgSymbol.stories.tsx +95 -0
- package/src/SvgSymbol/SvgSymbol.test.tsx +21 -0
- package/src/SvgSymbol/SvgSymbol.types.ts +57 -0
- package/src/SvgSymbol/icons.ts +217 -0
- package/src/SvgSymbol/index.tsx +32 -0
- package/src/Switcher/Switcher.module.css +159 -0
- package/src/Switcher/Switcher.stories.module.css +28 -0
- package/src/Switcher/Switcher.stories.tsx +68 -0
- package/src/Switcher/Switcher.test.tsx +43 -0
- package/src/Switcher/Switcher.types.ts +16 -0
- package/src/Switcher/index.tsx +53 -0
- package/src/Table/Table.module.css +300 -0
- package/src/Table/Table.stories.module.css +5 -0
- package/src/Table/Table.stories.tsx +36 -0
- package/src/Table/Table.test.tsx +20 -0
- package/src/Table/Table.types.ts +26 -0
- package/src/Table/index.tsx +76 -0
- package/src/Table/mock.json +301 -0
- package/src/Tag/Tag.module.css +115 -0
- package/src/Tag/Tag.stories.module.css +5 -0
- package/src/Tag/Tag.stories.tsx +53 -0
- package/src/Tag/Tag.test.tsx +20 -0
- package/src/Tag/Tag.types.ts +14 -0
- package/src/Tag/index.tsx +33 -0
- package/src/Timestamp/Timestamp.module.css +6 -0
- package/src/Timestamp/Timestamp.stories.module.css +5 -0
- package/src/Timestamp/Timestamp.stories.tsx +34 -0
- package/src/Timestamp/Timestamp.test.tsx +20 -0
- package/src/Timestamp/Timestamp.types.ts +5 -0
- package/src/Timestamp/index.tsx +40 -0
- package/src/Toolbar/Toolbar.module.css +134 -0
- package/src/Toolbar/Toolbar.stories.module.css +5 -0
- package/src/Toolbar/Toolbar.stories.tsx +89 -0
- package/src/Toolbar/Toolbar.test.tsx +20 -0
- package/src/Toolbar/Toolbar.types.ts +4 -0
- package/src/Toolbar/index.tsx +28 -0
- package/src/ToolbarButton/ToolbarButton.module.css +97 -0
- package/src/ToolbarButton/ToolbarButton.stories.module.css +5 -0
- package/src/ToolbarButton/ToolbarButton.stories.tsx +36 -0
- package/src/ToolbarButton/ToolbarButton.test.tsx +20 -0
- package/src/ToolbarButton/ToolbarButton.types.ts +19 -0
- package/src/ToolbarButton/index.tsx +34 -0
- package/src/_storybook/PreviewWrapper/PreviewWrapper.module.css +117 -0
- package/src/_storybook/PreviewWrapper/index.tsx +23 -0
- package/src/constants.ts +24 -0
- package/src/index.tsx +38 -0
- package/src/utils/BlockContext.ts +7 -0
- package/src/utils/DangerousHtml.tsx +79 -0
- package/src/utils/makeClassName.ts +1 -1
- package/src/utils/makeStyleContext.ts +13 -0
- package/src/utils/toCamel.ts +2 -0
- package/LICENSE +0 -21
- package/src/global.d.ts +0 -4
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "table",
|
|
3
|
+
"table_credit": "кредит в таблице",
|
|
4
|
+
"rows": [
|
|
5
|
+
{
|
|
6
|
+
"key": "9ef452430882269f180f",
|
|
7
|
+
"cells": [
|
|
8
|
+
{
|
|
9
|
+
"val": "первая строка _1",
|
|
10
|
+
"key": "ptijzw",
|
|
11
|
+
"color": "#f4f0f8"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"val": "первая строка _2",
|
|
15
|
+
"key": "kdns0e",
|
|
16
|
+
"color": "#f5f5f5"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"val": "первая строка опять и снова",
|
|
20
|
+
"color": "#ffffff",
|
|
21
|
+
"key": "3xhcl4"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"val": "первая строка опять и снова",
|
|
25
|
+
"color": "#ffffff",
|
|
26
|
+
"key": "3xshdcl4"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"val": "первая строка опять и снова",
|
|
30
|
+
"color": "#ffffff",
|
|
31
|
+
"key": "3xhdcl4"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"key": "8d41ad87004eaa2efcba",
|
|
37
|
+
"cells": [
|
|
38
|
+
{
|
|
39
|
+
"val": "вторая <strong>строка</strong> _1",
|
|
40
|
+
"key": "uu2q3s",
|
|
41
|
+
"color": "#f4f0f8"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"val": "<a href=\"https://meduza.io/paragraph/2019/10/30/kak-margarita-simonyan-prishla-na-intervyu-k-ksenii-sobchak-uslyshala-neudobnye-voprosy-i-ushla-v-odnom-abzatse\" target=\"_blank\">вторая строка _3</a>",
|
|
45
|
+
"key": "qfy9e43",
|
|
46
|
+
"color": "#e6f3ff"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"val": "ывывыв",
|
|
50
|
+
"color": "#ffffff",
|
|
51
|
+
"key": "flh2yh"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"val": "<a href=\"https://meduza.io/paragraph/2019/10/30/kak-margarita-simonyan-prishla-na-intervyu-k-ksenii-sobchak-uslyshala-neudobnye-voprosy-i-ushla-v-odnom-abzatse\" target=\"_blank\">вторая строка _3</a>",
|
|
55
|
+
"key": "qfy943",
|
|
56
|
+
"color": "#e6df3ff"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"val": "ывывыв",
|
|
60
|
+
"color": "#ffffff",
|
|
61
|
+
"key": "flh2dyh"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"key": "1c4b6ce381f928aa2b57",
|
|
67
|
+
"cells": [
|
|
68
|
+
{
|
|
69
|
+
"val": "а тут <strong>болд</strong> с<em> италиком</em> и <a href=\"https://second.meduza.io/feature/2019/10/30/test-tablits-v-ficherah\" target=\"_blank\">ссылкой</a>",
|
|
70
|
+
"key": "cfnbc3",
|
|
71
|
+
"color": "#f4f0f8"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"val": "llllllll",
|
|
75
|
+
"key": "25yr97",
|
|
76
|
+
"color": "#FFFFFF"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"val": "2",
|
|
80
|
+
"color": "#ffffff",
|
|
81
|
+
"key": "q5ssyu"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"val": "llllllll",
|
|
85
|
+
"key": "25yrd97",
|
|
86
|
+
"color": "#FFFFFF"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"val": "2",
|
|
90
|
+
"color": "#ffffff",
|
|
91
|
+
"key": "q5ssdyu"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"key": "2f7722300e13ba0d37b1",
|
|
97
|
+
"cells": [
|
|
98
|
+
{
|
|
99
|
+
"key": "swrdin",
|
|
100
|
+
"color": "#f4f0f8"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"val": "ии",
|
|
104
|
+
"key": "h9jg6z",
|
|
105
|
+
"color": "#ffffff"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"val": "3",
|
|
109
|
+
"color": "#ffffff",
|
|
110
|
+
"key": "ag23oa"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"val": "ии",
|
|
114
|
+
"key": "h9jdg6z",
|
|
115
|
+
"color": "#ffffff"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"val": "3",
|
|
119
|
+
"color": "#ffffff",
|
|
120
|
+
"key": "ag23doa"
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"key": "dbb5a2c10886fea7ee41",
|
|
126
|
+
"cells": [
|
|
127
|
+
{
|
|
128
|
+
"val": "цццццц",
|
|
129
|
+
"color": "#ffffff",
|
|
130
|
+
"key": "3sd3uv"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"val": "пустая ячейка дальше",
|
|
134
|
+
"color": "#fffde6",
|
|
135
|
+
"key": "pjkssg"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"color": "#ffffff",
|
|
139
|
+
"key": "gtjnbr"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"val": "пустая ячейка дальше",
|
|
143
|
+
"color": "#fffde6",
|
|
144
|
+
"key": "pjksdsg"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"color": "#ffffff",
|
|
148
|
+
"key": "gtjdnbr"
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"key": "dbb5a2c108f6f3a7ee41",
|
|
154
|
+
"cells": [
|
|
155
|
+
{
|
|
156
|
+
"val": "цццццц",
|
|
157
|
+
"color": "#ffffff",
|
|
158
|
+
"key": "3sd3uv"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"val": "пустая ячейка дальше",
|
|
162
|
+
"color": "#fffde6",
|
|
163
|
+
"key": "pjkssg"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"color": "#ffffff",
|
|
167
|
+
"key": "gtjnbr"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"val": "пустая ячейка дальше",
|
|
171
|
+
"color": "#fffde6",
|
|
172
|
+
"key": "pjksdsg"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"color": "#ffffff",
|
|
176
|
+
"key": "gtjdnbr"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"key": "dbb5a2c10886sea7ee41",
|
|
182
|
+
"cells": [
|
|
183
|
+
{
|
|
184
|
+
"val": "цццццц",
|
|
185
|
+
"color": "#ffffff",
|
|
186
|
+
"key": "3sd3uv"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"val": "пустая ячейка дальше",
|
|
190
|
+
"color": "#fffde6",
|
|
191
|
+
"key": "pjkssg"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"color": "#ffffff",
|
|
195
|
+
"key": "gtjnbr"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"val": "пустая ячейка дальше",
|
|
199
|
+
"color": "#fffde6",
|
|
200
|
+
"key": "pjksdsg"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"color": "#ffffff",
|
|
204
|
+
"key": "gtjdnbr"
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"key": "dbb5s2cf0886fea7ee41",
|
|
210
|
+
"cells": [
|
|
211
|
+
{
|
|
212
|
+
"val": "цццццц",
|
|
213
|
+
"color": "#ffffff",
|
|
214
|
+
"key": "3sd3uv"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"val": "пустая ячейка дальше",
|
|
218
|
+
"color": "#fffde6",
|
|
219
|
+
"key": "pjkssg"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"color": "#ffffff",
|
|
223
|
+
"key": "gtjnbr"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"val": "пустая ячейка дальше",
|
|
227
|
+
"color": "#fffde6",
|
|
228
|
+
"key": "pjksdsg"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"color": "#ffffff",
|
|
232
|
+
"key": "gtjdnbr"
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"key": "dcb5a2d108f6f3a7ee41",
|
|
238
|
+
"cells": [
|
|
239
|
+
{
|
|
240
|
+
"val": "цццццц",
|
|
241
|
+
"color": "#ffffff",
|
|
242
|
+
"key": "3sd3uv"
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"val": "пустая ячейка дальше",
|
|
246
|
+
"color": "#fffde6",
|
|
247
|
+
"key": "pjkssg"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"color": "#ffffff",
|
|
251
|
+
"key": "gtjnbr"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"val": "пустая ячейка дальше",
|
|
255
|
+
"color": "#fffde6",
|
|
256
|
+
"key": "pjksdsg"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"color": "#ffffff",
|
|
260
|
+
"key": "gtjdnbr"
|
|
261
|
+
}
|
|
262
|
+
]
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"key": "dbb5a2c1088ssea7ee41",
|
|
266
|
+
"cells": [
|
|
267
|
+
{
|
|
268
|
+
"val": "цццццц",
|
|
269
|
+
"color": "#ffffff",
|
|
270
|
+
"key": "3sd3uv"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"val": "пустая ячейка дальше",
|
|
274
|
+
"color": "#fffde6",
|
|
275
|
+
"key": "pjkssg"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"color": "#ffffff",
|
|
279
|
+
"key": "gtjnbr"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"val": "пустая ячейка дальше",
|
|
283
|
+
"color": "#fffde6",
|
|
284
|
+
"key": "pjksdsg"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"color": "#ffffff",
|
|
288
|
+
"key": "gtjdnbr"
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
],
|
|
293
|
+
"columns_widths": [200, 405, 300, 200, 200],
|
|
294
|
+
"options": {
|
|
295
|
+
"num_fixed_rows": 2,
|
|
296
|
+
"num_fixed_columns": 1,
|
|
297
|
+
"header": false
|
|
298
|
+
},
|
|
299
|
+
"display": "full",
|
|
300
|
+
"id": "2-84f2dfff359c2d021666431d5a565e0cf7954ede74cd1fa340771d4c229f6fbd"
|
|
301
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
@import '../vars.css';
|
|
2
|
+
|
|
3
|
+
.root {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
|
|
6
|
+
cursor: default;
|
|
7
|
+
user-select: none;
|
|
8
|
+
vertical-align: middle;
|
|
9
|
+
letter-spacing: 1px;
|
|
10
|
+
text-transform: uppercase;
|
|
11
|
+
|
|
12
|
+
font-family: $secondaryFont;
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
font-weight: 600;
|
|
15
|
+
line-height: 12px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.small {
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
line-height: 12px;
|
|
21
|
+
|
|
22
|
+
@media $landscapeTablet {
|
|
23
|
+
line-height: 14px;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.large {
|
|
28
|
+
@media $landscapeTablet {
|
|
29
|
+
letter-spacing: 1px;
|
|
30
|
+
|
|
31
|
+
font-size: 14px;
|
|
32
|
+
line-height: 16px;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.dark {
|
|
37
|
+
color: #000;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.light {
|
|
41
|
+
color: #fff;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.gold {
|
|
45
|
+
color: $gold;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.gray {
|
|
49
|
+
color: #757575;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.inherit {
|
|
53
|
+
color: inherit;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.is1to1,
|
|
57
|
+
.is1to2,
|
|
58
|
+
.isInSuperBlock {
|
|
59
|
+
@media $landscapeTablet {
|
|
60
|
+
letter-spacing: 1px;
|
|
61
|
+
|
|
62
|
+
font-size: 12px;
|
|
63
|
+
line-height: 20px;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.is1to3,
|
|
68
|
+
.is1to4 {
|
|
69
|
+
@media $landscapeTablet {
|
|
70
|
+
letter-spacing: 0.5px;
|
|
71
|
+
|
|
72
|
+
font-size: 10px;
|
|
73
|
+
line-height: 15px;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.slide,
|
|
78
|
+
.game {
|
|
79
|
+
@media $mobile {
|
|
80
|
+
width: 100%;
|
|
81
|
+
|
|
82
|
+
text-align: center;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.slide,
|
|
87
|
+
.game,
|
|
88
|
+
.card,
|
|
89
|
+
.live,
|
|
90
|
+
.episode,
|
|
91
|
+
.podcast,
|
|
92
|
+
.rich,
|
|
93
|
+
.isInDynamicBlock {
|
|
94
|
+
margin-bottom: 6px;
|
|
95
|
+
|
|
96
|
+
line-height: 10px;
|
|
97
|
+
|
|
98
|
+
@media $mobile {
|
|
99
|
+
margin-bottom: 10px;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.mobile {
|
|
104
|
+
@media $mobile {
|
|
105
|
+
display: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.desktop {
|
|
110
|
+
display: none;
|
|
111
|
+
|
|
112
|
+
@media $mobile {
|
|
113
|
+
display: block;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { Tag } from './'
|
|
4
|
+
import { PreviewWrapper } from '../_storybook/PreviewWrapper'
|
|
5
|
+
|
|
6
|
+
import { TagSizes, TagThemes } from './Tag.types'
|
|
7
|
+
|
|
8
|
+
import styles from './Tag.stories.module.css'
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Main / Tag',
|
|
12
|
+
component: Tag,
|
|
13
|
+
parameters: {
|
|
14
|
+
themeWrapperSideBySide: true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Example: React.FC = () => {
|
|
19
|
+
const tags: { theme: TagThemes; size: TagSizes; title: string }[] = [
|
|
20
|
+
{ theme: 'dark', size: 'small', title: 'Новости' },
|
|
21
|
+
{ theme: 'gold', size: 'small', title: 'Новости' },
|
|
22
|
+
{ theme: 'gray', size: 'small', title: 'Новости' },
|
|
23
|
+
{ theme: 'light', size: 'small', title: 'Новости' },
|
|
24
|
+
{ theme: 'dark', size: 'large', title: 'Новости' },
|
|
25
|
+
{ theme: 'gold', size: 'large', title: 'Новости' },
|
|
26
|
+
{ theme: 'gray', size: 'large', title: 'Новости' },
|
|
27
|
+
{ theme: 'light', size: 'large', title: 'Новости' }
|
|
28
|
+
]
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<div className={styles.root}>
|
|
32
|
+
{tags.map(tag => (
|
|
33
|
+
<div key={`tagSize-${tag.theme}-${tag.size}`}>
|
|
34
|
+
<Tag size={tag.size} theme={tag.theme} styleContext="rich">
|
|
35
|
+
{tag.title}
|
|
36
|
+
</Tag>
|
|
37
|
+
</div>
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
|
+
</>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const Default: React.FC = () => (
|
|
45
|
+
<>
|
|
46
|
+
<PreviewWrapper theme="light">
|
|
47
|
+
<Example />
|
|
48
|
+
</PreviewWrapper>
|
|
49
|
+
<PreviewWrapper theme="dark">
|
|
50
|
+
<Example />
|
|
51
|
+
</PreviewWrapper>
|
|
52
|
+
</>
|
|
53
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
|
|
4
|
+
import { Tag } from './'
|
|
5
|
+
// import { TagProps } from './Tag.types'
|
|
6
|
+
import styles from './Tag.module.css'
|
|
7
|
+
|
|
8
|
+
describe('Tag', () => {
|
|
9
|
+
// let props: TagProps
|
|
10
|
+
|
|
11
|
+
const renderComponent = () => render(<Tag>Tag name</Tag>)
|
|
12
|
+
|
|
13
|
+
it('should have root style', () => {
|
|
14
|
+
const { getByTestId } = renderComponent()
|
|
15
|
+
|
|
16
|
+
const tag = getByTestId('tag')
|
|
17
|
+
|
|
18
|
+
expect(tag).toHaveClass(styles.root)
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type TagSizes = 'small' | 'large'
|
|
2
|
+
|
|
3
|
+
export type TagThemes = 'dark' | 'gold' | 'gray' | 'light' | 'inherit'
|
|
4
|
+
|
|
5
|
+
export type TagStyleContexts = 'isInToolbar' | 'isInSpoiler' | 'isInDropdown'
|
|
6
|
+
|
|
7
|
+
export interface TagProps {
|
|
8
|
+
children: JSX.Element[] | JSX.Element
|
|
9
|
+
styleContext?: string | string[]
|
|
10
|
+
theme: TagThemes
|
|
11
|
+
size: TagSizes
|
|
12
|
+
onlyOn?: 'desktop' | 'mobile'
|
|
13
|
+
correlation?: string
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { TagProps } from './Tag.types'
|
|
3
|
+
import makeStyleContext from '../utils/makeStyleContext'
|
|
4
|
+
import makeClassName from '../utils/makeClassName'
|
|
5
|
+
|
|
6
|
+
import styles from './Tag.module.css'
|
|
7
|
+
|
|
8
|
+
export const Tag: React.FC<TagProps> = ({
|
|
9
|
+
children,
|
|
10
|
+
size = 'small',
|
|
11
|
+
theme = 'gold',
|
|
12
|
+
styleContext,
|
|
13
|
+
correlation,
|
|
14
|
+
onlyOn
|
|
15
|
+
}) => {
|
|
16
|
+
let classNames: (string[] | string | boolean)[][] = [
|
|
17
|
+
[styles.root, true],
|
|
18
|
+
[styles[size], !!size && !!styles[size]],
|
|
19
|
+
[styles[theme], !!theme && !!styles[theme]],
|
|
20
|
+
[styles[onlyOn], !!onlyOn && !!styles[onlyOn]],
|
|
21
|
+
[styles[correlation], !!correlation && !!styles[correlation]]
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
if (styleContext) {
|
|
25
|
+
classNames = makeStyleContext(classNames, styleContext, styles)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div data-testid="tag" className={makeClassName(classNames)}>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { Timestamp } from './'
|
|
4
|
+
import { PreviewWrapper } from '../_storybook/PreviewWrapper'
|
|
5
|
+
import styles from './Timestamp.stories.module.css'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Main / Timestamp',
|
|
9
|
+
component: Timestamp,
|
|
10
|
+
parameters: {
|
|
11
|
+
themeWrapperSideBySide: true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Example: React.FC = () => {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<div className={styles.root}>
|
|
19
|
+
<Timestamp publishedAt={1526024185} type="fromNow" />
|
|
20
|
+
</div>
|
|
21
|
+
</>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Default: React.FC = () => (
|
|
26
|
+
<>
|
|
27
|
+
<PreviewWrapper theme="light">
|
|
28
|
+
<Example />
|
|
29
|
+
</PreviewWrapper>
|
|
30
|
+
<PreviewWrapper theme="dark">
|
|
31
|
+
<Example />
|
|
32
|
+
</PreviewWrapper>
|
|
33
|
+
</>
|
|
34
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
|
|
4
|
+
import { Timestamp } from './'
|
|
5
|
+
import { TimestampProps } from './Timestamp.types'
|
|
6
|
+
import styles from './Timestamp.module.css'
|
|
7
|
+
|
|
8
|
+
describe('Timestamp', () => {
|
|
9
|
+
let props: TimestampProps
|
|
10
|
+
|
|
11
|
+
const renderComponent = () => render(<Timestamp {...props} />)
|
|
12
|
+
|
|
13
|
+
it('should have root style', () => {
|
|
14
|
+
const { getByTestId } = renderComponent()
|
|
15
|
+
|
|
16
|
+
const timestamp = getByTestId('timestamp')
|
|
17
|
+
|
|
18
|
+
expect(timestamp).toHaveClass(styles.root)
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { TimestampProps } from './Timestamp.types'
|
|
3
|
+
|
|
4
|
+
import dayjs from 'dayjs'
|
|
5
|
+
import 'dayjs/locale/ru'
|
|
6
|
+
|
|
7
|
+
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
8
|
+
|
|
9
|
+
import styles from './Timestamp.module.css'
|
|
10
|
+
|
|
11
|
+
export const Timestamp: React.FC<TimestampProps> = ({
|
|
12
|
+
publishedAt,
|
|
13
|
+
locale = 'ru',
|
|
14
|
+
type
|
|
15
|
+
}) => {
|
|
16
|
+
let published
|
|
17
|
+
const timeFormat =
|
|
18
|
+
locale === 'ru' ? 'HH:mm, D MMMM YYYY' : 'h:mm a, MMMM D, YYYY'
|
|
19
|
+
|
|
20
|
+
const preparedPublishedAt = publishedAt * 1000
|
|
21
|
+
|
|
22
|
+
dayjs.locale(locale)
|
|
23
|
+
dayjs.extend(relativeTime)
|
|
24
|
+
|
|
25
|
+
if (type === 'fromNow') {
|
|
26
|
+
published = dayjs(preparedPublishedAt).fromNow()
|
|
27
|
+
} else if (type === 'format') {
|
|
28
|
+
published = dayjs(preparedPublishedAt).format('HH:mm')
|
|
29
|
+
} else if (type === 'date') {
|
|
30
|
+
published = dayjs(preparedPublishedAt).format(timeFormat)
|
|
31
|
+
} else {
|
|
32
|
+
throw new Error('Unknown time type')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<time data-testid="timestamp" className={styles.root}>
|
|
37
|
+
{published}
|
|
38
|
+
</time>
|
|
39
|
+
)
|
|
40
|
+
}
|