import { Meta } from '@storybook/addon-docs';
import '../../src/css/index.scss';

<Meta title="Getting Started/Using the front-end" />

<style>
  {`
  .text-panel {
    background: white;
    margin: 24px auto;
    padding: 48px;
  }

  a {
    text-decoration: underline!important;
    color: black!important;
  }

  .layout {
    margin-top: 48px;
  }

  .push-top--double {
    margin-top: 48px!important;
  }
  
  .push-top {
    margin-top: 24px!important;
  }

  em {
    font-weight: 600;
    font-style: normal;
  }

  ol.sbdocs li:before {
      content: counter(my-awesome-counter)".";
      font-size: 14px;
      position: absolute;
      left: 8px;
  }

  `}
</style>

# Getting started
## Front-end development

<p>The quickest way to set up a new front-end project using with the Umbraco Component Library is to download and install the <a href="https://github.com/stormid/scaffold-cli" target="_blank" rel="nofollow">Storm frontend scaffold CLI</a>.</p>
<p>The tool will give you the means to start creating HTML prototype pages using the components listed in this Storybook.</p>
<nav id="page-nav" aria-label="In page navigation">
    <ul class="in-page-nav">
        <li><a href="#install">Install the Scaffold CLI</a></li>
        <li><a href="#create">Create a new prototype</a></li>
        <li><a href="#styling">Set up your styling</a></li>
        <li><a href="#import">Import the components</a></li>
        <li><a href="#customise">Make them your own</a></li>
    </ul>
</nav>
<section class="layout">
  <div class="text-panel">
    <h2 id="install">1. Install the Scaffold CLI</h2>
    <p>Open a terminal window on your local machine and run the following command:</p>
    <code>npm i -g @stormid/scaffold-cli</code>
    <p>This will download and install the tool so that it's available for you to use from any terminal window from now on.</p>
    <p><em>This step only needs to be done once, or whenever you are working from a new machine.</em></p>
    <p>Installing the CLI tool in this way does not tie it to a specific project, and makes it available to use on any new sites you make in the future.</p>
    <h2 class="push-top--double" id="create">2. Create a new prototype</h2>
    <p>Browse to the folder on your local machine where you would like to store your prototype and open a terminal window.</p>
    <p>Run the following command:</p>
    <code>scaffold &lt;insert-your-project-name-here&gt; --umbraco</code>
    <p>For example, if your project name was "Lorem" you would run:</p>
    <code>scaffold lorem --umbraco</code>
    <p>This will run a few steps in the terminal, and may take a while. </p>
    <ol>
    <li>It first creates a folder called 'lorem' in your current local directory.</li>
        <li>It then downloads and un-packs the <a href="https://github.com/stormid/scaffold" target="_blank" rel="nofollow">storm scaffold code</a> into that folder</li>
        <li>It runs an 'npm install' command so that the site will be ready for you to use once the CLI completes.</li>
        <li>Finally, it downloads the <a href="https://www.npmjs.com/package/@stormid/umbraco-library">Umbraco-library package</a> from npm and installs that too.  This is the step that will allow you to start using these components in your prototype.</li>
    </ol>
    <p>At this point your project is ready to use.</p>
    <h2 class="push-top--double" id="styling">3. Set up your styling</h2>
    <p>As part of the install process, a default SCSS file will have been made for you in the following folder:</p>
    <code>/your-project/src/css/index.scss</code>
    <p>This SCSS file contains imports to all of the stylesheets that are available to you as part of the library, and are named to match their corresponding component.</p>
    <p>These are initially commented out, leaving you free to uncomment the ones you require as you work through your prototype.</p>
    <p>It's important to note that the components have been set up to work with a specific set of variables and mixins. <em>It's strongly recommended that if you're using any of the components, you should also un-comment all abstract and base stylesheets as well</em> to avoid errors in compilation and to keep the layout consistent with the library.</p>
    <h2 class="push-top--double" id="import">4. Import the components</h2>
    <p>The components from the umbraco library can be used by importing them at the top of your prototype pages.</p>
    <p>The only difference between them and other components within your project is that they are imported from your installed 'node_modules' folder using a specific path. For example, to import the Blockquote component, add this line to the top of your page:</p>
    <code>import Blockquote from "@stormid/umbraco-library/src/templates/components/blockquote";</code>
    <p>The component can then be used anywhere in your page layout like this:</p>
    <code>&lt;Blockquote quote="Lorem ipsum" author="Dolor sit amet"/&gt;</code>
    <p>Details of the specific import path and the available properties for each component can be found within this storybook, under the 'Front end code' section of the component's story.</p>
    <h2 class="push-top--double" id="customise">5. Make them your own</h2>
    <p>The components in this library are meant to give you a starting point for your prototype, but it's expected that many of them will need skinned and/or adjusted to match your project's needs.</p>
    <h3 class="push-top">Customising the CSS</h3>
    <p>For small adjustments such as colours, font faces and font sizes, the best approach is to import the component's stylesheet from the library and then create and import your own stylesheet below to make the adjustments. For example, if you needed to alter the banner colours:</p>
    <code>@import '~@stormid/umbraco-library/src/css/components/buttons';<br/>@import './components/banner.scss';</code>
    <p>Each component's story shows you an example of the rendered markup, giving you a guide to the classes you'll need to override.</p>
    <p>Overriding in this way and still importing the original stylesheet means that your component will recieve any updates to styling that may come in future releases of the library. Your alterations will remain in tact as they are seperate from the imported styles.</p>
    <p>If your styling adjustments are significant, you may want to consider removing the imported library SCSS file import entirely and create your own from scratch. This would remove any possibility of updates from the libary, but give you a completely blank starting point for your own styling.</p>
    <h3 class="push-top">Customising the markup</h3>
    <p>If you find that the markup in the components doesn't match the needs of the design, you can create your own JSX version of the component and import that instead.</p>
    <p>Each component's story shows you a rendered version of the markup that the component generates. This can be used as a starting point for creating your own JSX component. Alternatively, if you'd like to access the JSX file itself, you can find this in the project's 'node_modules' folder under '@stormid/umbraco-library/src/templates/components'.</p>
    <p>Be aware that customising the JSX is a technical JavaScript task. Please feel free to discuss this with the Frontend developer team.</p>
  </div>
</section>

