@xyd-js/components 0.1.0-xyd.11 → 0.1.0-xyd.13

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.
Files changed (256) hide show
  1. package/.idea/git_toolbox_blame.xml +6 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/.idea/xyd-components.iml +12 -0
  5. package/CHANGELOG.md +16 -0
  6. package/TODO.md +1 -0
  7. package/content.ts +0 -2
  8. package/dist/CTABanner-BD4wweO5.js +2 -0
  9. package/dist/CTABanner-BD4wweO5.js.map +1 -0
  10. package/dist/CTABanner-DLG0_gv8.js +2 -0
  11. package/dist/CTABanner-DLG0_gv8.js.map +1 -0
  12. package/dist/CTABanner-DpPtA-FL.js +2 -0
  13. package/dist/CTABanner-DpPtA-FL.js.map +1 -0
  14. package/dist/CodeSample--qfqZ1hL.js +2 -0
  15. package/dist/CodeSample--qfqZ1hL.js.map +1 -0
  16. package/dist/CodeSample-CqFaFwwz.js +2 -0
  17. package/dist/CodeSample-CqFaFwwz.js.map +1 -0
  18. package/dist/CodeSample-GbqwRbcO.js +2 -0
  19. package/dist/CodeSample-GbqwRbcO.js.map +1 -0
  20. package/dist/HomeView-BZdY0g_7.js +2 -0
  21. package/dist/{HomeView-DHdqouwJ.js.map → HomeView-BZdY0g_7.js.map} +1 -1
  22. package/dist/HomeView-C_mEMzjV.js +2 -0
  23. package/dist/{HomeView-TDx2tcP_.js.map → HomeView-C_mEMzjV.js.map} +1 -1
  24. package/dist/HomeView-RATm-3zT.js +2 -0
  25. package/dist/HomeView-RATm-3zT.js.map +1 -0
  26. package/dist/Icon-BkXdTctK.js +2 -0
  27. package/dist/Icon-BkXdTctK.js.map +1 -0
  28. package/dist/Icon-BoKcRZAF.js +2 -0
  29. package/dist/Icon-BoKcRZAF.js.map +1 -0
  30. package/dist/Icon-CouPZRkJ.js +2 -0
  31. package/dist/Icon-CouPZRkJ.js.map +1 -0
  32. package/dist/Text-B-E3eaWW.js +2 -0
  33. package/dist/Text-B-E3eaWW.js.map +1 -0
  34. package/dist/Text-B5Ba_pci.js +2 -0
  35. package/dist/Text-B5Ba_pci.js.map +1 -0
  36. package/dist/Text-QH4jjPUM.js +2 -0
  37. package/dist/Text-QH4jjPUM.js.map +1 -0
  38. package/dist/Update-BlhP2VFR.js +2 -0
  39. package/dist/Update-BlhP2VFR.js.map +1 -0
  40. package/dist/Update-CMM38Snc.js +2 -0
  41. package/dist/Update-CMM38Snc.js.map +1 -0
  42. package/dist/Update-D5e_yqty.js +2 -0
  43. package/dist/Update-D5e_yqty.js.map +1 -0
  44. package/dist/VideoGuide-C5aW4OXW.js +2 -0
  45. package/dist/VideoGuide-C5aW4OXW.js.map +1 -0
  46. package/dist/VideoGuide-CoQXlHjQ.js +2 -0
  47. package/dist/VideoGuide-CoQXlHjQ.js.map +1 -0
  48. package/dist/VideoGuide-CwkedH8b.js +2 -0
  49. package/dist/VideoGuide-CwkedH8b.js.map +1 -0
  50. package/dist/_rollupPluginBabelHelpers-9wcO9jN6.js +4 -0
  51. package/dist/_rollupPluginBabelHelpers-9wcO9jN6.js.map +1 -0
  52. package/dist/_rollupPluginBabelHelpers-CiqSP2w-.js +4 -0
  53. package/dist/_rollupPluginBabelHelpers-CiqSP2w-.js.map +1 -0
  54. package/dist/_rollupPluginBabelHelpers-DmvUE1MU.js +4 -0
  55. package/dist/_rollupPluginBabelHelpers-DmvUE1MU.js.map +1 -0
  56. package/dist/brand.js +1 -1
  57. package/dist/brand.js.map +1 -1
  58. package/dist/coder/themes/cosmo-light.js.map +1 -1
  59. package/dist/coder.d.ts +32 -10
  60. package/dist/coder.js +1 -1
  61. package/dist/coder.js.map +1 -1
  62. package/dist/content.d.ts +264 -201
  63. package/dist/content.js +1 -1
  64. package/dist/content.js.map +1 -1
  65. package/dist/index.css +260 -210
  66. package/dist/layouts.d.ts +20 -21
  67. package/dist/layouts.js +1 -1
  68. package/dist/layouts.js.map +1 -1
  69. package/dist/pages.js +1 -1
  70. package/dist/pages.js.map +1 -1
  71. package/dist/system.d.ts +10 -0
  72. package/dist/system.js +2 -0
  73. package/dist/system.js.map +1 -0
  74. package/dist/tslib.es6-Bb9zBh0L.js +2 -0
  75. package/dist/{tslib.es6-BI9zka_a.js.map → tslib.es6-Bb9zBh0L.js.map} +1 -1
  76. package/dist/tslib.es6-Bd9lzVn6.js +2 -0
  77. package/dist/{tslib.es6-sxmRJynD.js.map → tslib.es6-Bd9lzVn6.js.map} +1 -1
  78. package/dist/tslib.es6-DwnOrHRg.js +2 -0
  79. package/dist/tslib.es6-DwnOrHRg.js.map +1 -0
  80. package/dist/views.js +1 -1
  81. package/dist/writer.d.ts +409 -77
  82. package/dist/writer.js +1 -1
  83. package/dist/writer.js.map +1 -1
  84. package/docs/.nojekyll +1 -0
  85. package/docs/assets/hierarchy.js +1 -0
  86. package/docs/assets/highlight.css +22 -0
  87. package/docs/assets/icons.js +18 -0
  88. package/docs/assets/icons.svg +1 -0
  89. package/docs/assets/main.js +60 -0
  90. package/docs/assets/navigation.js +1 -0
  91. package/docs/assets/search.js +1 -0
  92. package/docs/assets/style.css +1640 -0
  93. package/docs/functions/GuideCard.html +6 -0
  94. package/docs/hierarchy.html +1 -0
  95. package/docs/index.html +2 -0
  96. package/docs/interfaces/GuideCardProps.html +18 -0
  97. package/docs/modules.html +1 -0
  98. package/index.ts +0 -1
  99. package/package.json +10 -6
  100. package/project.json +677 -0
  101. package/rollup.config.js +30 -20
  102. package/src/brand/Button/Button.styles.tsx +0 -3
  103. package/src/brand/CTABanner/CTABanner.styles.tsx +2 -4
  104. package/src/brand/Footer/Footer.styles.tsx +0 -3
  105. package/src/coder/Code/Code.styles.tsx +132 -33
  106. package/src/coder/Code/Code.tsx +129 -38
  107. package/src/coder/Code/CodeLoader.tsx +3 -3
  108. package/src/coder/Code/annotations.tsx +28 -8
  109. package/src/coder/Code/highlight.ts +38 -0
  110. package/src/coder/Code/index.ts +2 -1
  111. package/src/coder/CodeCopy/CodeCopy.styles.tsx +13 -11
  112. package/src/coder/CodeCopy/CodeCopy.tsx +5 -3
  113. package/src/coder/CodeSample/CodeSample.tsx +83 -27
  114. package/src/coder/CodeTabs/CodeTabs.styles.tsx +111 -94
  115. package/src/coder/CodeTabs/CodeTabs.tsx +69 -51
  116. package/src/coder/CodeTheme/CodeTheme.tsx +89 -49
  117. package/src/coder/CodeTheme/index.ts +0 -1
  118. package/src/coder/CoderProvider.tsx +26 -0
  119. package/src/coder/index.ts +8 -4
  120. package/src/content/ContentDecoator.styles.tsx +113 -0
  121. package/src/content/ContentDecorator.tsx +17 -0
  122. package/src/content/GridDecorator.styles.tsx +67 -0
  123. package/src/content/GridDecorator.tsx +21 -0
  124. package/src/content/ReactContent.tsx +575 -0
  125. package/src/content/index.ts +10 -2
  126. package/src/icons/index.ts +0 -0
  127. package/src/kit/Loader/Loader.styles.tsx +53 -0
  128. package/src/kit/Loader/Loader.tsx +22 -0
  129. package/src/kit/index.ts +1 -0
  130. package/src/layouts/LayoutPrimary/LayoutPrimary.styles.tsx +270 -306
  131. package/src/layouts/LayoutPrimary/LayoutPrimary.tsx +171 -91
  132. package/src/layouts/LayoutPrimary/index.ts +0 -2
  133. package/src/layouts/index.ts +0 -7
  134. package/src/system/SearchButton/SearchButton.styles.tsx +86 -0
  135. package/src/system/SearchButton/SearchButton.tsx +116 -0
  136. package/src/system/SearchButton/index.ts +1 -0
  137. package/src/system/index.ts +1 -0
  138. package/src/writer/Anchor/Anchor.styles.tsx +11 -0
  139. package/src/{content → writer}/Anchor/Anchor.tsx +20 -22
  140. package/src/writer/Anchor/index.tsx +1 -0
  141. package/src/writer/Badge/Badge.styles.tsx +37 -27
  142. package/src/writer/Badge/Badge.tsx +34 -48
  143. package/src/writer/Banner/Banner.styles.tsx +91 -0
  144. package/src/writer/Banner/Banner.tsx +70 -0
  145. package/src/writer/Banner/index.ts +1 -0
  146. package/src/writer/Blockquote/Blockquote.styles.tsx +6 -4
  147. package/src/writer/Blockquote/Blockquote.tsx +5 -2
  148. package/src/writer/Breadcrumbs/Breadcrumbs.styles.ts +25 -25
  149. package/src/writer/Breadcrumbs/Breadcrumbs.tsx +18 -12
  150. package/src/writer/Button/Button.styles.tsx +137 -0
  151. package/src/writer/Button/Button.tsx +75 -0
  152. package/src/writer/Button/index.ts +2 -0
  153. package/src/writer/Callout/Callout.styles.tsx +35 -42
  154. package/src/writer/Callout/Callout.tsx +30 -15
  155. package/src/writer/Card/Card.styles.tsx +47 -0
  156. package/src/writer/Card/Card.tsx +69 -0
  157. package/src/writer/Card/index.ts +1 -0
  158. package/src/writer/Code/Code.styles.tsx +12 -11
  159. package/src/writer/Code/Code.tsx +6 -3
  160. package/src/writer/ColorSchemeButton/ColorSchemeButton.tsx +172 -0
  161. package/src/writer/ColorSchemeButton/index.ts +1 -0
  162. package/src/writer/Details/Details.styles.tsx +87 -98
  163. package/src/writer/Details/Details.tsx +65 -44
  164. package/src/writer/Example/index.tsx +5 -0
  165. package/src/writer/GuideCard/GuideCard.styles.tsx +100 -103
  166. package/src/writer/GuideCard/GuideCard.tsx +72 -37
  167. package/src/writer/Heading/Heading.styles.tsx +76 -60
  168. package/src/writer/Heading/Heading.tsx +92 -22
  169. package/src/writer/Hr/Hr.styles.tsx +3 -1
  170. package/src/writer/Hr/Hr.tsx +2 -5
  171. package/src/writer/Icon/Icon.tsx +48 -0
  172. package/src/writer/Icon/index.ts +1 -0
  173. package/src/writer/Image/Image.styles.tsx +9 -0
  174. package/src/writer/Image/Image.tsx +19 -0
  175. package/src/writer/Image/index.ts +1 -0
  176. package/src/writer/List/List.styles.tsx +47 -0
  177. package/src/writer/List/List.tsx +29 -0
  178. package/src/writer/List/index.ts +4 -0
  179. package/src/writer/NavLinks/NavLinks.styles.ts +26 -26
  180. package/src/writer/NavLinks/NavLinks.tsx +65 -18
  181. package/src/writer/Pre/Pre.styles.tsx +8 -6
  182. package/src/writer/Pre/Pre.tsx +3 -2
  183. package/src/writer/Steps/Steps.styles.tsx +27 -24
  184. package/src/writer/Steps/Steps.tsx +38 -8
  185. package/src/writer/Table/Table.styles.tsx +65 -34
  186. package/src/writer/Table/Table.tsx +121 -11
  187. package/src/writer/Table/index.ts +0 -11
  188. package/src/writer/Tabs/Tabs.styles.tsx +51 -55
  189. package/src/writer/Tabs/Tabs.tsx +30 -23
  190. package/src/writer/Text/Text.styles.tsx +66 -0
  191. package/src/writer/Text/Text.tsx +79 -0
  192. package/src/writer/Text/index.ts +3 -0
  193. package/src/writer/TocCard/TocCard.module.css +44 -0
  194. package/src/writer/TocCard/TocCard.tsx +42 -0
  195. package/src/writer/TocCard/index.ts +3 -0
  196. package/src/writer/UnderlineNav/Tabs.tsx +51 -0
  197. package/src/writer/UnderlineNav/TabsPrimary.styles.tsx +184 -0
  198. package/src/writer/UnderlineNav/TabsPrimary.tsx +209 -0
  199. package/src/writer/UnderlineNav/TabsSecondary.styles.tsx +77 -0
  200. package/src/writer/UnderlineNav/TabsSecondary.tsx +171 -0
  201. package/src/writer/UnderlineNav/UnderlineNav.styles.tsx +165 -31
  202. package/src/writer/UnderlineNav/UnderlineNav.tsx +257 -22
  203. package/src/writer/UnderlineNav/index.ts +2 -1
  204. package/src/writer/UnderlineNav/useValueChange.ts +60 -0
  205. package/src/writer/Update/Update.styles.tsx +33 -0
  206. package/src/writer/Update/Update.tsx +37 -0
  207. package/src/writer/Update/index.ts +1 -0
  208. package/src/writer/VideoGuide/VideoGuide.module.css +105 -0
  209. package/src/writer/VideoGuide/VideoGuide.tsx +75 -0
  210. package/src/writer/VideoGuide/index.ts +1 -0
  211. package/src/writer/index.ts +23 -1
  212. package/tsconfig.json +9 -3
  213. package/types.d.ts +50 -0
  214. package/writer.ts +1 -1
  215. package/dist/CTABanner-BLDHbq5h.js +0 -2
  216. package/dist/CTABanner-BLDHbq5h.js.map +0 -1
  217. package/dist/CTABanner-n3vc4xW5.js +0 -2
  218. package/dist/CTABanner-n3vc4xW5.js.map +0 -1
  219. package/dist/CodeSample-CVki5fdQ.js +0 -2
  220. package/dist/CodeSample-CVki5fdQ.js.map +0 -1
  221. package/dist/CodeSample-Dkob5gWa.js +0 -2
  222. package/dist/CodeSample-Dkob5gWa.js.map +0 -1
  223. package/dist/HomeView-DHdqouwJ.js +0 -2
  224. package/dist/HomeView-TDx2tcP_.js +0 -2
  225. package/dist/UnderlineNav-9lJPvnIp.js +0 -2
  226. package/dist/UnderlineNav-9lJPvnIp.js.map +0 -1
  227. package/dist/UnderlineNav-VqB7jDQD.js +0 -2
  228. package/dist/UnderlineNav-VqB7jDQD.js.map +0 -1
  229. package/dist/_rollupPluginBabelHelpers-C8nLsqZ7.js +0 -2
  230. package/dist/_rollupPluginBabelHelpers-C8nLsqZ7.js.map +0 -1
  231. package/dist/_rollupPluginBabelHelpers-CrdNG0jb.js +0 -2
  232. package/dist/_rollupPluginBabelHelpers-CrdNG0jb.js.map +0 -1
  233. package/dist/index-TkBHKzGT.js +0 -2
  234. package/dist/index-TkBHKzGT.js.map +0 -1
  235. package/dist/index-YH6Q3iH2.js +0 -2
  236. package/dist/index-YH6Q3iH2.js.map +0 -1
  237. package/dist/tslib.es6-BI9zka_a.js +0 -2
  238. package/dist/tslib.es6-sxmRJynD.js +0 -2
  239. package/src/content/Anchor/Anchor.styles.tsx +0 -5
  240. package/src/content/Anchor/index.tsx +0 -3
  241. package/src/content/Content/Content.styles.tsx +0 -9
  242. package/src/content/Content/Content.tsx +0 -13
  243. package/src/content/Content/index.tsx +0 -3
  244. package/src/content/Content.tsx +0 -179
  245. package/src/content/Subtitle/Subtitle.styles.ts +0 -8
  246. package/src/content/Subtitle/Subtitle.tsx +0 -12
  247. package/src/content/Subtitle/index.tsx +0 -3
  248. package/src/layouts/Layout.styles.tsx +0 -155
  249. package/src/layouts/Layout.tsx +0 -119
  250. package/src/ui/Loader/Loader.styles.tsx +0 -54
  251. package/src/ui/Loader/Loader.tsx +0 -26
  252. package/src/ui/index.ts +0 -1
  253. package/src/writer/Icon/index.tsx +0 -355
  254. package/src/writer/Table/TableV2.styles.tsx +0 -117
  255. package/src/writer/Table/TableV2.tsx +0 -83
  256. /package/src/{ui → kit}/TODO.md +0 -0
@@ -0,0 +1,75 @@
1
+ import React from "react";
2
+
3
+ import * as cn from "./Button.styles";
4
+
5
+ export interface ButtonProps {
6
+ children?: React.ReactNode;
7
+ kind?: "primary" | "secondary" | "tertiary" | undefined
8
+ theme?: "ghost";
9
+ size?: "sm" | "md" | "lg";
10
+ className?: string;
11
+ onClick?: () => void;
12
+ disabled?: boolean;
13
+ icon?: React.ReactElement;
14
+ iconPosition?: "left" | "right";
15
+ href?: string;
16
+ }
17
+
18
+ export function Button({
19
+ children,
20
+ kind = "primary",
21
+ theme,
22
+ size = "md",
23
+ className,
24
+ onClick,
25
+ disabled = false,
26
+ icon,
27
+ iconPosition = "left",
28
+ href
29
+ }: ButtonProps) {
30
+ let Component = href ? "a" : "button"
31
+
32
+ let hrefProps = {}
33
+
34
+ if (href) {
35
+ hrefProps = {
36
+ href,
37
+ target: "_blank",
38
+ }
39
+ }
40
+
41
+ if (theme === "ghost") {
42
+ kind = undefined
43
+ }
44
+
45
+ return (
46
+ <Component
47
+ className={`${cn.ButtonHost} ${className || ''}`}
48
+ data-button={true}
49
+ data-kind={kind}
50
+ data-size={size}
51
+ data-theme={theme}
52
+ data-has-icon={!!icon}
53
+ data-icon-position={iconPosition}
54
+ onClick={onClick}
55
+ disabled={disabled}
56
+ {...hrefProps}
57
+ >
58
+ {icon && iconPosition === "left" && (
59
+ <span part="icon" className={cn.ButtonIcon}>
60
+ {icon}
61
+ </span>
62
+ )}
63
+ {
64
+ children ? <span part="content">
65
+ {children}
66
+ </span> : null
67
+ }
68
+ {icon && iconPosition === "right" && (
69
+ <span part="icon" className={cn.ButtonIcon}>
70
+ {icon}
71
+ </span>
72
+ )}
73
+ </Component>
74
+ );
75
+ }
@@ -0,0 +1,2 @@
1
+ export { Button } from "./Button";
2
+ export type { ButtonProps } from "./Button";
@@ -1,46 +1,39 @@
1
1
  import {css} from "@linaria/core";
2
2
 
3
3
  export const CalloutHost = css`
4
- display: inline-flex;
5
- align-items: center;
6
-
7
- position: relative;
8
- width: 100%;
9
- min-width: 275px;
10
- padding: 8px 12px;
11
-
12
- border-radius: 8px;
13
-
14
- text-align: center;
15
-
16
- border: 1px solid #ececf1;
17
- `;
18
-
19
- export const CalloutNeutral = css`
20
- background-color: #f7f7f8;
21
-
22
- border-color: #ececf1;
23
- `;
24
-
25
- export const CalloutIcon = css`
26
- display: inline-flex;
27
- margin-right: 14px;
28
- flex: 0 0 auto;
29
- align-self: flex-start;
30
-
31
- color: #6e6e80;
32
- font-size: 20px;
33
- margin-top: 2px;
34
- `;
35
-
36
- export const CalloutMessage = css`
37
- color: #353740;
38
- text-align: left;
39
-
40
- flex: 1 1 auto;
41
- `;
42
-
43
- export const CalloutMessageBody = css`
44
- font-size: 14px;
45
- line-height: 20px;
4
+ @layer defaults {
5
+ display: inline-flex;
6
+ align-items: center;
7
+ position: relative;
8
+ width: 100%;
9
+ min-width: 275px;
10
+ padding: 8px 12px;
11
+ border-radius: 8px;
12
+ text-align: center;
13
+ border: 1px solid var(--xyd-callout-border-color);
14
+ background-color: var(--xyd-callout-bgcolor);
15
+
16
+ code {
17
+ background: var(--white);
18
+ }
19
+
20
+ [part="icon"] {
21
+ display: inline-flex;
22
+ margin-right: 14px;
23
+ flex: 0 0 auto;
24
+ align-self: flex-start;
25
+ color: var(--xyd-callout-icon-color);
26
+ margin-top: 2px;
27
+ }
28
+
29
+ [part="message"] {
30
+ color: var(--xyd-callout-message-color);
31
+ text-align: left;
32
+ flex: 1 1 auto;
33
+ }
34
+
35
+ [part="message-body"] {
36
+ }
37
+
38
+ }
46
39
  `;
@@ -2,11 +2,39 @@ import React from "react"
2
2
 
3
3
  import * as cn from "./Callout.styles";
4
4
 
5
+ /**
6
+ * Props for the Callout component
7
+ */
5
8
  export interface CalloutProps {
9
+ /** Additional CSS class name to be applied to the callout */
10
+ className?: string;
11
+
12
+ /** Content to be displayed inside the callout */
6
13
  children: React.ReactNode;
7
14
  }
8
15
 
9
- function InfoIcon() {
16
+ /**
17
+ * A Callout component that displays important information or notices in a visually distinct way.
18
+ * It includes an info icon and a message area for content.
19
+ *
20
+ * @category Component
21
+ */
22
+ export function Callout({ className, children }: CalloutProps) {
23
+ return <xyd-callout
24
+ className={`${cn.CalloutHost} ${className || ''}`}
25
+ >
26
+ <div part="icon">
27
+ <$IconInfo />
28
+ </div>
29
+ <div part="message">
30
+ <div part="message-body">
31
+ {children}
32
+ </div>
33
+ </div>
34
+ </xyd-callout>
35
+ }
36
+
37
+ function $IconInfo() {
10
38
  return <svg
11
39
  xmlns="http://www.w3.org/2000/svg"
12
40
  width="1em"
@@ -14,7 +42,7 @@ function InfoIcon() {
14
42
  fill="currentColor"
15
43
  viewBox="0 0 24 24"
16
44
  >
17
- <path d="M13 12a1 1 0 1 0-2 0v4a1 1 0 1 0 2 0v-4Zm-1-2.5A1.25 1.25 0 1 0 12 7a1.25 1.25 0 0 0 0 2.5Z"/>
45
+ <path d="M13 12a1 1 0 1 0-2 0v4a1 1 0 1 0 2 0v-4Zm-1-2.5A1.25 1.25 0 1 0 12 7a1.25 1.25 0 0 0 0 2.5Z" />
18
46
  <path
19
47
  fillRule="evenodd"
20
48
  d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Z"
@@ -22,16 +50,3 @@ function InfoIcon() {
22
50
  />
23
51
  </svg>
24
52
  }
25
-
26
- export function Callout({children}: CalloutProps) {
27
- return <div className={`${cn.CalloutHost} ${cn.CalloutNeutral}`}>
28
- <div className={cn.CalloutIcon}>
29
- <InfoIcon/>
30
- </div>
31
- <div className={cn.CalloutMessage}>
32
- <div className={cn.CalloutMessageBody}>
33
- {children}
34
- </div>
35
- </div>
36
- </div>
37
- }
@@ -0,0 +1,47 @@
1
+ import { css } from "@linaria/core"
2
+
3
+ export const CardHost = css`
4
+ background-color: var(--xyd-card-bgcolor);
5
+ border-radius: 8px;
6
+ box-shadow: 0 1px 2px 0 var(--xyd-card-shadow-color);
7
+ flex-direction: column;
8
+ display: flex;
9
+ overflow: hidden;
10
+
11
+ &[data-shadow="md"] {
12
+ box-shadow: 0 5px 40px var(--xyd-card-shadow-color);
13
+ }
14
+
15
+ [part="image-container"] {
16
+ border-bottom: 2px solid var(--xyd-card-border-color);
17
+ height: 200px;
18
+ overflow: hidden;
19
+ position: relative;
20
+
21
+ [part="bg"] {
22
+ background-size: cover;
23
+ background-repeat: no-repeat;
24
+ position: relative;
25
+ height: 100%;
26
+ }
27
+
28
+ img {
29
+ width: 100%;
30
+ height: 100%;
31
+ object-fit: cover;
32
+ margin-bottom: -4px;
33
+ }
34
+ }
35
+
36
+ [part="body"] {
37
+ padding: 16px;
38
+
39
+ [part="header"] {
40
+ margin-right: 4px;
41
+ align-items: center;
42
+ justify-content: space-between;
43
+ margin-bottom: 12px;
44
+ display: flex;
45
+ }
46
+ }
47
+ `
@@ -0,0 +1,69 @@
1
+ import React from "react"
2
+
3
+ import { Button } from "../Button"
4
+ import { Text } from "../Text"
5
+
6
+ import * as cn from "./Card.styles"
7
+
8
+ interface CardProps {
9
+ title: string
10
+ href?: string
11
+ link?: React.ElementType
12
+
13
+ description?: string
14
+
15
+ imgSrc?: string
16
+ imgAlt?: string
17
+
18
+ shadow?: "md"
19
+ }
20
+
21
+ export function Card(props: CardProps) {
22
+ const {
23
+ title,
24
+ description,
25
+ imgSrc,
26
+ imgAlt,
27
+ shadow,
28
+ href,
29
+ link,
30
+ } = props
31
+
32
+ const Link = link
33
+
34
+ return <xyd-card
35
+ data-shadow={shadow || undefined}
36
+ className={cn.CardHost}
37
+ >
38
+ {imgSrc && (
39
+ <div part="image-container">
40
+ <div part="bg">
41
+ <img src={imgSrc} alt={imgAlt} />
42
+ </div>
43
+ </div>
44
+ )}
45
+
46
+ <div part="body">
47
+ <div part="header">
48
+ {Link && href ?
49
+ <Text weight="bold">
50
+ <Link href={href}>
51
+ {title}
52
+ </Link>
53
+ </Text>
54
+ : <Text weight="bold">
55
+ {title}
56
+ </Text>}
57
+ <Button size="sm" kind="secondary">
58
+ Source
59
+ </Button>
60
+ </div>
61
+ <div part="description">
62
+ <Text size="small">
63
+ {description}
64
+ </Text>
65
+ </div>
66
+ </div>
67
+ </xyd-card>
68
+ }
69
+
@@ -0,0 +1 @@
1
+ export {Card} from "./Card"
@@ -1,15 +1,16 @@
1
1
  import {css} from "@linaria/core";
2
2
 
3
3
  export const CodeHost = css`
4
- display: inline-block;
5
- padding: 0 .3em;
6
- border-radius: 6px;
7
- margin: 0 3px;
8
- border: .5px solid #ececf1;
9
-
10
- font-size: 14px;
11
- font-weight: 500;
12
- line-height: 1.6em;
13
-
14
- background: linear-gradient(45deg, #f7f7f8 0%, rgba(247, 247, 248, 1) 100%);
4
+ @layer defaults {
5
+ display: inline-block;
6
+ padding: 0 .3em;
7
+ border-radius: 6px;
8
+ margin: 0 3px;
9
+ border: .5px solid var(--xyd-code-border-color);
10
+ background: var(--xyd-code-bgcolor);
11
+
12
+ & [part="content"] {
13
+ position: relative;
14
+ }
15
+ }
15
16
  `;
@@ -3,11 +3,14 @@ import React from "react"
3
3
  import * as cn from "./Code.styles";
4
4
 
5
5
  export interface CodeProps {
6
+ className?: string;
6
7
  children: React.ReactNode;
7
8
  }
8
9
 
9
- export function Code({children}: CodeProps) {
10
- return <code className={cn.CodeHost}>
11
- {children}
10
+ export function Code({ className, children }: CodeProps) {
11
+ return <code className={`${cn.CodeHost} ${className || ''}`}>
12
+ <span part="content">
13
+ {children}
14
+ </span>
12
15
  </code>
13
16
  }
@@ -0,0 +1,172 @@
1
+ import React, { useEffect, useState } from "react";
2
+
3
+ import { Button } from "../Button";
4
+
5
+ export function ColorSchemeButton() {
6
+ const [currentScheme, changeColorScheme] = useColorScheme() as [string, () => void]
7
+
8
+ return <Button
9
+ size="sm"
10
+ theme="ghost"
11
+ icon={currentScheme === "dark" ? <IconDarkMode /> : <IconLightMode />}
12
+ onClick={changeColorScheme}
13
+ />
14
+ }
15
+
16
+ export function useColorScheme() {
17
+ const [currentScheme, setCurrentScheme] = useState<string>('light')
18
+
19
+ // TODO: context
20
+ useEffect(() => {
21
+ const updateScheme = () => {
22
+ const html = document.querySelector("html");
23
+ if (html) {
24
+ const scheme = html.getAttribute("data-color-scheme") || "os";
25
+ if (scheme === "os") {
26
+ const preferred = getPreferredColorScheme();
27
+ setCurrentScheme(preferred || "light");
28
+ } else {
29
+ setCurrentScheme(scheme);
30
+ }
31
+ }
32
+ };
33
+
34
+ updateScheme();
35
+
36
+ // Listen for changes to the color scheme
37
+ const observer = new MutationObserver(updateScheme);
38
+ const html = document.querySelector("html");
39
+ if (html) {
40
+ observer.observe(html, { attributes: true, attributeFilter: ['data-color-scheme'] });
41
+ }
42
+
43
+ return () => observer.disconnect();
44
+ }, []);
45
+
46
+ function changeColorScheme() {
47
+ let colorScheme = ""
48
+
49
+ const preferredColorScheme = getPreferredColorScheme()
50
+ if (preferredColorScheme) {
51
+ colorScheme = preferredColorScheme === "dark" ? "light" : "dark"
52
+ }
53
+
54
+ const html = document.querySelector("html");
55
+ if (!html) return;
56
+
57
+ const currentScheme = html.getAttribute("data-color-scheme");
58
+ if (currentScheme && currentScheme !== "os") {
59
+ colorScheme = currentScheme === "dark" ? "light" : "dark";
60
+ }
61
+ if (!colorScheme) {
62
+ colorScheme = "light"
63
+ }
64
+
65
+ html.setAttribute("data-color-scheme", colorScheme);
66
+ localStorage.setItem("xyd-color-scheme", colorScheme);
67
+ }
68
+
69
+ return [currentScheme, changeColorScheme]
70
+ }
71
+
72
+ function getPreferredColorScheme() {
73
+ if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
74
+ return 'dark';
75
+ }
76
+
77
+ if (window.matchMedia('(prefers-color-scheme: light)').matches) {
78
+ return 'light';
79
+ }
80
+
81
+ return null
82
+ }
83
+
84
+
85
+ function IconLightMode() {
86
+ return <svg
87
+ width={16}
88
+ height={16}
89
+ viewBox="0 0 16 16"
90
+ fill="none"
91
+ stroke="currentColor"
92
+ xmlns="http://www.w3.org/2000/svg"
93
+ >
94
+ <g clipPath="url(#clip0_2880_7340)">
95
+ <path
96
+ d="M8 1.11133V2.00022"
97
+ strokeWidth={1.5}
98
+ strokeLinecap="round"
99
+ strokeLinejoin="round"
100
+ />
101
+ <path
102
+ d="M12.8711 3.12891L12.2427 3.75735"
103
+ strokeWidth={1.5}
104
+ strokeLinecap="round"
105
+ strokeLinejoin="round"
106
+ />
107
+ <path
108
+ d="M14.8889 8H14"
109
+ strokeWidth={1.5}
110
+ strokeLinecap="round"
111
+ strokeLinejoin="round"
112
+ />
113
+ <path
114
+ d="M12.8711 12.8711L12.2427 12.2427"
115
+ strokeWidth={1.5}
116
+ strokeLinecap="round"
117
+ strokeLinejoin="round"
118
+ />
119
+ <path
120
+ d="M8 14.8889V14"
121
+ strokeWidth={1.5}
122
+ strokeLinecap="round"
123
+ strokeLinejoin="round"
124
+ />
125
+ <path
126
+ d="M3.12891 12.8711L3.75735 12.2427"
127
+ strokeWidth={1.5}
128
+ strokeLinecap="round"
129
+ strokeLinejoin="round"
130
+ />
131
+ <path
132
+ d="M1.11133 8H2.00022"
133
+ strokeWidth={1.5}
134
+ strokeLinecap="round"
135
+ strokeLinejoin="round"
136
+ />
137
+ <path
138
+ d="M3.12891 3.12891L3.75735 3.75735"
139
+ strokeWidth={1.5}
140
+ strokeLinecap="round"
141
+ strokeLinejoin="round"
142
+ />
143
+ <path
144
+ d="M8.00043 11.7782C10.0868 11.7782 11.7782 10.0868 11.7782 8.00043C11.7782 5.91402 10.0868 4.22266 8.00043 4.22266C5.91402 4.22266 4.22266 5.91402 4.22266 8.00043C4.22266 10.0868 5.91402 11.7782 8.00043 11.7782Z"
145
+ strokeWidth={1.5}
146
+ strokeLinecap="round"
147
+ strokeLinejoin="round"
148
+ />
149
+ </g>
150
+ <defs>
151
+ <clipPath id="clip0_2880_7340">
152
+ <rect width={16} height={16} fill="white" />
153
+ </clipPath>
154
+ </defs>
155
+ </svg>
156
+ }
157
+
158
+ function IconDarkMode() {
159
+ return <svg
160
+ xmlns="http://www.w3.org/2000/svg"
161
+ width={16}
162
+ height={16}
163
+ viewBox="0 0 24 24"
164
+ fill="none"
165
+ stroke="currentColor"
166
+ strokeWidth={2}
167
+ strokeLinecap="round"
168
+ strokeLinejoin="round"
169
+ >
170
+ <path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" />
171
+ </svg>
172
+ }
@@ -0,0 +1 @@
1
+ export { ColorSchemeButton, useColorScheme } from "./ColorSchemeButton";