@apify/ui-library 0.51.6-featurepublishuilibrary-0a4729.38266
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/.eslintrc +39 -0
- package/.stylelintrc +12 -0
- package/CHANGELOG.md +2804 -0
- package/README.md +15 -0
- package/dist/src/components/action_link.d.ts +5 -0
- package/dist/src/components/action_link.d.ts.map +1 -0
- package/dist/src/components/action_link.jsx +35 -0
- package/dist/src/components/action_link.jsx.map +1 -0
- package/dist/src/components/actor_template_card.d.ts +10 -0
- package/dist/src/components/actor_template_card.d.ts.map +1 -0
- package/dist/src/components/actor_template_card.jsx +73 -0
- package/dist/src/components/actor_template_card.jsx.map +1 -0
- package/dist/src/components/badge.d.ts +26 -0
- package/dist/src/components/badge.d.ts.map +1 -0
- package/dist/src/components/badge.jsx +96 -0
- package/dist/src/components/badge.jsx.map +1 -0
- package/dist/src/components/banner.d.ts +11 -0
- package/dist/src/components/banner.d.ts.map +1 -0
- package/dist/src/components/banner.jsx +73 -0
- package/dist/src/components/banner.jsx.map +1 -0
- package/dist/src/components/blog_article.d.ts +9 -0
- package/dist/src/components/blog_article.d.ts.map +1 -0
- package/dist/src/components/blog_article.jsx +73 -0
- package/dist/src/components/blog_article.jsx.map +1 -0
- package/dist/src/components/box.d.ts +41 -0
- package/dist/src/components/box.d.ts.map +1 -0
- package/dist/src/components/box.jsx +48 -0
- package/dist/src/components/box.jsx.map +1 -0
- package/dist/src/components/button.d.ts +35 -0
- package/dist/src/components/button.d.ts.map +1 -0
- package/dist/src/components/button.jsx +193 -0
- package/dist/src/components/button.jsx.map +1 -0
- package/dist/src/components/chip.d.ts +52 -0
- package/dist/src/components/chip.d.ts.map +1 -0
- package/dist/src/components/chip.jsx +89 -0
- package/dist/src/components/chip.jsx.map +1 -0
- package/dist/src/components/code/action_button.d.ts +11 -0
- package/dist/src/components/code/action_button.d.ts.map +1 -0
- package/dist/src/components/code/action_button.jsx +67 -0
- package/dist/src/components/code/action_button.jsx.map +1 -0
- package/dist/src/components/code/code_block/code_block.d.ts +38 -0
- package/dist/src/components/code/code_block/code_block.d.ts.map +1 -0
- package/dist/src/components/code/code_block/code_block.jsx +99 -0
- package/dist/src/components/code/code_block/code_block.jsx.map +1 -0
- package/dist/src/components/code/code_block/code_block.styled.d.ts +13 -0
- package/dist/src/components/code/code_block/code_block.styled.d.ts.map +1 -0
- package/dist/src/components/code/code_block/code_block.styled.jsx +215 -0
- package/dist/src/components/code/code_block/code_block.styled.jsx.map +1 -0
- package/dist/src/components/code/code_block/utils.d.ts +2 -0
- package/dist/src/components/code/code_block/utils.d.ts.map +1 -0
- package/dist/src/components/code/code_block/utils.js +20 -0
- package/dist/src/components/code/code_block/utils.js.map +1 -0
- package/dist/src/components/code/index.d.ts +4 -0
- package/dist/src/components/code/index.d.ts.map +1 -0
- package/dist/src/components/code/index.js +4 -0
- package/dist/src/components/code/index.js.map +1 -0
- package/dist/src/components/code/inline_code/inline_code.d.ts +11 -0
- package/dist/src/components/code/inline_code/inline_code.d.ts.map +1 -0
- package/dist/src/components/code/inline_code/inline_code.jsx +24 -0
- package/dist/src/components/code/inline_code/inline_code.jsx.map +1 -0
- package/dist/src/components/code/one_line_code/one_line_code.d.ts +27 -0
- package/dist/src/components/code/one_line_code/one_line_code.d.ts.map +1 -0
- package/dist/src/components/code/one_line_code/one_line_code.jsx +157 -0
- package/dist/src/components/code/one_line_code/one_line_code.jsx.map +1 -0
- package/dist/src/components/code/syntax_highlighter.d.ts +16 -0
- package/dist/src/components/code/syntax_highlighter.d.ts.map +1 -0
- package/dist/src/components/code/syntax_highlighter.jsx +94 -0
- package/dist/src/components/code/syntax_highlighter.jsx.map +1 -0
- package/dist/src/components/color_wheel_gradient.d.ts +9 -0
- package/dist/src/components/color_wheel_gradient.d.ts.map +1 -0
- package/dist/src/components/color_wheel_gradient.jsx +23 -0
- package/dist/src/components/color_wheel_gradient.jsx.map +1 -0
- package/dist/src/components/floating/index.d.ts +4 -0
- package/dist/src/components/floating/index.d.ts.map +1 -0
- package/dist/src/components/floating/index.js +4 -0
- package/dist/src/components/floating/index.js.map +1 -0
- package/dist/src/components/floating/menu.d.ts +33 -0
- package/dist/src/components/floating/menu.d.ts.map +1 -0
- package/dist/src/components/floating/menu.jsx +95 -0
- package/dist/src/components/floating/menu.jsx.map +1 -0
- package/dist/src/components/floating/menu_common.d.ts +42 -0
- package/dist/src/components/floating/menu_common.d.ts.map +1 -0
- package/dist/src/components/floating/menu_common.jsx +20 -0
- package/dist/src/components/floating/menu_common.jsx.map +1 -0
- package/dist/src/components/floating/menu_components.d.ts +29 -0
- package/dist/src/components/floating/menu_components.d.ts.map +1 -0
- package/dist/src/components/floating/menu_components.jsx +73 -0
- package/dist/src/components/floating/menu_components.jsx.map +1 -0
- package/dist/src/components/image.d.ts +12 -0
- package/dist/src/components/image.d.ts.map +1 -0
- package/dist/src/components/image.jsx +8 -0
- package/dist/src/components/image.jsx.map +1 -0
- package/dist/src/components/index.d.ts +21 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +21 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/link.d.ts +24 -0
- package/dist/src/components/link.d.ts.map +1 -0
- package/dist/src/components/link.jsx +67 -0
- package/dist/src/components/link.jsx.map +1 -0
- package/dist/src/components/message.d.ts +31 -0
- package/dist/src/components/message.d.ts.map +1 -0
- package/dist/src/components/message.jsx +105 -0
- package/dist/src/components/message.jsx.map +1 -0
- package/dist/src/components/readme_renderer/index.d.ts +4 -0
- package/dist/src/components/readme_renderer/index.d.ts.map +1 -0
- package/dist/src/components/readme_renderer/index.js +4 -0
- package/dist/src/components/readme_renderer/index.js.map +1 -0
- package/dist/src/components/readme_renderer/pythonize_value.d.ts +3 -0
- package/dist/src/components/readme_renderer/pythonize_value.d.ts.map +1 -0
- package/dist/src/components/readme_renderer/pythonize_value.js +81 -0
- package/dist/src/components/readme_renderer/pythonize_value.js.map +1 -0
- package/dist/src/components/readme_renderer/table_of_contents.d.ts +10 -0
- package/dist/src/components/readme_renderer/table_of_contents.d.ts.map +1 -0
- package/dist/src/components/readme_renderer/table_of_contents.jsx +197 -0
- package/dist/src/components/readme_renderer/table_of_contents.jsx.map +1 -0
- package/dist/src/components/readme_renderer/utils.d.ts +6 -0
- package/dist/src/components/readme_renderer/utils.d.ts.map +1 -0
- package/dist/src/components/readme_renderer/utils.jsx +42 -0
- package/dist/src/components/readme_renderer/utils.jsx.map +1 -0
- package/dist/src/components/simple_markdown/index.d.ts +3 -0
- package/dist/src/components/simple_markdown/index.d.ts.map +1 -0
- package/dist/src/components/simple_markdown/index.jsx +3 -0
- package/dist/src/components/simple_markdown/index.jsx.map +1 -0
- package/dist/src/components/simple_markdown/simple_markdown.d.ts +16 -0
- package/dist/src/components/simple_markdown/simple_markdown.d.ts.map +1 -0
- package/dist/src/components/simple_markdown/simple_markdown.jsx +137 -0
- package/dist/src/components/simple_markdown/simple_markdown.jsx.map +1 -0
- package/dist/src/components/simple_markdown/simple_markdown_components.d.ts +26 -0
- package/dist/src/components/simple_markdown/simple_markdown_components.d.ts.map +1 -0
- package/dist/src/components/simple_markdown/simple_markdown_components.jsx +193 -0
- package/dist/src/components/simple_markdown/simple_markdown_components.jsx.map +1 -0
- package/dist/src/components/tag.d.ts +38 -0
- package/dist/src/components/tag.d.ts.map +1 -0
- package/dist/src/components/tag.jsx +126 -0
- package/dist/src/components/tag.jsx.map +1 -0
- package/dist/src/components/text/heading_content.d.ts +10 -0
- package/dist/src/components/text/heading_content.d.ts.map +1 -0
- package/dist/src/components/text/heading_content.jsx +31 -0
- package/dist/src/components/text/heading_content.jsx.map +1 -0
- package/dist/src/components/text/heading_marketing.d.ts +10 -0
- package/dist/src/components/text/heading_marketing.d.ts.map +1 -0
- package/dist/src/components/text/heading_marketing.jsx +31 -0
- package/dist/src/components/text/heading_marketing.jsx.map +1 -0
- package/dist/src/components/text/heading_shared.d.ts +10 -0
- package/dist/src/components/text/heading_shared.d.ts.map +1 -0
- package/dist/src/components/text/heading_shared.jsx +32 -0
- package/dist/src/components/text/heading_shared.jsx.map +1 -0
- package/dist/src/components/text/index.d.ts +12 -0
- package/dist/src/components/text/index.d.ts.map +1 -0
- package/dist/src/components/text/index.js +11 -0
- package/dist/src/components/text/index.js.map +1 -0
- package/dist/src/components/text/text_base.d.ts +13 -0
- package/dist/src/components/text/text_base.d.ts.map +1 -0
- package/dist/src/components/text/text_base.jsx +23 -0
- package/dist/src/components/text/text_base.jsx.map +1 -0
- package/dist/src/components/text/text_content.d.ts +11 -0
- package/dist/src/components/text/text_content.d.ts.map +1 -0
- package/dist/src/components/text/text_content.jsx +68 -0
- package/dist/src/components/text/text_content.jsx.map +1 -0
- package/dist/src/components/text/text_marketing.d.ts +11 -0
- package/dist/src/components/text/text_marketing.d.ts.map +1 -0
- package/dist/src/components/text/text_marketing.jsx +116 -0
- package/dist/src/components/text/text_marketing.jsx.map +1 -0
- package/dist/src/components/text/text_shared.d.ts +14 -0
- package/dist/src/components/text/text_shared.d.ts.map +1 -0
- package/dist/src/components/text/text_shared.jsx +55 -0
- package/dist/src/components/text/text_shared.jsx.map +1 -0
- package/dist/src/components/tile/horizontal_tile.d.ts +9 -0
- package/dist/src/components/tile/horizontal_tile.d.ts.map +1 -0
- package/dist/src/components/tile/horizontal_tile.jsx +43 -0
- package/dist/src/components/tile/horizontal_tile.jsx.map +1 -0
- package/dist/src/components/tile/index.d.ts +3 -0
- package/dist/src/components/tile/index.d.ts.map +1 -0
- package/dist/src/components/tile/index.js +3 -0
- package/dist/src/components/tile/index.js.map +1 -0
- package/dist/src/components/tile/shared.d.ts +17 -0
- package/dist/src/components/tile/shared.d.ts.map +1 -0
- package/dist/src/components/tile/shared.js +12 -0
- package/dist/src/components/tile/shared.js.map +1 -0
- package/dist/src/components/tile/vertical_tile.d.ts +10 -0
- package/dist/src/components/tile/vertical_tile.d.ts.map +1 -0
- package/dist/src/components/tile/vertical_tile.jsx +32 -0
- package/dist/src/components/tile/vertical_tile.jsx.map +1 -0
- package/dist/src/components/to_consolidate/card.d.ts +27 -0
- package/dist/src/components/to_consolidate/card.d.ts.map +1 -0
- package/dist/src/components/to_consolidate/card.jsx +93 -0
- package/dist/src/components/to_consolidate/card.jsx.map +1 -0
- package/dist/src/components/to_consolidate/index.d.ts +5 -0
- package/dist/src/components/to_consolidate/index.d.ts.map +1 -0
- package/dist/src/components/to_consolidate/index.js +5 -0
- package/dist/src/components/to_consolidate/index.js.map +1 -0
- package/dist/src/components/to_consolidate/markdown.d.ts +40 -0
- package/dist/src/components/to_consolidate/markdown.d.ts.map +1 -0
- package/dist/src/components/to_consolidate/markdown.jsx +454 -0
- package/dist/src/components/to_consolidate/markdown.jsx.map +1 -0
- package/dist/src/components/to_consolidate/pagination.d.ts +8 -0
- package/dist/src/components/to_consolidate/pagination.d.ts.map +1 -0
- package/dist/src/components/to_consolidate/pagination.jsx +88 -0
- package/dist/src/components/to_consolidate/pagination.jsx.map +1 -0
- package/dist/src/components/to_consolidate/tab_number_chip.d.ts +7 -0
- package/dist/src/components/to_consolidate/tab_number_chip.d.ts.map +1 -0
- package/dist/src/components/to_consolidate/tab_number_chip.jsx +22 -0
- package/dist/src/components/to_consolidate/tab_number_chip.jsx.map +1 -0
- package/dist/src/design_system/colors_theme.d.ts +213 -0
- package/dist/src/design_system/colors_theme.d.ts.map +1 -0
- package/dist/src/design_system/colors_theme.js +213 -0
- package/dist/src/design_system/colors_theme.js.map +1 -0
- package/dist/src/design_system/properties_theme.d.ts +175 -0
- package/dist/src/design_system/properties_theme.d.ts.map +1 -0
- package/dist/src/design_system/properties_theme.js +315 -0
- package/dist/src/design_system/properties_theme.js.map +1 -0
- package/dist/src/design_system/theme.d.ts +630 -0
- package/dist/src/design_system/theme.d.ts.map +1 -0
- package/dist/src/design_system/theme.js +17 -0
- package/dist/src/design_system/theme.js.map +1 -0
- package/dist/src/design_system/tokens/index.d.ts +6 -0
- package/dist/src/design_system/tokens/index.d.ts.map +1 -0
- package/dist/src/design_system/tokens/index.js +6 -0
- package/dist/src/design_system/tokens/index.js.map +1 -0
- package/dist/src/design_system/tokens/layouts.d.ts +29 -0
- package/dist/src/design_system/tokens/layouts.d.ts.map +1 -0
- package/dist/src/design_system/tokens/layouts.js +29 -0
- package/dist/src/design_system/tokens/layouts.js.map +1 -0
- package/dist/src/design_system/tokens/radiuses.d.ts +23 -0
- package/dist/src/design_system/tokens/radiuses.d.ts.map +1 -0
- package/dist/src/design_system/tokens/radiuses.js +23 -0
- package/dist/src/design_system/tokens/radiuses.js.map +1 -0
- package/dist/src/design_system/tokens/shadows.d.ts +23 -0
- package/dist/src/design_system/tokens/shadows.d.ts.map +1 -0
- package/dist/src/design_system/tokens/shadows.js +23 -0
- package/dist/src/design_system/tokens/shadows.js.map +1 -0
- package/dist/src/design_system/tokens/spaces.d.ts +15 -0
- package/dist/src/design_system/tokens/spaces.d.ts.map +1 -0
- package/dist/src/design_system/tokens/spaces.js +14 -0
- package/dist/src/design_system/tokens/spaces.js.map +1 -0
- package/dist/src/design_system/tokens/transitions.d.ts +20 -0
- package/dist/src/design_system/tokens/transitions.d.ts.map +1 -0
- package/dist/src/design_system/tokens/transitions.js +20 -0
- package/dist/src/design_system/tokens/transitions.js.map +1 -0
- package/dist/src/design_system/typography_theme.d.ts +189 -0
- package/dist/src/design_system/typography_theme.d.ts.map +1 -0
- package/dist/src/design_system/typography_theme.js +190 -0
- package/dist/src/design_system/typography_theme.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/type_utils.d.ts +6 -0
- package/dist/src/type_utils.d.ts.map +1 -0
- package/dist/src/type_utils.js +2 -0
- package/dist/src/type_utils.js.map +1 -0
- package/dist/src/ui_dependency_provider.d.ts +29 -0
- package/dist/src/ui_dependency_provider.d.ts.map +1 -0
- package/dist/src/ui_dependency_provider.jsx +14 -0
- package/dist/src/ui_dependency_provider.jsx.map +1 -0
- package/dist/src/utils/copy_to_clipboard.d.ts +7 -0
- package/dist/src/utils/copy_to_clipboard.d.ts.map +1 -0
- package/dist/src/utils/copy_to_clipboard.js +16 -0
- package/dist/src/utils/copy_to_clipboard.js.map +1 -0
- package/dist/src/utils/image_color.d.ts +7 -0
- package/dist/src/utils/image_color.d.ts.map +1 -0
- package/dist/src/utils/image_color.js +35 -0
- package/dist/src/utils/image_color.js.map +1 -0
- package/dist/src/utils/index.d.ts +4 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +4 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/sanitization.d.ts +11 -0
- package/dist/src/utils/sanitization.d.ts.map +1 -0
- package/dist/src/utils/sanitization.js +16 -0
- package/dist/src/utils/sanitization.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +71 -0
- package/src/codemods/generate_color_property_tokens.mjs +97 -0
- package/src/codemods/generate_color_theme_files.mjs +46 -0
- package/src/codemods/generate_typograpy_tokens_files.mjs +136 -0
- package/src/components/action_link.tsx +59 -0
- package/src/components/actor_template_card.tsx +99 -0
- package/src/components/badge.tsx +144 -0
- package/src/components/banner.tsx +95 -0
- package/src/components/blog_article.tsx +85 -0
- package/src/components/box.tsx +127 -0
- package/src/components/button.tsx +303 -0
- package/src/components/chip.tsx +121 -0
- package/src/components/code/action_button.tsx +96 -0
- package/src/components/code/code_block/code_block.styled.tsx +228 -0
- package/src/components/code/code_block/code_block.tsx +235 -0
- package/src/components/code/code_block/utils.ts +19 -0
- package/src/components/code/index.ts +3 -0
- package/src/components/code/inline_code/inline_code.tsx +44 -0
- package/src/components/code/one_line_code/one_line_code.tsx +232 -0
- package/src/components/code/syntax_highlighter.tsx +125 -0
- package/src/components/color_wheel_gradient.tsx +31 -0
- package/src/components/floating/index.ts +3 -0
- package/src/components/floating/menu.tsx +191 -0
- package/src/components/floating/menu_common.tsx +31 -0
- package/src/components/floating/menu_components.tsx +94 -0
- package/src/components/image.tsx +23 -0
- package/src/components/index.ts +20 -0
- package/src/components/link.tsx +114 -0
- package/src/components/message.tsx +157 -0
- package/src/components/readme_renderer/index.ts +3 -0
- package/src/components/readme_renderer/pythonize_value.ts +78 -0
- package/src/components/readme_renderer/table_of_contents.tsx +257 -0
- package/src/components/readme_renderer/utils.tsx +46 -0
- package/src/components/simple_markdown/index.tsx +2 -0
- package/src/components/simple_markdown/simple_markdown.tsx +181 -0
- package/src/components/simple_markdown/simple_markdown_components.tsx +295 -0
- package/src/components/tag.tsx +185 -0
- package/src/components/text/heading_content.tsx +56 -0
- package/src/components/text/heading_marketing.tsx +55 -0
- package/src/components/text/heading_shared.tsx +57 -0
- package/src/components/text/index.ts +18 -0
- package/src/components/text/text_base.tsx +52 -0
- package/src/components/text/text_content.tsx +104 -0
- package/src/components/text/text_marketing.tsx +152 -0
- package/src/components/text/text_shared.tsx +96 -0
- package/src/components/tile/horizontal_tile.tsx +76 -0
- package/src/components/tile/index.ts +2 -0
- package/src/components/tile/shared.ts +27 -0
- package/src/components/tile/vertical_tile.tsx +58 -0
- package/src/components/to_consolidate/card.tsx +141 -0
- package/src/components/to_consolidate/index.ts +4 -0
- package/src/components/to_consolidate/markdown.tsx +593 -0
- package/src/components/to_consolidate/pagination.tsx +139 -0
- package/src/components/to_consolidate/tab_number_chip.tsx +31 -0
- package/src/design_system/colors_theme.ts +213 -0
- package/src/design_system/generate_color_definitions.js +43 -0
- package/src/design_system/properties_theme.ts +453 -0
- package/src/design_system/supernova_color_tokens.json +1766 -0
- package/src/design_system/supernova_typography_tokens.json +657 -0
- package/src/design_system/theme.ts +26 -0
- package/src/design_system/tokens/index.ts +5 -0
- package/src/design_system/tokens/layouts.ts +29 -0
- package/src/design_system/tokens/radiuses.ts +22 -0
- package/src/design_system/tokens/shadows.ts +22 -0
- package/src/design_system/tokens/spaces.ts +15 -0
- package/src/design_system/tokens/transitions.ts +19 -0
- package/src/design_system/typography_theme.ts +197 -0
- package/src/index.ts +7 -0
- package/src/type_utils.ts +7 -0
- package/src/ui_dependency_provider.tsx +50 -0
- package/src/utils/copy_to_clipboard.ts +24 -0
- package/src/utils/image_color.ts +44 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/sanitization.ts +14 -0
- package/tsconfig.build.json +18 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import qs from 'query-string';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { CodeProps, ReactMarkdownProps } from 'react-markdown/lib/ast-to-react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
|
|
6
|
+
import { Check16, Link16 } from '@apify/icons';
|
|
7
|
+
|
|
8
|
+
import { theme } from '../../design_system/theme';
|
|
9
|
+
import type { WithOptional } from '../../type_utils';
|
|
10
|
+
import { useCopyToClipboard } from '../../utils';
|
|
11
|
+
import { Box } from '../box';
|
|
12
|
+
import { CodeBlock, InlineCode, OneLineCode } from '../code';
|
|
13
|
+
import type { LinkProps } from '../link';
|
|
14
|
+
import { Link } from '../link';
|
|
15
|
+
import { slugifyHeadingChildren } from '../readme_renderer/utils';
|
|
16
|
+
import { Heading } from '../text';
|
|
17
|
+
import type { HeadingSharedProps } from '../text/heading_shared';
|
|
18
|
+
import type { SharedTextProps, SharedTextSize } from '../text/text_shared';
|
|
19
|
+
|
|
20
|
+
const simpleMarkdownClassNames = {
|
|
21
|
+
HEADING_ICON_LINK: 'headingIconLink',
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
export const MarkdownPlainHeading: React.FC<HeadingSharedProps> = ({
|
|
25
|
+
children,
|
|
26
|
+
...rest
|
|
27
|
+
}) => {
|
|
28
|
+
const id = slugifyHeadingChildren(children);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Heading
|
|
32
|
+
mt='space32'
|
|
33
|
+
mb='space16'
|
|
34
|
+
id={id}
|
|
35
|
+
{...rest}
|
|
36
|
+
>
|
|
37
|
+
{children}
|
|
38
|
+
</Heading>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const StyledMarkdownHeading = styled(Box)`
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: ${theme.space.space4};
|
|
46
|
+
|
|
47
|
+
.${simpleMarkdownClassNames.HEADING_ICON_LINK} {
|
|
48
|
+
height: 16px;
|
|
49
|
+
display: none;
|
|
50
|
+
|
|
51
|
+
svg {
|
|
52
|
+
max-height: 1em !important;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:hover {
|
|
57
|
+
.${simpleMarkdownClassNames.HEADING_ICON_LINK} {
|
|
58
|
+
display: initial;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Default markdown heading that renders copy icon next to it.
|
|
65
|
+
* Use `MarkdownPlainHeading` if you want to render simple heading instead
|
|
66
|
+
*/
|
|
67
|
+
// TODO: This should be used for readmes
|
|
68
|
+
export const MarkdownHeadingWrapper: React.FC<HeadingSharedProps> = ({
|
|
69
|
+
children,
|
|
70
|
+
...rest
|
|
71
|
+
}) => {
|
|
72
|
+
const id = slugifyHeadingChildren(children);
|
|
73
|
+
|
|
74
|
+
const [isCopied, handleClick] = useCopyToClipboard({
|
|
75
|
+
text: id ?? '',
|
|
76
|
+
// We want the whole URL to be copied, not just the ID
|
|
77
|
+
transform: (text) => {
|
|
78
|
+
const url = new URL(window.location.href);
|
|
79
|
+
url.hash = `#${text}`;
|
|
80
|
+
return url.toString();
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<StyledMarkdownHeading
|
|
86
|
+
mt='space32'
|
|
87
|
+
mb='space16'
|
|
88
|
+
id={id}
|
|
89
|
+
{...rest}
|
|
90
|
+
>
|
|
91
|
+
{children}
|
|
92
|
+
<Link
|
|
93
|
+
className={simpleMarkdownClassNames.HEADING_ICON_LINK}
|
|
94
|
+
onClick={handleClick}
|
|
95
|
+
to={`#${id}`}
|
|
96
|
+
>
|
|
97
|
+
{isCopied ? (
|
|
98
|
+
<Check16
|
|
99
|
+
color={theme.color.success.action}
|
|
100
|
+
viewBox="0 0 16 16"
|
|
101
|
+
/>
|
|
102
|
+
) : (
|
|
103
|
+
<Link16
|
|
104
|
+
color={theme.color.primary.text}
|
|
105
|
+
viewBox="0 0 16 16"
|
|
106
|
+
/>
|
|
107
|
+
)}
|
|
108
|
+
</Link>
|
|
109
|
+
</StyledMarkdownHeading>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// TODO: This should be used for readmes
|
|
114
|
+
export const MarkdownParagraphContent: React.FC<SharedTextProps & Pick<ReactMarkdownProps, 'node'>> = ({
|
|
115
|
+
children,
|
|
116
|
+
node,
|
|
117
|
+
}) => {
|
|
118
|
+
const child = node.children[0];
|
|
119
|
+
const isText = child?.type === 'text';
|
|
120
|
+
|
|
121
|
+
const videoSrc = isText && getVideoSrc(child.value);
|
|
122
|
+
if (videoSrc) return <MarkdownVideo src={videoSrc} />;
|
|
123
|
+
|
|
124
|
+
// the || null part is important because non-supported elements will fall back to this paragraph component;
|
|
125
|
+
return children || null;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const StyledInlineCode = styled(InlineCode)`
|
|
129
|
+
/* If code is rendered within heading, it should inherit its font styles */
|
|
130
|
+
/* TODO: Look at implementation of InlineCode - maybe we can live without it */
|
|
131
|
+
h1 & code, h2 & code, h3 & code, h4 & code, h5 & code {
|
|
132
|
+
font-size: inherit !important;
|
|
133
|
+
line-height: inherit !important;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
b & code, strong & code{
|
|
137
|
+
font-weight: inherit !important;
|
|
138
|
+
}
|
|
139
|
+
`;
|
|
140
|
+
|
|
141
|
+
type MarkdownCodeProps = Pick<CodeProps, 'inline' | 'className' | 'children'>
|
|
142
|
+
|
|
143
|
+
export const MarkdownCode: React.FC<MarkdownCodeProps & { size: SharedTextSize }> = ({
|
|
144
|
+
inline,
|
|
145
|
+
className,
|
|
146
|
+
children,
|
|
147
|
+
size,
|
|
148
|
+
}) => {
|
|
149
|
+
if (inline) {
|
|
150
|
+
return <StyledInlineCode size={size} className={className}>{children}</StyledInlineCode>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const code = String(children).replace(/\n$/, '').trim();
|
|
154
|
+
const match = /language-(\w+)/.exec(className || '');
|
|
155
|
+
const language = match?.[1]?.toLowerCase();
|
|
156
|
+
const isOneLineCode = code.split('\n').length <= 1;
|
|
157
|
+
|
|
158
|
+
if (isOneLineCode) {
|
|
159
|
+
return (
|
|
160
|
+
<OneLineCode
|
|
161
|
+
language={language}
|
|
162
|
+
size={size}
|
|
163
|
+
fullWidth
|
|
164
|
+
>
|
|
165
|
+
{code}
|
|
166
|
+
</OneLineCode>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!inline) {
|
|
171
|
+
return (
|
|
172
|
+
<CodeBlock
|
|
173
|
+
content={code}
|
|
174
|
+
language={language}
|
|
175
|
+
size={size}
|
|
176
|
+
hideLineNumbers
|
|
177
|
+
fullWidth
|
|
178
|
+
hideBashHeader
|
|
179
|
+
hideBashPromptPrefixes
|
|
180
|
+
/>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const youtubeRegex = /^(?:https?:\/\/)?(?:www\.)?(?:m\.)?(?:youtube(?:-nocookie)?\.com|youtu\.be)\/(?:watch\?v=|embed\/|v\/)?([a-zA-Z0-9\-_]+)(?:\S*)?$/;
|
|
186
|
+
const vimeoRegex = /^((?:https?:\/\/)?(?:player\.)?vimeo\.com(?:\/video)?\/(\d+))$/;
|
|
187
|
+
|
|
188
|
+
const getVideoSrc = (link: string) => {
|
|
189
|
+
const youtubeLink = link.match(youtubeRegex);
|
|
190
|
+
const vimeoLink = link.match(vimeoRegex);
|
|
191
|
+
let src;
|
|
192
|
+
if (youtubeLink) {
|
|
193
|
+
// add rel=0 to disable related videos from other channels at the end of the video
|
|
194
|
+
// add enablejsapi=1 to enable tracking videos via API through Google Analytics
|
|
195
|
+
src = qs.stringifyUrl({ url: `https://www.youtube.com/embed/${youtubeLink[1]}`, query: { rel: 0, enablejsapi: 1 } });
|
|
196
|
+
}
|
|
197
|
+
if (vimeoLink) src = `https://player.vimeo.com/video/${vimeoLink[2]}`;
|
|
198
|
+
|
|
199
|
+
return src;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const StyledVideo = styled.div`
|
|
203
|
+
width: 65%;
|
|
204
|
+
|
|
205
|
+
& > div {
|
|
206
|
+
position: relative;
|
|
207
|
+
overflow: hidden;
|
|
208
|
+
width: 100%;
|
|
209
|
+
padding-top: 56.25%;
|
|
210
|
+
|
|
211
|
+
& > iframe {
|
|
212
|
+
position: absolute;
|
|
213
|
+
top: 0;
|
|
214
|
+
left: 0;
|
|
215
|
+
bottom: 0;
|
|
216
|
+
right: 0;
|
|
217
|
+
width: 100%;
|
|
218
|
+
height: 100%;
|
|
219
|
+
border: 0px;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
|
|
224
|
+
interface MarkdownVideoProps {
|
|
225
|
+
src: string;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const MarkdownVideo = ({ src }: MarkdownVideoProps) => {
|
|
229
|
+
return (
|
|
230
|
+
<StyledVideo>
|
|
231
|
+
<div>
|
|
232
|
+
<iframe loading="lazy" allowFullScreen src={src} />
|
|
233
|
+
</div>
|
|
234
|
+
</StyledVideo>
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const StyledMarkdownLink = styled(Link)`
|
|
239
|
+
overflow-wrap: break-word;
|
|
240
|
+
|
|
241
|
+
h1 &, h2 &, h3 &, h4 &, h5 & {
|
|
242
|
+
overflow-wrap: normal;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
&:hover {
|
|
246
|
+
/* Links normally don't have underline, but in markdown we want to have it */
|
|
247
|
+
text-decoration: underline;
|
|
248
|
+
}
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
export const MarkdownLink: React.FC<WithOptional<LinkProps, 'to'>> = ({
|
|
252
|
+
to,
|
|
253
|
+
children,
|
|
254
|
+
rel,
|
|
255
|
+
className,
|
|
256
|
+
}) => {
|
|
257
|
+
return (to && typeof to === 'string') ? (
|
|
258
|
+
<StyledMarkdownLink to={to} hideExternalIcon={true} rel={rel} className={className}>{children}</StyledMarkdownLink>
|
|
259
|
+
) : (
|
|
260
|
+
<span>{children}</span> // Invalid links can be rendered as a regular span instead
|
|
261
|
+
);
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export const MarkdownBlockQuote = styled(Box).attrs({
|
|
265
|
+
my: 'space16',
|
|
266
|
+
py: 'none',
|
|
267
|
+
forwardedAs: 'blockquote',
|
|
268
|
+
})`
|
|
269
|
+
border-left: 2px solid ${theme.color.neutral.separatorSubtle};
|
|
270
|
+
padding-left: ${theme.space.space16};
|
|
271
|
+
|
|
272
|
+
color: ${theme.color.neutral.textMuted};
|
|
273
|
+
|
|
274
|
+
& > p {
|
|
275
|
+
margin: 0;
|
|
276
|
+
}
|
|
277
|
+
`;
|
|
278
|
+
|
|
279
|
+
export const MarkdownTable = styled.table`
|
|
280
|
+
display: block;
|
|
281
|
+
overflow: auto;
|
|
282
|
+
border-collapse: collapse;
|
|
283
|
+
|
|
284
|
+
td, th {
|
|
285
|
+
border: 1px solid ${theme.color.neutral.border};
|
|
286
|
+
padding: ${theme.space.space16};
|
|
287
|
+
text-align: left;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
tr:nth-child(even):not([class]) {
|
|
291
|
+
> th, > td {
|
|
292
|
+
background-color: inherit;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
`;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React, { type ForwardedRef, forwardRef } from 'react';
|
|
2
|
+
import styled, { css, type FlattenSimpleInterpolation } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconComponent, IconSize } from '@apify/ui-icons';
|
|
5
|
+
|
|
6
|
+
import { theme } from '../design_system/theme';
|
|
7
|
+
import type { WithTransientProps } from '../type_utils';
|
|
8
|
+
import { Box, type MarginSpacingProps, type RegularBoxProps } from './box';
|
|
9
|
+
import { Link, type RegularLinkProps } from './link';
|
|
10
|
+
|
|
11
|
+
type TagSize = typeof TAG_SIZES[number];
|
|
12
|
+
|
|
13
|
+
export const TAG_SIZES = ['large', 'medium', 'small'] as const;
|
|
14
|
+
|
|
15
|
+
const TAG_ICON_SIZES = {
|
|
16
|
+
large: '20',
|
|
17
|
+
medium: '16',
|
|
18
|
+
small: '12',
|
|
19
|
+
} satisfies Record<TagSize, IconSize>;
|
|
20
|
+
|
|
21
|
+
const tagSizeStyle = {
|
|
22
|
+
large: css`
|
|
23
|
+
height: 4rem;
|
|
24
|
+
padding: ${theme.space.space8} ${theme.space.space12};
|
|
25
|
+
border-radius: ${theme.radius.radius12};
|
|
26
|
+
${theme.typography.shared.desktop.bodyLMedium}
|
|
27
|
+
`,
|
|
28
|
+
medium: css`
|
|
29
|
+
height: 2.8rem;
|
|
30
|
+
padding: ${theme.space.space4} ${theme.space.space8};
|
|
31
|
+
border-radius: ${theme.radius.radius8};
|
|
32
|
+
${theme.typography.shared.desktop.bodyMMedium}
|
|
33
|
+
`,
|
|
34
|
+
small: css`
|
|
35
|
+
height: 2rem;
|
|
36
|
+
padding: ${theme.space.space2} ${theme.space.space6};
|
|
37
|
+
border-radius: ${theme.radius.radius4};
|
|
38
|
+
${theme.typography.shared.desktop.bodySMedium}
|
|
39
|
+
|
|
40
|
+
&:has(> svg:last-child:nth-child(1)) {
|
|
41
|
+
padding: ${theme.space.space2} ${theme.space.space4};
|
|
42
|
+
}
|
|
43
|
+
`,
|
|
44
|
+
} satisfies Record<TagSize, FlattenSimpleInterpolation>;
|
|
45
|
+
|
|
46
|
+
type TagVariant = typeof TAG_VARIANTS[number];
|
|
47
|
+
|
|
48
|
+
export const TAG_VARIANTS = ['primary', 'secondary', 'accent', 'success', 'warning', 'error'] as const;
|
|
49
|
+
|
|
50
|
+
const tagVariantStyle = {
|
|
51
|
+
primary: css`
|
|
52
|
+
color: ${theme.color.neutral.text};
|
|
53
|
+
fill: ${theme.color.neutral.icon};
|
|
54
|
+
background: transparent;
|
|
55
|
+
box-shadow: inset 0 0 0 1px ${theme.color.neutral.border};
|
|
56
|
+
|
|
57
|
+
&:hover {
|
|
58
|
+
background: ${theme.color.neutral.hover};
|
|
59
|
+
}
|
|
60
|
+
`,
|
|
61
|
+
secondary: css`
|
|
62
|
+
color: ${theme.color.neutral.text};
|
|
63
|
+
fill: ${theme.color.neutral.icon};
|
|
64
|
+
background: transparent;
|
|
65
|
+
|
|
66
|
+
&:hover {
|
|
67
|
+
background: ${theme.color.neutral.hover};
|
|
68
|
+
}
|
|
69
|
+
`,
|
|
70
|
+
accent: css`
|
|
71
|
+
color: ${theme.color.primary.chipText};
|
|
72
|
+
fill: ${theme.color.primary.chipText};
|
|
73
|
+
background: ${theme.color.primary.background};
|
|
74
|
+
|
|
75
|
+
&:hover {
|
|
76
|
+
background: ${theme.color.primary.backgroundHover};
|
|
77
|
+
}
|
|
78
|
+
`,
|
|
79
|
+
success: css`
|
|
80
|
+
color: ${theme.color.success.chipText};
|
|
81
|
+
fill: ${theme.color.success.chipText};
|
|
82
|
+
background: ${theme.color.success.background};
|
|
83
|
+
|
|
84
|
+
&:hover {
|
|
85
|
+
background: ${theme.color.success.backgroundHover};
|
|
86
|
+
}
|
|
87
|
+
`,
|
|
88
|
+
warning: css`
|
|
89
|
+
color: ${theme.color.warning.chipText};
|
|
90
|
+
fill: ${theme.color.warning.chipText};
|
|
91
|
+
background: ${theme.color.warning.background};
|
|
92
|
+
|
|
93
|
+
&:hover {
|
|
94
|
+
background: ${theme.color.warning.backgroundHover};
|
|
95
|
+
}
|
|
96
|
+
`,
|
|
97
|
+
error: css`
|
|
98
|
+
color: ${theme.color.danger.chipText};
|
|
99
|
+
fill: ${theme.color.danger.chipText};
|
|
100
|
+
background: ${theme.color.danger.background};
|
|
101
|
+
|
|
102
|
+
&:hover {
|
|
103
|
+
background: ${theme.color.danger.backgroundHover};
|
|
104
|
+
}
|
|
105
|
+
`,
|
|
106
|
+
} satisfies Record<TagVariant, FlattenSimpleInterpolation>;
|
|
107
|
+
|
|
108
|
+
type StyledTagProps = WithTransientProps<
|
|
109
|
+
Required<Pick<TagProps<any>, 'size' | 'variant'>>
|
|
110
|
+
>;
|
|
111
|
+
|
|
112
|
+
const StyledTag = styled(Box)<StyledTagProps>`
|
|
113
|
+
${({ $size }) => tagSizeStyle[$size]};
|
|
114
|
+
${({ $variant }) => tagVariantStyle[$variant]};
|
|
115
|
+
|
|
116
|
+
/* Static styles */
|
|
117
|
+
width: fit-content;
|
|
118
|
+
border: none;
|
|
119
|
+
outline: none;
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-direction: row;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
align-items: center;
|
|
124
|
+
white-space: nowrap;
|
|
125
|
+
gap: ${theme.space.space4};
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
transition: background ${theme.transition.fastEaseOut};
|
|
128
|
+
`;
|
|
129
|
+
|
|
130
|
+
type TagNodeType = Extract<React.ElementType, 'a' | 'button'>;
|
|
131
|
+
type TagNodePropsMap = {
|
|
132
|
+
a: {
|
|
133
|
+
element: HTMLAnchorElement;
|
|
134
|
+
props: RegularLinkProps;
|
|
135
|
+
};
|
|
136
|
+
button: {
|
|
137
|
+
element: HTMLButtonElement;
|
|
138
|
+
props: React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export type TagProps<T extends TagNodeType> = RegularBoxProps & MarginSpacingProps & ({
|
|
143
|
+
as?: T;
|
|
144
|
+
size?: TagSize;
|
|
145
|
+
variant?: TagVariant;
|
|
146
|
+
LeadingIcon?: IconComponent;
|
|
147
|
+
TrailingIcon?: IconComponent;
|
|
148
|
+
} & Omit<TagNodePropsMap[T]['props'], 'size'>);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Component for displaying inherenly interactive chip descendant
|
|
152
|
+
*/
|
|
153
|
+
function TagWrapper<T extends TagNodeType>({
|
|
154
|
+
as,
|
|
155
|
+
size = 'small',
|
|
156
|
+
variant = 'primary',
|
|
157
|
+
LeadingIcon,
|
|
158
|
+
TrailingIcon,
|
|
159
|
+
children,
|
|
160
|
+
...props
|
|
161
|
+
}: TagProps<T>,
|
|
162
|
+
ref: ForwardedRef<TagNodePropsMap[T]['element']>,
|
|
163
|
+
) {
|
|
164
|
+
const component: React.ElementType = (as === 'a' ? Link : as ?? 'button');
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<StyledTag
|
|
168
|
+
as={component}
|
|
169
|
+
ref={ref}
|
|
170
|
+
$variant={variant}
|
|
171
|
+
$size={size}
|
|
172
|
+
{...props}
|
|
173
|
+
>
|
|
174
|
+
{LeadingIcon && <LeadingIcon size={TAG_ICON_SIZES[size]} />}
|
|
175
|
+
{children}
|
|
176
|
+
{TrailingIcon && <TrailingIcon size={TAG_ICON_SIZES[size]} />}
|
|
177
|
+
</StyledTag>
|
|
178
|
+
);
|
|
179
|
+
};
|
|
180
|
+
TagWrapper.displayName = 'Tag';
|
|
181
|
+
|
|
182
|
+
// `forwardRef` can't handle generic types, should be fixable with React 19
|
|
183
|
+
export const Tag = forwardRef(TagWrapper) as <T extends TagNodeType>(
|
|
184
|
+
props: TagProps<T> & { ref?: ForwardedRef<TagNodePropsMap[T]['element']> },
|
|
185
|
+
) => ReturnType<typeof TagWrapper>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { theme } from '../../design_system/theme';
|
|
5
|
+
import type { WithTransientProps } from '../../type_utils';
|
|
6
|
+
import type { TextBaseProps } from './text_base';
|
|
7
|
+
import { TextBaseComponent } from './text_base';
|
|
8
|
+
|
|
9
|
+
type HeadingContentType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6';
|
|
10
|
+
|
|
11
|
+
interface HeadingContentTransientProps {
|
|
12
|
+
type?: HeadingContentType,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getContentHeadingStyles = (headingType: HeadingContentType) => css`
|
|
16
|
+
${theme.typography.content.mobile[headingType]}
|
|
17
|
+
|
|
18
|
+
@media (min-width: ${theme.layout.tablet}) {
|
|
19
|
+
${theme.typography.content.tablet[headingType]}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@media (min-width: ${theme.layout.desktop}) {
|
|
23
|
+
${theme.typography.content.desktop[headingType]}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
type StyledHeadingContentProps = WithTransientProps<HeadingContentTransientProps>;
|
|
28
|
+
export type HeadingContentProps = HeadingContentTransientProps & TextBaseProps;
|
|
29
|
+
|
|
30
|
+
const HEADING_CONTENT_DEFAULT_ELEMENTS = {
|
|
31
|
+
heading1: 'h1',
|
|
32
|
+
heading2: 'h2',
|
|
33
|
+
heading3: 'h3',
|
|
34
|
+
heading4: 'h4',
|
|
35
|
+
heading5: 'h5',
|
|
36
|
+
heading6: 'h6',
|
|
37
|
+
} as const;
|
|
38
|
+
|
|
39
|
+
const StyledHeadingContent = styled(TextBaseComponent)<StyledHeadingContentProps>`
|
|
40
|
+
${(props) => getContentHeadingStyles(props.$type || 'heading1')}
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
export const HeadingContent: React.FC<HeadingContentProps> = ({
|
|
44
|
+
type,
|
|
45
|
+
as,
|
|
46
|
+
...rest
|
|
47
|
+
}) => {
|
|
48
|
+
return (
|
|
49
|
+
<StyledHeadingContent
|
|
50
|
+
$type={type}
|
|
51
|
+
forwardedAs={as || HEADING_CONTENT_DEFAULT_ELEMENTS[type || 'heading1']}
|
|
52
|
+
m='none'
|
|
53
|
+
{...rest}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { theme } from '../../design_system/theme';
|
|
5
|
+
import type { WithTransientProps } from '../../type_utils';
|
|
6
|
+
import type { TextBaseProps } from './text_base';
|
|
7
|
+
import { TextBaseComponent } from './text_base';
|
|
8
|
+
|
|
9
|
+
type HeadingMarketingType = 'titleXs' | 'titleS' | 'titleM' | 'titleL' | 'titleXl' | 'title2xl' | 'title3xl';
|
|
10
|
+
|
|
11
|
+
interface HeadingMarketingTransientProps {
|
|
12
|
+
type?: HeadingMarketingType,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type StyledHeadingMarketingProps = WithTransientProps<HeadingMarketingTransientProps>;
|
|
16
|
+
export type HeadingMarketingProps = HeadingMarketingTransientProps & TextBaseProps;
|
|
17
|
+
|
|
18
|
+
const HEADING_MARKETING_DEFAULT_ELEMENTS: { [Type in HeadingMarketingType]: string } = {
|
|
19
|
+
titleXs: 'h6',
|
|
20
|
+
titleS: 'h5',
|
|
21
|
+
titleM: 'h4',
|
|
22
|
+
titleL: 'h3',
|
|
23
|
+
titleXl: 'h2',
|
|
24
|
+
title2xl: 'h1',
|
|
25
|
+
title3xl: 'h1',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const StyledHeadingMarketing = styled(TextBaseComponent)<StyledHeadingMarketingProps>`
|
|
29
|
+
${(props) => `
|
|
30
|
+
${theme.typography.marketing.mobile[props.$type || 'titleL']}
|
|
31
|
+
|
|
32
|
+
@media (${theme.device.tablet}) {
|
|
33
|
+
${theme.typography.marketing.tablet[props.$type || 'titleL']}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@media (${theme.device.desktop}) {
|
|
37
|
+
${theme.typography.marketing.desktop[props.$type || 'titleL']}
|
|
38
|
+
}
|
|
39
|
+
`}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export const HeadingMarketing: React.FC<HeadingMarketingProps> = ({
|
|
43
|
+
type,
|
|
44
|
+
as,
|
|
45
|
+
...rest
|
|
46
|
+
}) => {
|
|
47
|
+
return (
|
|
48
|
+
<StyledHeadingMarketing
|
|
49
|
+
$type={type}
|
|
50
|
+
forwardedAs={as || HEADING_MARKETING_DEFAULT_ELEMENTS[type || 'titleL']}
|
|
51
|
+
m='none'
|
|
52
|
+
{...rest}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { theme } from '../../design_system/theme';
|
|
5
|
+
import type { WithTransientProps } from '../../type_utils';
|
|
6
|
+
import type { TextBaseProps } from './text_base';
|
|
7
|
+
import { TextBaseComponent } from './text_base';
|
|
8
|
+
|
|
9
|
+
type HeadingSharedType = 'titleXs' | 'titleS' | 'titleM' | 'titleL' | 'titleXl' | 'title2xl' | 'title3xl';
|
|
10
|
+
|
|
11
|
+
interface HeadingSharedTransientProps {
|
|
12
|
+
type?: HeadingSharedType,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type StyledHeadingSharedProps = WithTransientProps<HeadingSharedTransientProps>;
|
|
16
|
+
export type HeadingSharedProps = HeadingSharedTransientProps & TextBaseProps;
|
|
17
|
+
|
|
18
|
+
const HEADING_SHARED_DEFAULT_ELEMENTS: { [Type in HeadingSharedType]: string } = {
|
|
19
|
+
titleXs: 'h6',
|
|
20
|
+
titleS: 'h5',
|
|
21
|
+
titleM: 'h4',
|
|
22
|
+
titleL: 'h3',
|
|
23
|
+
titleXl: 'h2',
|
|
24
|
+
title2xl: 'h1',
|
|
25
|
+
title3xl: 'h1',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const StyledHeadingShared = styled(TextBaseComponent)<StyledHeadingSharedProps>`
|
|
29
|
+
${(props) => `
|
|
30
|
+
${theme.typography.shared.mobile[props.$type || 'titleL']}
|
|
31
|
+
|
|
32
|
+
@media (${theme.device.tablet}) {
|
|
33
|
+
${theme.typography.shared.tablet[props.$type || 'titleL']}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@media (${theme.device.desktop}) {
|
|
37
|
+
${theme.typography.shared.desktop[props.$type || 'titleL']}
|
|
38
|
+
}
|
|
39
|
+
`}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
const HeadingShared: React.FC<HeadingSharedProps> = ({
|
|
43
|
+
type,
|
|
44
|
+
as,
|
|
45
|
+
...rest
|
|
46
|
+
}) => {
|
|
47
|
+
return (
|
|
48
|
+
<StyledHeadingShared
|
|
49
|
+
$type={type}
|
|
50
|
+
forwardedAs={as || HEADING_SHARED_DEFAULT_ELEMENTS[type || 'titleL']}
|
|
51
|
+
m='none'
|
|
52
|
+
{...rest}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default HeadingShared;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import HeadingShared from './heading_shared';
|
|
2
|
+
import type { SharedTextProps } from './text_shared';
|
|
3
|
+
import TextShared from './text_shared';
|
|
4
|
+
|
|
5
|
+
export * from './text_base';
|
|
6
|
+
export * from './text_content';
|
|
7
|
+
export * from './text_marketing';
|
|
8
|
+
export * from './heading_content';
|
|
9
|
+
export * from './heading_marketing';
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
TextShared as Text, // Shared typography is the default
|
|
13
|
+
HeadingShared as Heading, // Shared typography is the default
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type {
|
|
17
|
+
SharedTextProps,
|
|
18
|
+
};
|