rbi-learning / Today-I-Learned

1 stars 0 forks source link

Today I Learned 08/18 #157

Open paulapereira1 opened 4 years ago

paulapereira1 commented 4 years ago

When declaring a function and an argument, there is no difference between: function addToCart(event){ } Or function addToCart = event => { }

Applying .closest to get the pricing of items in a cart const priceId = theButtonThatGotClicked.closest('[data-priceid]').dataset.priceid // find me the closest element in the DOM with the ‘data-priceid’ element and give that to me => this gives us the price of each product

Sanity.io Sanity is a content management platform that stores data and is user friendly for non developers; frequently used to update apps Step 1:

yarn global add @sanity/cli
sanity init

Step 2: sanity init // this will setup a place to store the CMS locally Step 3: sanity start // starts a localhost:3333 where content can be added Step 4: define a schema in an empty file

import createSchema from 'part:@sanity/base/schema-creator'

// Then import schema types from any plugins that might expose them
import schemaTypes from 'all:part:@sanity/base/schema-type'

// Then we give our schema to the builder and provide the result to Sanity
export default createSchema({

  // We name our schema
  name: 'mySchema',

  // Then proceed to concatenate our document types (just one, for now)
  // to the ones provided by any plugins that are installed
  types: schemaTypes.concat([
    {
      // This is the display name for the type
      title: "Person",

      // The identifier for this document type used in the api's
      name: "person",

      // Documents have the type 'document'. Your schema may describe types beyond documents
      // but let's get back to that later.
      type: "document",

      // Now we proceed to list the fields of our document
      fields: [
        // This document has only one field
        {
          // The display name for this field
          title: "Name",

          // The identifier for this field used in the api's
          name: "name",

          // The type of this field
          type: "string",
        }
      ]
    }
  ])
})