/docs/getting-started.md

https://github.com/wework/ray · Markdown · 135 lines · 99 code · 36 blank · 0 comment · 0 complexity · c22dd37f3146087d16c61f8a4f2658aa MD5 · raw file

  1. ---
  2. title: Getting Started
  3. label: Guide
  4. ---
  5. Just want to get your feet wet? Check out the [codepen demo](https://codepen.io/adamraider/pen/bZoBqL).
  6. ## Install
  7. Install via yarn
  8. ```bash
  9. $ yarn add @wework/ray-core
  10. ```
  11. Install via npm
  12. ```bash
  13. $ npm install --save @wework/ray-core
  14. ```
  15. ## Import
  16. Ray requires both CSS and JavaScript files to be imported into your application.
  17. ### CSS
  18. We encourage the use of the Sass source files, as they give access to Ray variables and mixins. If you are using Sass for your project, simply import the Ray SCSS file into your app's main stylesheet:
  19. ```css
  20. @import '@wework/ray-core/scss/ray-core';
  21. ```
  22. If you prefer to use plain CSS, you can either [use our CDN](#cdn), or import the Ray CSS file at `@wework/ray-core/css/ray-core`
  23. ### JavaScript
  24. In order for certain components to work properly, you must import Ray into your app:
  25. ```js
  26. import '@wework/ray-core';
  27. ```
  28. For convenience, Ray will automatically instantiate any components that require JavaScript on `DOMContentLoaded`.
  29. If components are generated after this event (i.e. client-side rendered), or if they require additional programming, you can import individual component classes and use the APIs available on the component level throughout the documentation:
  30. ```js
  31. import { Select } from '@wework/ray-core';
  32. // instantiate all instances found in the document
  33. Select.createAll();
  34. // manually create a specific instance
  35. const select = Select.create(document.querySelector('.ray-select'));
  36. // manipulate the component from code
  37. select.set('pikachu');
  38. ```
  39. ## CDN
  40. Ray can also be installed via CDN for rapid prototyping.
  41. | Resource | URL |
  42. | -------- | ----------------------------------------------------------------- |
  43. | CSS | https://unpkg.com/@wework/ray-core@latest/css/ray-core.min.css |
  44. | ES5 | https://unpkg.com/@wework/ray-core@latest/scripts/ray-core.min.js |
  45. <br/>
  46. ```html
  47. <html>
  48. <head>
  49. <link
  50. rel="stylesheet"
  51. href="https://unpkg.com/@wework/ray-core@latest/css/ray-core.min.css"
  52. />
  53. </head>
  54. <body>
  55. <div class="ray-select">
  56. ...
  57. </div>
  58. <script src="https://unpkg.com/@wework/ray-core@latest/scripts/ray-core.min.js"></script>
  59. <script>
  60. Ray.Core.Select.create(document.querySelector('.ray-select'));
  61. </script>
  62. </body>
  63. </html>
  64. ```
  65. ## Fonts
  66. You will also need to install Ray fonts, which can be done via WeWork's CDN. See instructions in the [fonts documentation](/foundations/fonts/).
  67. ## Structure
  68. `@wework/ray-core` is structured as follows:
  69. ```txt
  70. .
  71. ├── es/
  72. │ ├── index.js
  73. │ ├── global/
  74. │ ├── components/
  75. ├── umd/
  76. │ ├── index.js
  77. │ ├── global/
  78. │ ├── components/
  79. ├── scripts/
  80. │ ├── ray-core.js
  81. │ ├── ray-core.js.map
  82. │ ├── ray-core.min.js
  83. │ ├── ray-core.min.js.map
  84. ├── scss/
  85. │ ├── ray-core.scss
  86. │ ├── global/
  87. │ ├── components/
  88. ├── css/
  89. │ ├── ray-core.css
  90. │ ├── ray-core.css.map
  91. │ ├── ray-core.min.css
  92. │ ├── ray-core.min.css.map
  93. ├── LICENSE
  94. └── README.md
  95. ```
  96. ## Contributing
  97. Feeling ambitious? Good, because wed love your input and contributions to the design system.
  98. - Create an issue or submit a pull request at [@wework/ray](https://github.com/wework/ray/issues).
  99. - Join us in the [#ray-design-system](https://wework.slack.com/messages/CFLL3QWQ5) slack channel. (For WeWork employees)