ably-ui 4.2.0.dev.1a5533f
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +34 -0
- data/LICENSE +13 -0
- data/README.md +419 -0
- data/ably-ui.gemspec +22 -0
- data/lib/ably_ui/core/code/code.html.erb +3 -0
- data/lib/ably_ui/core/code/code.rb +11 -0
- data/lib/ably_ui/core/code/component.css +70 -0
- data/lib/ably_ui/core/code/component.js +1 -0
- data/lib/ably_ui/core/connect_state_wrapper/component.js +1 -0
- data/lib/ably_ui/core/contact_footer/component.css +12 -0
- data/lib/ably_ui/core/contact_footer/component.js +1 -0
- data/lib/ably_ui/core/contact_footer/contact_footer.html.erb +32 -0
- data/lib/ably_ui/core/contact_footer/contact_footer.rb +13 -0
- data/lib/ably_ui/core/cookie_message/component.css +14 -0
- data/lib/ably_ui/core/cookie_message/component.js +1 -0
- data/lib/ably_ui/core/core.rb +65 -0
- data/lib/ably_ui/core/feature_footer/component.css +13 -0
- data/lib/ably_ui/core/feature_footer/component.js +1 -0
- data/lib/ably_ui/core/feature_footer/feature_footer.html.erb +54 -0
- data/lib/ably_ui/core/feature_footer/feature_footer.rb +30 -0
- data/lib/ably_ui/core/featured_link/component.css +17 -0
- data/lib/ably_ui/core/featured_link/component.js +1 -0
- data/lib/ably_ui/core/featured_link/featured_link.html.erb +6 -0
- data/lib/ably_ui/core/featured_link/featured_link.rb +17 -0
- data/lib/ably_ui/core/flash/component.css +30 -0
- data/lib/ably_ui/core/flash/component.js +1 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Light-Italic.eot +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Light-Italic.otf +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Light-Italic.woff +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Light-Italic.woff2 +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Light.eot +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Light.otf +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Light.woff +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Light.woff2 +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Medium-Italic.eot +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Medium-Italic.otf +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Medium-Italic.woff +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Medium-Italic.woff2 +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Medium.eot +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Medium.otf +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Medium.woff +0 -0
- data/lib/ably_ui/core/fonts/NEXT-Book-Medium.woff2 +0 -0
- data/lib/ably_ui/core/fonts/next.css +59 -0
- data/lib/ably_ui/core/footer/component.css +14 -0
- data/lib/ably_ui/core/footer/component.js +1 -0
- data/lib/ably_ui/core/footer/footer.html.erb +190 -0
- data/lib/ably_ui/core/footer/footer.rb +14 -0
- data/lib/ably_ui/core/icon/component.css +1 -0
- data/lib/ably_ui/core/icon/component.js +1 -0
- data/lib/ably_ui/core/icon/icon.html.erb +3 -0
- data/lib/ably_ui/core/icon/icon.rb +25 -0
- data/lib/ably_ui/core/images/ably-logo.svg +15 -0
- data/lib/ably_ui/core/images/ably-stack.svg +14 -0
- data/lib/ably_ui/core/images/blog-thumb1.jpg +0 -0
- data/lib/ably_ui/core/images/blog-thumb2.jpg +0 -0
- data/lib/ably_ui/core/images/blog-thumb3.jpg +0 -0
- data/lib/ably_ui/core/images/cust-logo-ao-col-pos.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-ao-col-pos@2x.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-ausopen-col-pos.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-ausopen-col-pos@2x.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-hubspot-col-pos.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-hubspot-col-pos@2x.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-lightspeed-col-pos.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-lightspeed-col-pos@2x.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-lightspeed-syst-col-pos.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-lightspeed-syst-col-pos@2x.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-split-col-pos.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-split-col-pos@2x.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-vitac-col-pos.png +0 -0
- data/lib/ably_ui/core/images/cust-logo-vitac-col-pos@2x.png +0 -0
- data/lib/ably_ui/core/images/cust-photo-hubspot-max-freiert.jpg +0 -0
- data/lib/ably_ui/core/images/cust-photo-split-pato-echague.jpg +0 -0
- data/lib/ably_ui/core/images/cust-photo-vitac-joe-antonio.jpg +0 -0
- data/lib/ably_ui/core/images/flexible-companies.png +0 -0
- data/lib/ably_ui/core/images/rocket-list-2021.png +0 -0
- data/lib/ably_ui/core/images/scale-motif-open-empathetic.svg +1 -0
- data/lib/ably_ui/core/images/technical-support-01-800x533.jpg +0 -0
- data/lib/ably_ui/core/logo/component.js +1 -0
- data/lib/ably_ui/core/logo/logo.html.erb +28 -0
- data/lib/ably_ui/core/logo/logo.rb +19 -0
- data/lib/ably_ui/core/meganav/component.css +103 -0
- data/lib/ably_ui/core/meganav/component.js +1 -0
- data/lib/ably_ui/core/meganav/component.json +37 -0
- data/lib/ably_ui/core/meganav/meganav.html.erb +26 -0
- data/lib/ably_ui/core/meganav/meganav.rb +53 -0
- data/lib/ably_ui/core/meganav_blog_posts_list/component.js +1 -0
- data/lib/ably_ui/core/meganav_blog_posts_list/meganav_blog_posts_list.html.erb +5 -0
- data/lib/ably_ui/core/meganav_blog_posts_list/meganav_blog_posts_list.rb +13 -0
- data/lib/ably_ui/core/meganav_content_developers/component.js +1 -0
- data/lib/ably_ui/core/meganav_content_developers/meganav_content_developers.html.erb +77 -0
- data/lib/ably_ui/core/meganav_content_developers/meganav_content_developers.rb +13 -0
- data/lib/ably_ui/core/meganav_content_platform/component.js +1 -0
- data/lib/ably_ui/core/meganav_content_platform/meganav_content_platform.html.erb +91 -0
- data/lib/ably_ui/core/meganav_content_platform/meganav_content_platform.rb +14 -0
- data/lib/ably_ui/core/meganav_content_use_cases/component.js +1 -0
- data/lib/ably_ui/core/meganav_content_use_cases/meganav_content_use_cases.html.erb +72 -0
- data/lib/ably_ui/core/meganav_content_use_cases/meganav_content_use_cases.rb +13 -0
- data/lib/ably_ui/core/meganav_content_why_ably/component.js +1 -0
- data/lib/ably_ui/core/meganav_content_why_ably/meganav_content_why_ably.html.erb +70 -0
- data/lib/ably_ui/core/meganav_content_why_ably/meganav_content_why_ably.rb +13 -0
- data/lib/ably_ui/core/meganav_control/component.js +1 -0
- data/lib/ably_ui/core/meganav_control/meganav_control.html.erb +6 -0
- data/lib/ably_ui/core/meganav_control/meganav_control.rb +12 -0
- data/lib/ably_ui/core/meganav_control_mobile_dropdown/component.js +1 -0
- data/lib/ably_ui/core/meganav_control_mobile_dropdown/meganav_control_mobile_dropdown.html.erb +7 -0
- data/lib/ably_ui/core/meganav_control_mobile_dropdown/meganav_control_mobile_dropdown.rb +11 -0
- data/lib/ably_ui/core/meganav_control_mobile_panel_close/component.js +1 -0
- data/lib/ably_ui/core/meganav_control_mobile_panel_close/meganav_control_mobile_panel_close.html.erb +10 -0
- data/lib/ably_ui/core/meganav_control_mobile_panel_close/meganav_control_mobile_panel_close.rb +9 -0
- data/lib/ably_ui/core/meganav_control_mobile_panel_open/component.js +1 -0
- data/lib/ably_ui/core/meganav_control_mobile_panel_open/meganav_control_mobile_panel_open.html.erb +7 -0
- data/lib/ably_ui/core/meganav_control_mobile_panel_open/meganav_control_mobile_panel_open.rb +9 -0
- data/lib/ably_ui/core/meganav_items_desktop/component.js +1 -0
- data/lib/ably_ui/core/meganav_items_desktop/meganav_items_desktop.html.erb +16 -0
- data/lib/ably_ui/core/meganav_items_desktop/meganav_items_desktop.rb +15 -0
- data/lib/ably_ui/core/meganav_items_mobile/component.js +1 -0
- data/lib/ably_ui/core/meganav_items_mobile/meganav_items_mobile.html.erb +47 -0
- data/lib/ably_ui/core/meganav_items_mobile/meganav_items_mobile.rb +17 -0
- data/lib/ably_ui/core/meganav_items_signed_in/component.js +1 -0
- data/lib/ably_ui/core/meganav_items_signed_in/meganav_items_signed_in.html.erb +49 -0
- data/lib/ably_ui/core/meganav_items_signed_in/meganav_items_signed_in.rb +33 -0
- data/lib/ably_ui/core/notice/component.css +8 -0
- data/lib/ably_ui/core/notice/component.js +2 -0
- data/lib/ably_ui/core/notice/notice.html.erb +16 -0
- data/lib/ably_ui/core/notice/notice.rb +29 -0
- data/lib/ably_ui/core/scripts.js +1 -0
- data/lib/ably_ui/core/showcase/component.css +31 -0
- data/lib/ably_ui/core/showcase/component.js +1 -0
- data/lib/ably_ui/core/showcase/showcase.html.erb +76 -0
- data/lib/ably_ui/core/showcase/showcase.rb +190 -0
- data/lib/ably_ui/core/sign_out_link/component.js +1 -0
- data/lib/ably_ui/core/sign_out_link/sign_out_link.html.erb +1 -0
- data/lib/ably_ui/core/sign_out_link/sign_out_link.rb +17 -0
- data/lib/ably_ui/core/slider/component.css +9 -0
- data/lib/ably_ui/core/slider/component.js +1 -0
- data/lib/ably_ui/core/slider/slider.html.erb +28 -0
- data/lib/ably_ui/core/slider/slider.rb +38 -0
- data/lib/ably_ui/core/sprites.svg +113 -0
- data/lib/ably_ui/core/styles.css +332 -0
- data/lib/ably_ui/core/uptime/component.css +129 -0
- data/lib/ably_ui/core/uptime/component.js +1 -0
- data/lib/ably_ui/core/uptime/uptime.html.erb +0 -0
- data/lib/ably_ui/core/uptime/uptime.rb +7 -0
- data/lib/ably_ui/reset/scripts.js +1 -0
- data/lib/ably_ui/reset/styles.css +487 -0
- data/lib/ably_ui/version.rb +3 -0
- data/lib/ably_ui.rb +27 -0
- metadata +210 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d90d2dcabfe89fbf34064b45b05e22286e68f0508475509e6a7ab9e32ac45513
|
4
|
+
data.tar.gz: f385c2cb554a828e6faa7678291d23a1f95688edbefb19ad3fe8d873a11ffcf0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e63f99bd5cb2d9736b3d5d5cf903f42d536868d862beee75fd6106613d6d4270e59f62676ed7aaa30f3191a830a31a14af6250074e9998ca3dc38c01ae631912
|
7
|
+
data.tar.gz: bbbf3d2ae41413b024e2e79bc2eb90a775882a617182df8fa7856c374327847f826b1802f58b361d4c744a8462feb7ac183b696d02d1a7ab7819dd4d8189cd67
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ably-ui (4.2.0)
|
5
|
+
view_component (~> 2.33.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (6.1.3.2)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
15
|
+
zeitwerk (~> 2.3)
|
16
|
+
concurrent-ruby (1.1.9)
|
17
|
+
i18n (1.8.10)
|
18
|
+
concurrent-ruby (~> 1.0)
|
19
|
+
minitest (5.14.4)
|
20
|
+
tzinfo (2.0.4)
|
21
|
+
concurrent-ruby (~> 1.0)
|
22
|
+
view_component (2.33.0)
|
23
|
+
activesupport (>= 5.0.0, < 7.0)
|
24
|
+
zeitwerk (2.4.2)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
ably-ui!
|
31
|
+
view_component
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.2.19
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2015-2020 Ably Real-time Ltd (ably.com)
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,419 @@
|
|
1
|
+
**_Note:_** some features are still in development and their documentation might be incomplete. Lookout for the ⚠️ icon.
|
2
|
+
|
3
|
+
# ably-ui
|
4
|
+
|
5
|
+
`ably-ui` is the of home of the Ably design system library ([https://ably-ui.herokuapp.com/](https://ably-ui.herokuapp.com/)). It provides a showcase, development/test environment and a publishing pipeline for different distributables.
|
6
|
+
|
7
|
+
## Getting started
|
8
|
+
|
9
|
+
`ably-ui` is a library built in mind with supporting a variety of websites/apps based on core web technologies. That's why where possible we build based on those but publish in a way that is easy to consume for frameworks we use across our properties.
|
10
|
+
|
11
|
+
As an example, the `Logo` component has two templates, for a [React](https://reactjs.org/) component and [view-component](https://viewcomponent.org/) but uses the same CSS classes and same JavaScript hooks (`data-id`).
|
12
|
+
|
13
|
+
In some cases, this is impractical. Some components will be more specialized and take advantage of a given framework, and we will have no need to make it available in multiple frameworks (for example, something that is only used within signed in, SPA like areas).
|
14
|
+
|
15
|
+
### Guiding principles
|
16
|
+
|
17
|
+
1. Provide easy access to common patterns and assets, from brand colours to navigation.
|
18
|
+
2. Use the web platform as much as possible without relying on frameworks.
|
19
|
+
3. Be flexible in how the library can be integrated.
|
20
|
+
|
21
|
+
### Library structure
|
22
|
+
|
23
|
+
The library is built out of modules, assets, JavaScript & ruby modules and components. A module is a container for all of those.
|
24
|
+
|
25
|
+
For example, the `core` module provides the most general elements one can build the “chrome” of a web-based interface — typography, colours, spacing (i.e., containers) etc. The components within the module support our most common needs to build that “chrome”, like navigation elements, footer, hero sections, code samples etc. Assets, JavaScript & ruby modules are all shared between the components in the module.
|
26
|
+
|
27
|
+
Components do not require assets directly — instead, it's up to the consumer to load the assets and pass them to the components. This ensures flexibility in terms of URLs.
|
28
|
+
|
29
|
+
Each module, apart from components, exposes a `scripts.js`, `styles.css` and `MODULE_NAME.rb` files. `scripts.js` contains helper functions, `MODULE_NAME.rb` contains modules that components can include. `styles.css` contains CSS that does not belong to any module in particular.
|
30
|
+
|
31
|
+
### Installation
|
32
|
+
|
33
|
+
### NPM
|
34
|
+
|
35
|
+
This type of installation gives you access to module/components assets as well as React components.
|
36
|
+
|
37
|
+
Note, the package is currently hosted in our private GitHub registry, so you will need a `GITHUB_REGISTRY_TOKEN` environment variable in your shell to be able to install it. See [here](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) for instructions on obtaining one.
|
38
|
+
|
39
|
+
```bash
|
40
|
+
npm install @ably/ui
|
41
|
+
|
42
|
+
# or
|
43
|
+
|
44
|
+
yarn add @ably/ui
|
45
|
+
```
|
46
|
+
|
47
|
+
To attach the imported JavaScript from the `Core` module to the `window` object:
|
48
|
+
|
49
|
+
```js
|
50
|
+
import "@ably/ui/core/scripts";
|
51
|
+
|
52
|
+
// AblyUi.Core is now available on window
|
53
|
+
```
|
54
|
+
|
55
|
+
To import an es6 `core` module and expose nothing to window:
|
56
|
+
|
57
|
+
```js
|
58
|
+
import ablyUiCore from "@ably/ui/core/scripts";
|
59
|
+
```
|
60
|
+
|
61
|
+
To import the JavaScript for an `Accordion` component:
|
62
|
+
|
63
|
+
```js
|
64
|
+
import Accordion from "@ably/ui/core/accordion/component";
|
65
|
+
```
|
66
|
+
|
67
|
+
If your bundler supports CSS importing, you can import it as well:
|
68
|
+
|
69
|
+
```js
|
70
|
+
import "@ably/ui/core/styles.css";
|
71
|
+
```
|
72
|
+
|
73
|
+
### Setting up TailwindCSS
|
74
|
+
|
75
|
+
Currently, AblyUI CSS is built to work with TailwindCSS. To integrate it into your app:
|
76
|
+
|
77
|
+
1. Add AblyUI to your project
|
78
|
+
1. Add TailwindCSS to your project https://tailwindcss.com/docs/installation#installing-tailwind-css-as-a-post-css-plugin
|
79
|
+
1. Add the following to your `tailwind.config.js`. Note how different config properties are always extended by the `ablyUIConfig`:
|
80
|
+
|
81
|
+
```js
|
82
|
+
const extendConfig = require("@ably/ui/tailwind.extend.js");
|
83
|
+
|
84
|
+
module.exports = extendConfig((ablyUIConfig) => ({
|
85
|
+
...ablyUIConfig,
|
86
|
+
purge: {
|
87
|
+
content: [
|
88
|
+
...(relative - globbed - paths - to - your - templates),
|
89
|
+
...ablyUIConfig.purge.content,
|
90
|
+
],
|
91
|
+
options: {
|
92
|
+
...ablyUIConfig.purge.options,
|
93
|
+
},
|
94
|
+
},
|
95
|
+
}));
|
96
|
+
```
|
97
|
+
|
98
|
+
1. In the CSS file you added your tailwind declarations too, import the CSS for the modules and components you need:
|
99
|
+
|
100
|
+
```css
|
101
|
+
@import "tailwindcss/base";
|
102
|
+
@import "tailwindcss/components";
|
103
|
+
@import "tailwindcss/utilities";
|
104
|
+
|
105
|
+
@import "@ably/ui/reset/styles.css"; /* needed as we disable the default Tailwind reset */
|
106
|
+
@import "@ably/ui/core/styles.css"; /* styles for core module components and more */
|
107
|
+
@import "@ably/ui/core/Meganav/component.css";
|
108
|
+
@import "@ably/ui/core/ContactFooter/component.css";
|
109
|
+
```
|
110
|
+
|
111
|
+
#### Importing React components
|
112
|
+
|
113
|
+
Note that depending on the component, you might still need to include CSS & JS for it:
|
114
|
+
|
115
|
+
```js
|
116
|
+
import Meganav from "@ably/ui/core/Meganav";
|
117
|
+
```
|
118
|
+
|
119
|
+
#### Importing ViewComponent (Rails) components
|
120
|
+
|
121
|
+
To use `ably-ui` with [Ruby on Rails](https://rubyonrails.org/) add the `ably-ui` gem to your `Gemfile`:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
gem 'ably-ui',
|
125
|
+
'1.0.0',
|
126
|
+
require: 'ably_ui',
|
127
|
+
source: 'https://rubygems.pkg.github.com/ably'
|
128
|
+
```
|
129
|
+
|
130
|
+
And then run:
|
131
|
+
|
132
|
+
```bash
|
133
|
+
bundle config https://rubygems.pkg.github.com/ably USERNAME:TOKEN
|
134
|
+
```
|
135
|
+
|
136
|
+
Where `USERNAME` is your GitHub username (without the `@`) and TOKEN is your [GitHub access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token). This is required because the gem is downloaded from a private gem registry on GitHub.
|
137
|
+
|
138
|
+
Components are exposed as [View Components](https://github.com/github/view_component) and should be available in any view:
|
139
|
+
|
140
|
+
```erb
|
141
|
+
<%= render(AblyUi::Core::Meganav.new) %>
|
142
|
+
```
|
143
|
+
|
144
|
+
Note that this loads neither CSS nor JS — these need to still be loaded by a bundler like webpack.
|
145
|
+
|
146
|
+
## Usage
|
147
|
+
|
148
|
+
### Icons
|
149
|
+
|
150
|
+
Putting SVG files inside and `src/MODULE_NAME/icons` folder will add them to a per-module sprites file that will be available at the root of the module (e.g., `core/sprites.svg`). This file can be loaded with the `loadSprites` helper available in the `core` module or include in the page directly.
|
151
|
+
|
152
|
+
Usage with the `Icon` React component:
|
153
|
+
|
154
|
+
```jsx
|
155
|
+
<Icon name="icon-display-live-chat" size="3rem" additionalCSS="block mb-16" />
|
156
|
+
```
|
157
|
+
|
158
|
+
Usage with `Icon` VW component:
|
159
|
+
|
160
|
+
```rb
|
161
|
+
<%= render(AblyUi::Core::Icon.new(name: "icon-gui-disclosure-arrow", size: "1rem", additional_css: "align-middle transform rotate-180 mr-4")) %>
|
162
|
+
```
|
163
|
+
|
164
|
+
Usage without a component:
|
165
|
+
|
166
|
+
```html
|
167
|
+
<!-- The width and height are required for correct sizing. The actual color class might depend on the svg and whether it uses strokes, fills etc. Note as well xlink:href, which is xlinkHref in react. -->
|
168
|
+
<svg class="w-12 h-12 text-cool-black">
|
169
|
+
<use xlink:href="#sprite-disclosure-arrow" />
|
170
|
+
</svg>
|
171
|
+
```
|
172
|
+
|
173
|
+
Usage without a component, in React, with hover states. Note the [group](https://tailwindcss.com/docs/hover-focus-and-other-states#group-hover) class:
|
174
|
+
|
175
|
+
```jsx
|
176
|
+
<a
|
177
|
+
href="{url}"
|
178
|
+
className="text-gui-default hover:text-gui-hover focus:text-gui-focus group"
|
179
|
+
>
|
180
|
+
{children}
|
181
|
+
<svg className="w-12 h-12 transform -rotate-90 align-top ui-icon-dark-grey group-hover:icon-gui-hover group-focus:icon-gui-focus ml-4">
|
182
|
+
<use xlinkHref="#sprite-disclosure-arrow" />
|
183
|
+
</svg>
|
184
|
+
</a>
|
185
|
+
```
|
186
|
+
|
187
|
+
See https://ably-ui.herokuapp.com/components/icon for more details.
|
188
|
+
|
189
|
+
### Fonts
|
190
|
+
|
191
|
+
Font assets are not included automagically but are part of the repo, together with an example of font-face file; see `src/core/fonts` for examples. Make sure to include the licence file declaration on usage.
|
192
|
+
|
193
|
+
See `preview/app/javascript/styles/application.css` for an example when using webpacker/rails.
|
194
|
+
|
195
|
+
#### Rails
|
196
|
+
|
197
|
+
Because the gem directories are on the asset path (see [Importing ViewComponent (Rails) components](#user-content-importing-viewcomponent-rails-components) section), they will work with standard asset helpers (i.e., `asset_path`).
|
198
|
+
|
199
|
+
### Accessibility
|
200
|
+
|
201
|
+
An important part of ably-ui is ensuring the produced UI is accessible to as wide range of users as possible. All components should adhere to at least AA accessibility standards. In most cases, this can be accomplished by following a few simple rules:
|
202
|
+
|
203
|
+
— use the correct [HTML elements](https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML): anchors for navigation, buttons for interacting, lists for lists etc
|
204
|
+
|
205
|
+
- test using a screen reader (for example [Voice Over on a Mac OSX with Web rotor](https://support.apple.com/en-gb/guide/voiceover/welcome/mac))
|
206
|
+
— confirm designs have appropriate tap targets, contrast
|
207
|
+
— use [aria attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) where you reach the limits of what you can do with HTML
|
208
|
+
— don't break the web platform (i.e., don't break the behaviour of a back button, scrolling, in-page links etc)
|
209
|
+
|
210
|
+
## Development
|
211
|
+
|
212
|
+
The repository includes a “preview” app, which is serves both as a showcase and development environment.
|
213
|
+
|
214
|
+
To use, first make sure you install dependencies both for the library and the “preview” app:
|
215
|
+
|
216
|
+
```bash
|
217
|
+
yarn && bundle
|
218
|
+
cd preview
|
219
|
+
yarn && bundle
|
220
|
+
```
|
221
|
+
|
222
|
+
Then, from the root of the repository, run:
|
223
|
+
|
224
|
+
```bash
|
225
|
+
yarn dev
|
226
|
+
```
|
227
|
+
|
228
|
+
This will run the app and use the published versions of the `ably-ui`, specified in `preview/Gemfile` and `preview/package.json` NPM package.
|
229
|
+
|
230
|
+
### Using the local ably-ui in the preview app
|
231
|
+
|
232
|
+
It's possible to use the local version of ably-ui in the “preview” app. Enabling this, requires separate steps for the `npm` and `ruby` packages.
|
233
|
+
|
234
|
+
For `npm`:
|
235
|
+
|
236
|
+
```bash
|
237
|
+
# in the root directory
|
238
|
+
yarn link
|
239
|
+
# in the the "preview" directory
|
240
|
+
yarn link @ably/ui
|
241
|
+
```
|
242
|
+
|
243
|
+
For `ruby`:
|
244
|
+
|
245
|
+
In `preview/Gemfile` replace `source: "https://rubygems.pkg.github.com/ably"` with `path: '../'` and run:
|
246
|
+
|
247
|
+
```bash
|
248
|
+
# in preview
|
249
|
+
bundle --no-cache
|
250
|
+
```
|
251
|
+
|
252
|
+
Why not `bundle config set local.ably-ui ../`? Because that feature is built around the local gem being a separate repo, and works poorly with our config.
|
253
|
+
|
254
|
+
A caveat of this approach is that the change `preview/Gemfile` should not be committed, as it will cause the remote app to not build.
|
255
|
+
|
256
|
+
### Using a deployed package of ably-ui in the preview app
|
257
|
+
|
258
|
+
If at anytime you don't want to use the local NPM package and/or gems any more, you can do:
|
259
|
+
|
260
|
+
```bash
|
261
|
+
# in "preview" directory
|
262
|
+
yarn unlink @ably/ui
|
263
|
+
```
|
264
|
+
|
265
|
+
Then change back `path` to source `source` in the `Gemfile`. If you need to update `Gemfile.lock` without installing gems, you can run `bundle lock`.
|
266
|
+
|
267
|
+
#### Publishing pre-release packages for review apps
|
268
|
+
|
269
|
+
Make sure you commit & push your work and remove the [development-specific config](#using-the-development-build-of-ably-ui-in-the-preview-app) before doing this.
|
270
|
+
|
271
|
+
You will need to authenticate with the GitHub [NPM registry](https://docs.github.com/en/free-pro-team@latest/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages#authenticating-to-github-packages) and [gem registry](https://docs.github.com/en/free-pro-team@latest/packages/using-github-packages-with-your-projects-ecosystem/configuring-rubygems-for-use-with-github-packages#authenticating-with-a-personal-access-token) to publish.
|
272
|
+
|
273
|
+
After the above, you should have:
|
274
|
+
|
275
|
+
- GITHUB_REGISTRY_TOKEN set in your environment (`.npmrc` will read from it)
|
276
|
+
- you should do registry login as described in the above docs with your GitHub username and password
|
277
|
+
- a `~/.gem/credentials` file with a `:github: Bearer TOKEN` (replace GITHUB_REGISTRY_TOKEN with your token - interpolation does not work here)
|
278
|
+
|
279
|
+
To deploy a review app with your in-progress code, you can use the `pre-release` script:
|
280
|
+
|
281
|
+
```bash
|
282
|
+
# in root
|
283
|
+
./pre-release
|
284
|
+
```
|
285
|
+
|
286
|
+
This will do a couple of things:
|
287
|
+
|
288
|
+
— update your local dependencies for ably-ui and run a production build
|
289
|
+
— release a gem and a NPM package with the version built from your current SemVer but adding a pre-release tag based on a short SHA of your HEAD commit
|
290
|
+
|
291
|
+
- update the preview app
|
292
|
+
- commit all the above and push to origin
|
293
|
+
|
294
|
+
This will trigger a build of the review app.
|
295
|
+
|
296
|
+
### Components
|
297
|
+
|
298
|
+
Components and modules contain JS and CSS files, but no templates. Instead, for each framework that a given component supports, a separate "framework template" is created. A component can still be used in any other framework by just using it's required assets.
|
299
|
+
|
300
|
+
All components live in `src` and follow a directory and filename convention:
|
301
|
+
|
302
|
+
- module directory (TitleCase)
|
303
|
+
- module asset files: `scripts.js` for JavaScript and `styles.css` for CSS
|
304
|
+
- component directory (TitleCase)
|
305
|
+
- `component.js` - this is the entry file for a component and is the only required file
|
306
|
+
- `components.css` - additional CSS
|
307
|
+
- for ruby components, you need `component.rb` and `component.html.erb`
|
308
|
+
- for react, `components.jsx`
|
309
|
+
|
310
|
+
For example:
|
311
|
+
|
312
|
+
```
|
313
|
+
- Core
|
314
|
+
- script.js
|
315
|
+
- styles.css
|
316
|
+
- Accordion
|
317
|
+
- component.rb
|
318
|
+
- component.html.erb
|
319
|
+
- component.js
|
320
|
+
- component.css
|
321
|
+
- component.jsx
|
322
|
+
```
|
323
|
+
|
324
|
+
#### CSS
|
325
|
+
|
326
|
+
##### z-index and positioning
|
327
|
+
|
328
|
+
If using positioning any other than static, be mindful of creating stacking contexts. In `properties.css` you'll find the `z-index` values for the HTML stacking context (used by components like the meganav). When creating a new one within your component, hoist the z-index values to the selector that creates the stacking context and define `z-index` values there for easy scanning (see https://www.oreilly.com/library/view/developing-web-components/9781491905685/ch04.html for a good write-up on stacking contexts and z-index.).
|
329
|
+
|
330
|
+
### Formatting & linting files
|
331
|
+
|
332
|
+
By default, [Prettier](https://prettier.io/) & [ESLint](https://eslint.org/) will handle most of the frontend files. You can use them through your editor (which should pick up the relevant config files) or on the command line (see `scripts` in package.json).
|
333
|
+
|
334
|
+
Neither handles `erb` and `rb` files. The only config for those files is at the moment in `editorconfig`.
|
335
|
+
|
336
|
+
#### Note
|
337
|
+
|
338
|
+
Until we have set up formatting scripts for `erb` it's worth setting up [htmlbeautifier](https://github.com/threedaymonk/htmlbeautifier) for your editor (for example with https://github.com/aliariff/vscode-erb-beautify if you use VS Code) and tracking [this issue in Prettier](https://github.com/prettier/plugin-ruby/issues/371), as Prettier is much faster and hopefully will get support for `erb`.
|
339
|
+
|
340
|
+
### Adding a new component
|
341
|
+
|
342
|
+
#### To add a new component:
|
343
|
+
|
344
|
+
1. Add it in `modules-config.js`
|
345
|
+
2. Create a folder in `src`, in the module of your choice. The folder name should be TitleCase.
|
346
|
+
3. Add a `component.js`
|
347
|
+
|
348
|
+
- if the component has custom CSS, add a `component.css` file as well. Add `@layer components {}` to its contents. Import the CSS file in `component.js`
|
349
|
+
- if you need a VW component, add `component.rb` and `component.html.erb`
|
350
|
+
- if you need a React component, add a `components.jsx`
|
351
|
+
|
352
|
+
#### To see this component in the preview app:
|
353
|
+
|
354
|
+
##### For React components:
|
355
|
+
|
356
|
+
1. Import the file into `preview/app/javascript/packs/application.js` and add as input to the `reactRenderer`
|
357
|
+
2. If it contains custom CSS, import it into `preview/app/javascript/styles/application.css`
|
358
|
+
3. Add a template in `preview/app/views/components`, with a `_react` suffix, i.e. `my_component_react.html.erb`
|
359
|
+
|
360
|
+
##### For VW components:
|
361
|
+
|
362
|
+
1. You will need to restart the server for Rails to load the component (this will also need to happen after any changes to `component.rb`)
|
363
|
+
1. If it contains custom CSS, import it into `preview/app/javascript/styles/application.css`
|
364
|
+
1. Add a template in `preview/app/views/components`, with a `_vw` suffix, i.e. `my_component_vw.html.erb`
|
365
|
+
1. If the component has any JavaScript, import it in the view (`preview/app/views/components/my_component_vw.html.erb`) and initialize:
|
366
|
+
|
367
|
+
```rb
|
368
|
+
<% content_for :component do %>
|
369
|
+
<%= javascript_include_tag 'ably_ui/core/my_component/component' %>
|
370
|
+
<script type="text/javascript">
|
371
|
+
document.addEventListener("DOMContentLoaded", () => {
|
372
|
+
const container = document.querySelector("[data-id=my_component]");
|
373
|
+
AblyUI.Core.MyComponent(container);
|
374
|
+
});
|
375
|
+
</script>
|
376
|
+
<% end %>
|
377
|
+
```
|
378
|
+
|
379
|
+
### Publishing
|
380
|
+
|
381
|
+
We use [Semantic Versioning 2.0.0](https://semver.org/) to version different library versions.
|
382
|
+
|
383
|
+
Packages are published to the [GitHub private registry](https://github.com/features/packages).
|
384
|
+
|
385
|
+
Publishing is done by tagging a release in GitHub. This triggers a GitHub action that pushes to the private NPM and gem registries as well as publishing new artefacts in the CDN, with the version taken from the tag of the GitHub release. ⚠️
|
386
|
+
|
387
|
+
This will trigger GitHub actions in supported apps (currently [Voltaire](http://github.com/ably/voltaire) & [Website](http://github.com/ably/website)) to create a PR with an ably-ui version update.
|
388
|
+
|
389
|
+
**To trigger a release:**
|
390
|
+
|
391
|
+
- Merge your PR into `main`.
|
392
|
+
- On the Github [Ably-UI](http://github.com/ably/ui) repo, [create a new release](https://github.com/ably/ui/releases/new) tag.
|
393
|
+
- Create a new tag with the new version number for the release.
|
394
|
+
- _Do not prefix the tag with a `v`_
|
395
|
+
- Add a meaningful title for the Release.
|
396
|
+
- Click on the Autogenerate release notes button.
|
397
|
+
- Publish Release.
|
398
|
+
|
399
|
+
This will release the packages, update library & preview app and create & push the commit & tag, and also create corresponding PRs in Voltaire & Website.
|
400
|
+
|
401
|
+
### Running tests
|
402
|
+
|
403
|
+
The repo includes [Cypress](https://www.cypress.io/) for snapshot, screenshot, parity and behaviour testing. Cypress runs against the "preview" server (e.g. the same server used for development).
|
404
|
+
|
405
|
+
**Snapshot testing** takes saves the DOM and compares it between runs - updating of snapshots can be done in the Cypress UI.
|
406
|
+
|
407
|
+
**Screenshot testing** takes a screenshot of a component and compares it between runs. Diffs are located in `cypress/screenshots`. To update a screenshot, delete it.
|
408
|
+
|
409
|
+
**Parity testing** checks VW/React components; screenshots are taken of both versions and fail if they are different.
|
410
|
+
|
411
|
+
**Behaviour testing** clicks around the DOM and checks for singular elements on the page to be updated.
|
412
|
+
|
413
|
+
To run integration tests (using [Cypress](https://www.cypress.io/)), you'll need to have the "preview app" running on port 5000, then run:
|
414
|
+
|
415
|
+
```bash
|
416
|
+
yarn cy:open
|
417
|
+
```
|
418
|
+
|
419
|
+
This will open the UI for Cypress, from which you can run the tests. Screenshots are saved in `cypress/screenshots`.
|
data/ably-ui.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ably_ui/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ably-ui"
|
8
|
+
spec.version = AblyUi::VERSION
|
9
|
+
spec.authors = ["Dominik Piatek", "Arti Mathanda", "Bruce Thomas"]
|
10
|
+
spec.email = ["dominik.piatek@ably.com", "arti.mathanda@ably.com", "bruce.thomas@ably.com"]
|
11
|
+
spec.summary = "Shared component library and design system for Ably Real-time Ltd (ably.com)"
|
12
|
+
spec.licenses = ['Apache-2.0']
|
13
|
+
spec.homepage = "https://github.com/ably/ui"
|
14
|
+
|
15
|
+
spec.metadata = {
|
16
|
+
"source_code_uri" => "https://github.com/ably/ui",
|
17
|
+
}
|
18
|
+
|
19
|
+
spec.files = Dir['lib/**/*'] + %w[Gemfile Gemfile.lock LICENSE README.md ably-ui.gemspec]
|
20
|
+
|
21
|
+
spec.add_dependency "view_component", '~> 2.33.0'
|
22
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
@layer base {
|
2
|
+
@import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro&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
|
+
font-style: italic;
|
13
|
+
}
|
14
|
+
|
15
|
+
.hljs-strong {
|
16
|
+
font-weight: 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
|
+
}
|
70
|
+
|