@ably/ui 8.7.0-dev.b3aa10e → 8.7.0-dev.fa55b85
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 +1 -1
- package/core/Code/component.css +3 -3
- package/core/Code/component.js +1 -1
- package/core/Code.jsx +353 -7273
- package/core/CompanyAutocomplete/component.js +1 -1
- package/core/ConnectStateWrapper.jsx +13 -4
- package/core/ContactFooter.jsx +13 -119
- package/core/CookieMessage.jsx +21 -293
- package/core/CustomerLogos.jsx +11 -115
- package/core/DropdownMenu/component.js +1 -0
- package/core/DropdownMenu.jsx +317 -0
- package/core/FeaturedLink.jsx +10 -116
- package/core/Flash.jsx +29 -1483
- package/core/Footer.jsx +17 -123
- package/core/Icon.jsx +9 -114
- package/core/Loader.jsx +9 -114
- package/core/Logo.jsx +13 -118
- package/core/Meganav/component.js +1 -2
- package/core/Meganav.jsx +2844 -10177
- package/core/MeganavBlogPostsList/component.js +1 -1
- package/core/MeganavBlogPostsList.jsx +11 -118
- package/core/MeganavContentCompany.jsx +31 -124
- package/core/MeganavContentDevelopers.jsx +23 -117
- package/core/MeganavContentPlatform.jsx +11 -118
- package/core/MeganavContentUseCases.jsx +11 -117
- package/core/MeganavContentWhyAbly/component.js +22 -0
- package/core/MeganavContentWhyAbly.jsx +3279 -0
- package/core/MeganavControl.jsx +10 -116
- package/core/MeganavControlMobileDropdown/component.js +1 -1
- package/core/MeganavControlMobileDropdown.jsx +10 -116
- package/core/MeganavControlMobilePanelClose.jsx +10 -116
- package/core/MeganavControlMobilePanelOpen.jsx +10 -116
- package/core/MeganavItemsDesktop.jsx +13 -121
- package/core/MeganavItemsMobile.jsx +18 -132
- package/core/MeganavItemsSignedIn.jsx +16 -129
- package/core/MeganavSearch.jsx +13 -123
- package/core/MeganavSearchAutocomplete/component.js +1 -2
- package/core/MeganavSearchPanel.jsx +12 -121
- package/core/MeganavSearchSuggestions.jsx +11 -118
- package/core/Notice/component.js +1 -2
- package/core/Notice.jsx +62 -2136
- package/core/SignOutLink.jsx +9 -114
- package/core/Slider/component.js +1 -1
- package/core/Slider.jsx +25 -582
- package/core/Uptime.jsx +15 -118
- package/core/scripts.js +1 -1
- package/core/sprites.svg +21 -0
- package/core/styles.css +2 -0
- package/package.json +4 -4
- package/src/core/Code/component.css +1 -67
- package/src/core/Code/component.js +11 -46
- package/src/core/Code/component.jsx +7 -3
- package/src/core/CustomerLogos/component.jsx +1 -1
- package/src/core/DropdownMenu/component.js +0 -0
- package/src/core/DropdownMenu/component.jsx +114 -0
- package/src/core/FeatureFooter/component.html.erb +1 -1
- package/src/core/MeganavContentDevelopers/component.html.erb +9 -0
- package/src/core/MeganavContentDevelopers/component.jsx +9 -0
- package/src/core/MeganavContentUseCases/component.html.erb +1 -1
- package/src/core/MeganavContentUseCases/component.jsx +1 -1
- package/src/core/MeganavSearchSuggestions/component.html.erb +1 -1
- package/src/core/icons/google.svg +3 -0
- package/src/core/icons/icon-display-integrations-col.svg +8 -0
- package/src/core/icons/stackoverflow.svg +3 -0
- package/src/core/icons/youtube.svg +11 -0
- package/src/core/styles/properties.css +2 -0
- package/src/core/utils/syntax-highlighter-registry.js +61 -0
- package/src/core/utils/syntax-highlighter.css +69 -0
- package/src/core/utils/syntax-highlighter.js +98 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React, { createContext, useContext, useState, useEffect, useRef } from "react";
|
|
2
|
+
import T from "prop-types";
|
|
3
|
+
import Icon from "../Icon/component.jsx";
|
|
4
|
+
|
|
5
|
+
const DropdownMenuContext = createContext();
|
|
6
|
+
|
|
7
|
+
const DropdownMenu = ({ children }) => {
|
|
8
|
+
const [isOpen, setOpen] = useState(false);
|
|
9
|
+
const ref = useRef(null);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const clickHandler = (e) => {
|
|
13
|
+
if (ref?.current?.contains(e.target)) return;
|
|
14
|
+
setOpen(false);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
document.addEventListener("click", clickHandler);
|
|
18
|
+
|
|
19
|
+
return () => {
|
|
20
|
+
document.removeEventListener("click", clickHandler);
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<DropdownMenuContext.Provider value={{ isOpen, setOpen }}>
|
|
26
|
+
<div id="dropdown-menu" className="relative" ref={ref}>
|
|
27
|
+
{children}
|
|
28
|
+
</div>
|
|
29
|
+
</DropdownMenuContext.Provider>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
DropdownMenu.propTypes = {
|
|
34
|
+
children: T.node,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const Trigger = ({ children, additionalTriggerCSS = "" }) => {
|
|
38
|
+
const { isOpen, setOpen } = useContext(DropdownMenuContext);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<button
|
|
42
|
+
id="menu-trigger"
|
|
43
|
+
onClick={() => setOpen(!isOpen)}
|
|
44
|
+
className={`${additionalTriggerCSS} flex items-center p-8 ml-8 group hover:text-gui-hover hover:bg-light-grey active:text-gui-active focus:text-gui-focus focus:outline-none rounded-lg`}
|
|
45
|
+
>
|
|
46
|
+
<span className="leading-normal">{children}</span>
|
|
47
|
+
<Icon
|
|
48
|
+
name="icon-gui-disclosure-arrow"
|
|
49
|
+
color="text-cool-black"
|
|
50
|
+
size="1.25rem"
|
|
51
|
+
additionalCSS="transform rotate-90 group-hover:text-gui-hover group-active:text-gui-active group-focus:text-gui-focus"
|
|
52
|
+
/>
|
|
53
|
+
</button>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
<DropdownMenu.Trigger className="list of names">Click me</DropdownMenu.Trigger>;
|
|
58
|
+
|
|
59
|
+
Trigger.propTypes = {
|
|
60
|
+
children: T.node,
|
|
61
|
+
additionalTriggerCSS: T.string,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const Content = ({ children, anchorPosition = "right", additionalContentCSS }) => {
|
|
65
|
+
const { isOpen } = useContext(DropdownMenuContext);
|
|
66
|
+
|
|
67
|
+
if (!isOpen) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const anchorPositionClasses = anchorPosition === "right" ? "right-0" : "left-0";
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
id="menu-content"
|
|
76
|
+
className={`${additionalContentCSS} absolute p-8 z-10 border border-mid-grey bg-white rounded shadow-container ${anchorPositionClasses}`}
|
|
77
|
+
style={{ minWidth: 275, top: 44 }}
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
Content.propTypes = {
|
|
85
|
+
children: T.node,
|
|
86
|
+
anchorPosition: T.string,
|
|
87
|
+
additionalContentCSS: T.string,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const Link = ({ url, title, subtitle, iconName, children }) => {
|
|
91
|
+
return (
|
|
92
|
+
<a href={url} className="menu-link group block p-8 hover:bg-light-grey hover:text-cool-black rounded">
|
|
93
|
+
<p className="mb-4">
|
|
94
|
+
{title}
|
|
95
|
+
{iconName ? <Icon name={iconName} size="1rem" color="text-cool-black" additionalCSS="align-middle ml-8 relative -top-1 -left-4" /> : null}
|
|
96
|
+
</p>
|
|
97
|
+
{subtitle ? <p className="text-p3 mb-16 text-dark-grey">{subtitle}</p> : null}
|
|
98
|
+
{children}
|
|
99
|
+
</a>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
Link.propTypes = {
|
|
104
|
+
url: T.string,
|
|
105
|
+
title: T.string,
|
|
106
|
+
subtitle: T.string,
|
|
107
|
+
iconName: T.string,
|
|
108
|
+
children: T.node,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
DropdownMenu.Trigger = Trigger;
|
|
112
|
+
DropdownMenu.Content = Content;
|
|
113
|
+
DropdownMenu.Link = Link;
|
|
114
|
+
export default DropdownMenu;
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
</ul>
|
|
47
47
|
</span>
|
|
48
48
|
<span class="flex-0">
|
|
49
|
-
<%= link_to 'Start
|
|
49
|
+
<%= link_to 'Start building', abs_url("/sign-up"), class: "ui-btn-secondary self-start mt-24" %>
|
|
50
50
|
</span>
|
|
51
51
|
</div>
|
|
52
52
|
</div>
|
|
@@ -56,6 +56,15 @@
|
|
|
56
56
|
</div>
|
|
57
57
|
<% end %>
|
|
58
58
|
</li>
|
|
59
|
+
<li>
|
|
60
|
+
<%= link_to abs_url("/integrations"), class: "ui-meganav-media-with-image group" do %>
|
|
61
|
+
<%= render(AblyUi::Core::Icon.new(name: "icon-display-integrations-col", size: "2.5rem")) %>
|
|
62
|
+
<div class="flex flex-col justify-center">
|
|
63
|
+
<p class="ui-meganav-media-heading">Integrations</p>
|
|
64
|
+
<p class="ui-meganav-media-copy">Find out more about Ably integrations. </p>
|
|
65
|
+
</div>
|
|
66
|
+
<% end %>
|
|
67
|
+
</li>
|
|
59
68
|
</ul>
|
|
60
69
|
</div>
|
|
61
70
|
|
|
@@ -62,6 +62,15 @@ const MeganavContentDevelopers = ({ absUrl }) => (
|
|
|
62
62
|
</div>
|
|
63
63
|
</a>
|
|
64
64
|
</li>
|
|
65
|
+
<li>
|
|
66
|
+
<a href={absUrl("/integrations")} className="ui-meganav-media-with-image group">
|
|
67
|
+
<Icon name="icon-display-integrations-col" size="2.5rem" />
|
|
68
|
+
<div className="flex flex-col justify-center">
|
|
69
|
+
<p className="ui-meganav-media-heading">Integrations</p>
|
|
70
|
+
<p className="ui-meganav-media-copy">Find out more about Ably integrations. </p>
|
|
71
|
+
</div>
|
|
72
|
+
</a>
|
|
73
|
+
</li>
|
|
65
74
|
</ul>
|
|
66
75
|
</div>
|
|
67
76
|
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
</li>
|
|
59
59
|
<li>
|
|
60
60
|
<%= link_to abs_url("/solutions/fintech"), class: "ui-meganav-media group" do %>
|
|
61
|
-
<p class="ui-meganav-media-heading">
|
|
61
|
+
<p class="ui-meganav-media-heading">FinTech</p>
|
|
62
62
|
<p class="ui-meganav-media-copy">Deliver personalised financial data in realtime.</p>
|
|
63
63
|
<% end %>
|
|
64
64
|
</li>
|
|
@@ -64,7 +64,7 @@ const MeganavContentUseCases = ({ absUrl }) => (
|
|
|
64
64
|
</li>
|
|
65
65
|
<li>
|
|
66
66
|
<a href={absUrl("/solutions/fintech")} className="ui-meganav-media group">
|
|
67
|
-
<p className="ui-meganav-media-heading">
|
|
67
|
+
<p className="ui-meganav-media-heading">FinTech</p>
|
|
68
68
|
<p className="ui-meganav-media-copy">Deliver personalised financial data in realtime.</p>
|
|
69
69
|
</a>
|
|
70
70
|
</li>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<%= link_to 'Publish/Subscribe Messaging', abs_url("/docs/core-features/pubsub"), class: "ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus" %>
|
|
13
13
|
</li>
|
|
14
14
|
<li class="py-12 pl-8 flex-shrink-0">
|
|
15
|
-
<%= link_to 'Platform', abs_url("/
|
|
15
|
+
<%= link_to 'Platform', abs_url("/platform"), class: "ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus" %>
|
|
16
16
|
</li>
|
|
17
17
|
</ul>
|
|
18
18
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M17.6483 7.36875H9.1803V10.8492H14.0178C13.8092 11.9742 13.1764 12.9258 12.2225 13.5633C11.4162 14.1023 10.3873 14.4211 9.17795 14.4211C6.83655 14.4211 4.85608 12.8391 4.14827 10.7133C3.97014 10.1742 3.86702 9.59766 3.86702 9.00469C3.86702 8.41172 3.97014 7.83516 4.14827 7.29609C4.85842 5.17266 6.83889 3.59063 9.1803 3.59063C10.4998 3.59063 11.6834 4.04531 12.6162 4.93594L15.1944 2.35547C13.6358 0.902344 11.6037 0.0117188 9.1803 0.0117188C5.66702 0.0117188 2.62717 2.02734 1.14827 4.96641C0.538892 6.18047 0.192017 7.55391 0.192017 9.00703C0.192017 10.4602 0.538892 11.8312 1.14827 13.0453C2.62717 15.9844 5.66702 18 9.1803 18C11.6084 18 13.6428 17.1938 15.1287 15.8203C16.828 14.2547 17.81 11.9484 17.81 9.20859C17.81 8.57109 17.7537 7.95937 17.6483 7.36875Z" fill="currentColor" />
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M7.69985 7.70029C3.40409 11.9961 3.18585 18.7426 7.21241 22.7692L11.9425 27.4993L27.4988 11.9429L22.7688 7.21285C18.7422 3.18629 11.9956 3.40453 7.69985 7.70029Z" stroke="#03020D" stroke-width="1.5" stroke-linejoin="round"/>
|
|
3
|
+
<path d="M45.2129 45.2131L42.3844 42.3847" stroke="#03020D" stroke-width="1.37459" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M40.4514 40.451C35.8956 45.0068 28.6731 45.2897 24.3219 40.9385L19.5918 36.2084C19.2989 35.9155 19.2989 35.4406 19.5918 35.1477L35.1482 19.5914C35.441 19.2985 35.9159 19.2985 36.2088 19.5914L40.9389 24.3215C45.2902 28.6727 45.0073 35.8952 40.4514 40.451Z" fill="#FF5416"/>
|
|
5
|
+
<path d="M2.78647 2.78662L7.73622 7.73637" stroke="#03020D" stroke-width="1.37459" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6
|
+
<path d="M23.2925 16.2217L28.2423 21.1714" stroke="#03020D" stroke-width="1.37459" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7
|
+
<path d="M16.2215 23.2927L21.1712 28.2425" stroke="#03020D" stroke-width="1.37459" stroke-linecap="round" stroke-linejoin="round"/>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M16.8833 17.0404L6.44573 14.8304L6.89029 12.7367L17.3279 14.9467L16.8833 17.0404ZM17.4825 14.3457L7.81808 9.82876L8.72653 7.89014L18.391 12.4071L17.4825 14.3457ZM18.7002 11.9031L10.5048 5.05977L11.8771 3.41195L20.0726 10.2552L18.7002 11.9031ZM14.0806 1.27948L15.8009 0L22.1601 8.58804L20.4398 9.86753L14.0806 1.27948ZM16.8833 19.7351H6.25244V17.6026H16.8833V19.7351ZM21.1356 15.4701H19.0094V21.8675H4.12617V15.4701H2V24H21.1356V15.4701Z" fill="#03020D"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="32" height="22" viewBox="0 0 32 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_1509_18255)">
|
|
3
|
+
<path d="M30.525 3.44433C30.1655 2.09844 29.113 1.03726 27.778 0.6749C25.3391 0.00195312 15.5834 0.00195312 15.5834 0.00195312C15.5834 0.00195312 5.82773 0.00195312 3.38881 0.649017C2.0795 1.01137 1.00124 2.09844 0.64182 3.44433C0 5.90318 0 11.002 0 11.002C0 11.002 0 16.1268 0.64182 18.5597C1.00124 19.9056 2.05382 20.9668 3.38881 21.3292C5.8534 22.0021 15.5834 22.0021 15.5834 22.0021C15.5834 22.0021 25.3391 22.0021 27.778 21.3551C29.113 20.9927 30.1655 19.9315 30.525 18.5856C31.1668 16.1268 31.1668 11.0279 31.1668 11.0279C31.1668 11.0279 31.1925 5.90318 30.525 3.44433Z" fill="#282828"/>
|
|
4
|
+
<path d="M20.5892 11.0021L12.4766 6.2915V15.7128L20.5892 11.0021Z" fill="white"/>
|
|
5
|
+
</g>
|
|
6
|
+
<defs>
|
|
7
|
+
<clipPath id="clip0_1509_18255">
|
|
8
|
+
<rect width="31.1667" height="22" fill="white"/>
|
|
9
|
+
</clipPath>
|
|
10
|
+
</defs>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// This file can be used in the browser, but because of the weight of all the language
|
|
2
|
+
// definitions, preferably it should be used on the server.
|
|
3
|
+
|
|
4
|
+
import bash from "highlight.js/lib/languages/bash";
|
|
5
|
+
import cpp from "highlight.js/lib/languages/cpp";
|
|
6
|
+
import csharp from "highlight.js/lib/languages/csharp";
|
|
7
|
+
import css from "highlight.js/lib/languages/css";
|
|
8
|
+
import dart from "highlight.js/lib/languages/dart";
|
|
9
|
+
import dos from "highlight.js/lib/languages/dos";
|
|
10
|
+
import diff from "highlight.js/lib/languages/diff";
|
|
11
|
+
import erlang from "highlight.js/lib/languages/erlang";
|
|
12
|
+
import elixir from "highlight.js/lib/languages/elixir";
|
|
13
|
+
import plaintext from "highlight.js/lib/languages/plaintext";
|
|
14
|
+
import go from "highlight.js/lib/languages/go";
|
|
15
|
+
import http from "highlight.js/lib/languages/http";
|
|
16
|
+
import java from "highlight.js/lib/languages/java";
|
|
17
|
+
import javascript from "highlight.js/lib/languages/javascript";
|
|
18
|
+
import typescript from "highlight.js/lib/languages/typescript";
|
|
19
|
+
import json from "highlight.js/lib/languages/json";
|
|
20
|
+
import objectivec from "highlight.js/lib/languages/objectivec";
|
|
21
|
+
import php from "highlight.js/lib/languages/php";
|
|
22
|
+
import python from "highlight.js/lib/languages/python";
|
|
23
|
+
import ruby from "highlight.js/lib/languages/ruby";
|
|
24
|
+
import swift from "highlight.js/lib/languages/swift";
|
|
25
|
+
import sql from "highlight.js/lib/languages/sql";
|
|
26
|
+
import xml from "highlight.js/lib/languages/xml";
|
|
27
|
+
import yaml from "highlight.js/lib/languages/yaml";
|
|
28
|
+
import curl from "highlightjs-curl/src/languages/curl";
|
|
29
|
+
|
|
30
|
+
const registry = [
|
|
31
|
+
{ label: "Text", key: "text", module: plaintext },
|
|
32
|
+
{ label: "JS", key: "javascript", module: javascript },
|
|
33
|
+
{ label: "TS", key: "typescript", module: typescript },
|
|
34
|
+
{ label: "Java", key: "java", module: java },
|
|
35
|
+
{ label: "Ruby", key: "ruby", module: ruby },
|
|
36
|
+
{ label: "Python", key: "python", module: python },
|
|
37
|
+
{ label: "PHP", key: "php", module: php },
|
|
38
|
+
{ label: "Shell", key: "bash", module: bash },
|
|
39
|
+
{ label: "C#", key: "cs", module: csharp },
|
|
40
|
+
{ label: "CSS", key: "css", module: css },
|
|
41
|
+
{ label: "Go", key: "go", module: go },
|
|
42
|
+
{ label: "HTML", key: "xml", module: xml },
|
|
43
|
+
{ label: "HTTP", key: "http", module: http },
|
|
44
|
+
{ label: "C++", key: "cpp", module: cpp },
|
|
45
|
+
{ label: "Dart", key: "dart", module: dart },
|
|
46
|
+
{ label: "Swift", key: "swift", module: swift },
|
|
47
|
+
{ label: "Objective C", key: "objectivec", module: objectivec },
|
|
48
|
+
{ label: "Node.js", key: "javascript", module: javascript },
|
|
49
|
+
{ label: "JSON", key: "json", module: json },
|
|
50
|
+
{ label: "DOS", key: "dos", module: dos },
|
|
51
|
+
{ label: "YAML", key: "yaml", module: yaml },
|
|
52
|
+
{ label: "Erlang", key: "erlang", module: erlang },
|
|
53
|
+
{ label: "Elixir", key: "elixir", module: elixir },
|
|
54
|
+
{ label: "Diff", key: "diff", module: diff },
|
|
55
|
+
{ label: "SQL", key: "sql", module: sql },
|
|
56
|
+
{ label: "cURL", key: "curl", module: curl },
|
|
57
|
+
{ label: "HTML", key: "html", module: xml },
|
|
58
|
+
{ label: "XML", key: "xml", module: xml },
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
export default registry;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
@import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,600;0,700;1,600;1,700&display=swap");
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
@layer components {
|
|
6
|
+
.hljs {
|
|
7
|
+
background: var(--syntax-black);
|
|
8
|
+
color: var(--syntax-light-grey);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.hljs-emphasis {
|
|
12
|
+
@apply italic;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.hljs-strong {
|
|
16
|
+
@apply font-bold;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.hljs-comment,
|
|
20
|
+
.hljs-quote {
|
|
21
|
+
color: var(--syntax-dark-grey);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.hljs-variable,
|
|
25
|
+
.hljs-template-variable,
|
|
26
|
+
.hljs-tag,
|
|
27
|
+
.hljs-name,
|
|
28
|
+
.hljs-selector-id,
|
|
29
|
+
.hljs-selector-class,
|
|
30
|
+
.hljs-regexp,
|
|
31
|
+
.hljs-deletion {
|
|
32
|
+
color: var(--syntax-red);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.hljs-number,
|
|
36
|
+
.hljs-built_in,
|
|
37
|
+
.hljs-literal,
|
|
38
|
+
.hljs-type,
|
|
39
|
+
.hljs-params,
|
|
40
|
+
.hljs-meta,
|
|
41
|
+
.hljs-link {
|
|
42
|
+
color: var(--syntax-orange);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.hljs-attribute {
|
|
46
|
+
color: var(--syntax-yellow);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.hljs-string,
|
|
50
|
+
.hljs-symbol,
|
|
51
|
+
.hljs-bullet,
|
|
52
|
+
.hljs-addition {
|
|
53
|
+
color: var(--syntax-green);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.hljs-title,
|
|
57
|
+
.hljs-section {
|
|
58
|
+
color: var(--syntax-blue);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.hljs-keyword,
|
|
62
|
+
.hljs-selector-tag {
|
|
63
|
+
color: var(--syntax-lilac);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.hljs-subst {
|
|
67
|
+
color: var(--syntax-mid-grey);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import hljs from "highlight.js/lib/core";
|
|
2
|
+
|
|
3
|
+
// Map certain frameworks, protocols etc to available langauage packs
|
|
4
|
+
const languageToHighlightKey = (lang) => {
|
|
5
|
+
let id;
|
|
6
|
+
|
|
7
|
+
if (!lang) {
|
|
8
|
+
lang = "text";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
switch (lang.toLowerCase()) {
|
|
12
|
+
case "android":
|
|
13
|
+
id = "java";
|
|
14
|
+
break;
|
|
15
|
+
|
|
16
|
+
case ".net":
|
|
17
|
+
case "net":
|
|
18
|
+
case "dotnet":
|
|
19
|
+
case "csharp":
|
|
20
|
+
case "c#":
|
|
21
|
+
id = "cs";
|
|
22
|
+
break;
|
|
23
|
+
|
|
24
|
+
case "objc":
|
|
25
|
+
case "objective c":
|
|
26
|
+
id = "objectivec";
|
|
27
|
+
break;
|
|
28
|
+
|
|
29
|
+
case "laravel":
|
|
30
|
+
id = "php";
|
|
31
|
+
break;
|
|
32
|
+
|
|
33
|
+
case "flutter":
|
|
34
|
+
id = "dart";
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
case "node.js":
|
|
38
|
+
case "js":
|
|
39
|
+
id = "javascript";
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case "ts":
|
|
43
|
+
id = "typescript";
|
|
44
|
+
break;
|
|
45
|
+
|
|
46
|
+
case "shell":
|
|
47
|
+
case "fh":
|
|
48
|
+
case "sh":
|
|
49
|
+
id = "bash";
|
|
50
|
+
break;
|
|
51
|
+
|
|
52
|
+
case "https":
|
|
53
|
+
case "http":
|
|
54
|
+
case "txt":
|
|
55
|
+
case "plaintext":
|
|
56
|
+
id = "text";
|
|
57
|
+
break;
|
|
58
|
+
|
|
59
|
+
case "cmd":
|
|
60
|
+
case "bat":
|
|
61
|
+
id = "dos";
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case "yml":
|
|
65
|
+
id = "yaml";
|
|
66
|
+
break;
|
|
67
|
+
|
|
68
|
+
case "erl":
|
|
69
|
+
id = "erlang";
|
|
70
|
+
break;
|
|
71
|
+
|
|
72
|
+
case "patch":
|
|
73
|
+
id = "diff";
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case "svg":
|
|
77
|
+
id = "xml";
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
default:
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return id || lang;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const registerDefaultLanguages = (register) => {
|
|
88
|
+
register.forEach(({ key, module }) => hljs.registerLanguage(key, module));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const highlightSnippet = (languageKeyword, snippet) => {
|
|
92
|
+
const language = languageToHighlightKey(languageKeyword);
|
|
93
|
+
if (typeof snippet !== "string" || !snippet || !language) return;
|
|
94
|
+
|
|
95
|
+
return hljs.highlight(snippet, { language }).value;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { highlightSnippet, languageToHighlightKey, registerDefaultLanguages };
|