Giter Site home page Giter Site logo

lab-bulma-components's Introduction

logo_ironhack_blue 7

React Components & Bulma

Introduction

Do you know Bulma, a very nice alternative to Bootstrap as a CSS framework? We are going to create a simple website with Bulma and React!

Requirements

  • Fork this repo
  • Clone this repo

You can find the starter code in the starter code folder of this GitHub repo.

Submission

  • Upon completion, run the following commands

    git add .
    git commit -m "done"
    git push origin master
    
  • Create Pull Request so your TAs can check up your work.

Setup

First let's get set up:

  1. After forking and cloning, run npm install.
  2. Install the react and react-dom packages.
$ npm install react react-dom

Bulma installation

To get Bulma, install the npm package:

$ npm install bulma

You will have to import Bulma CSS in every component that will use it. You can do it with the following line:

import 'bulma/css/bulma.css';

Instructions

Iteration 1 | Navbar component

To kick off, create a new folder src/navbar and inside create two files:

  • src/navbar/Navbar.js and
  • src/navbar/Navbar.css.

This component should display a link to "Home", "Login" and "Signup" like in the following example:

To help you, you can use the code from the Bulma Transparent Navbar.

In the end, you will need to import this component into the src/App.js and use it properly in the return statement, instead of the h1 tag which is there for now.

Iteration 2 | FormField component

Following the previous example, create a new folder src/formfield and inside create two files:

  • src/formfield/FormField.js and
  • src/formfield/FormField.css.

Now it's time to create a new component FormField we will use multiple times in the future.

// JSX version
<FormField label="Name" type="text" placeholder="e.g Alex Smith" />
<FormField label="Email" type="email" placeholder="e.g. [email protected]" />
<!-- What is rendered in the DOM -->
<div class="field">
  <label class="label">Name</label>
  <div class="control">
    <input class="input" type="text" placeholder="e.g Alex Smith" />
  </div>
</div>
<div class="field">
  <label class="label">Email</label>
  <div class="control">
    <input class="input" type="email" placeholder="e.g. [email protected]" />
  </div>
</div>

What is visually rendered

As we can see, there are similarities between each of the FormFields so it would be the best to pass props that will fill in different label tags, as well as type and placeholder attributes. To give you a hint, check the following code snippet:

const FormField = props => {
  return (
    <div className='field'>
      <label className='label'>{props.label}</label>
      // some other code goes here
    </div>
  );
};

Iteration 3 | CoolButton Component

Follow the folder/file pattern as we instructed you in the first two iterations.

The goal is to create a component called CoolButton that creates a <button> with the nice Bulma classes.

You will find the Bulma buttons documentation here: https://bulma.io/documentation/elements/button/

// JSX version
<CoolButton isSmall isDanger className="is-rounded my-class">Button 1</CoolButton>
<CoolButton isSmall isSuccess>Button 2</CoolButton>
<!-- What is rendered in the DOM -->
<button class="button is-rounded my-class is-danger is-small">Button 1</button>
<button class="button is-small is-success">Button 2</button>

What is visually rendered

Because there are many cases to code, focus on the following classes: is-primary, is-success, is-danger.

If you need any help, you can have a look how to take the content between an opening tag and a closing tag: Children in JSX

Change your Navbar component so it uses the CoolButton component for the "Login" and "Signup" buttons.

Bonus

If you want, you can do all the cases by using the following object:

{
  isActive: 'is-active',
  isBlack: 'is-black',
  isCentered: 'is-centered',
  isDanger: 'is-danger',
  isDark: 'is-dark',
  isFocused: 'is-focused',
  isGrouped: 'is-grouped',
  isHovered: 'is-hovered',
  isInfo: 'is-info',
  isInverted: 'is-inverted',
  isLarge: 'is-large',
  isLight: 'is-light',
  isLink: 'is-link',
  isLoading: 'is-loading',
  isMedium: 'is-medium',
  isOutlined: 'is-outlined',
  isPrimary: 'is-primary',
  isRight: 'is-right',
  isRounded: 'is-rounded',
  isSelected: 'is-selected',
  isSmall: 'is-small',
  isStatic: 'is-static',
  isSuccess: 'is-success',
  isText: 'is-text',
  isWarning: 'is-warning',
  isWhite: 'is-white',
}

Iteration 4 | A Signup Page

Create a Signup component that contains:

  • A Navbar
  • A form with
    • A FormField for name
    • An FormField for email
    • A FormField for password
    • A CoolButton for submitting the form

Iteration 5 | Bonus

Before continuing, ask for feedback from one of your teachers, they will give you a feedback about what you've done.

Then, you can:

  • Refactor your code
  • Create a Container component (for the class "container")
  • Create a Message component (see the following explanation)

Message Component

Now, we are going to create Message component. You can find the documentation on Bulma's website: https://bulma.io/documentation/components/message/

// JSX version
<Message isInfo title='Hello World'>
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. <strong>Pellentesque risus mi</strong>.
</Message>

What is visually rendered

Happy coding! ❤️

lab-bulma-components's People

Contributors

sandrabosk avatar tzikas avatar mc100s avatar papuarza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.