Getting Started With Gutenberg By Creating Your Own Block

Original Source: https://www.smashingmagazine.com/2018/10/gutenberg-testimonials-sliderblock/

Getting Started With Gutenberg By Creating Your Own Block

Getting Started With Gutenberg By Creating Your Own Block

Muhammad Muhsin

2018-10-08T13:50:00+02:00
2018-10-09T09:40:13+00:00

WordPress is the most popular Content Management System (CMS) by far —powering more than 30% of the web. It has undergone a huge metamorphosis during its 15 years of existence. Its latest addition is Gutenberg which is to be released in version 5.0.

Named after Johannes Gutenberg (the inventor of the printing press), Gutenberg is going to fundamentally change WordPress, further helping reach its goal to democratize publishing.

WordPress usually releases its major features as a plugin to test the waters before baking them into the core. Gutenberg is no exception. In this article, we will learn how to go about building your first Gutenberg block. We will be building a Testimonials Slider Block while dwelling on the basics of Gutenberg.

Here is an outline for this article:

Installing The Gutenberg Plugin
Installing The Testimonials Slider Block
Getting Started With The Configuration
Registering A Block
Introducing Gutenberg Specific Syntax
The attributes Object
The edit And save Functions
Continuing Development
Starting A New Gutenberg Block
Conclusion

This article assumes the following:

Some knowledge of WordPress such as how content is saved and basic plugin development;
Basic understanding of React and ES6;
Knowledge of both npm and webpack.

Recommended reading: The Complete Anatomy Of The Gutenberg WordPress Editor

Front-end is messy and complicated these days. That’s why we publish articles, printed books and webinars with useful techniques to improve your work. Even better: Smashing Membership with a growing selection of front-end & UX goodies. So you get your work done, better and faster.

Explore Smashing Membership ↬

Smashing Cat, just preparing to do some magic stuff.

Installing The Gutenberg Plugin

If you are a WordPress user, you will know that installing a plugin is pretty straightforward. Installing Gutenberg is no exception.

However, the recommended way of installing Gutenberg is by cloning the development version from the GitHub repository since you can get the latest changes. Head on over to the GitHub repository and clone it to your plugins folder in your local WordPress setup. You can make updates to this repository later on when there are changes to the Gutenberg project.

Now when you go and create a page or a post, you will be able to edit using the Gutenberg Editor.

Gutenberg Editor Demo

Gutenberg Editor Demo (Large preview)

Since this article is about creating a Gutenberg Block, we will not go into the introduction to the Editor, For a complete understanding of what is Gutenberg and how to use it, please refer to Manish Dudharejia’s article on Smashing Magazine.

Installing The Testimonials Slider Block

The plugin in question — the one we are going to go through is already published to the WordPress repository.

Please install the Testimonials Slider Block plugin to your local WordPress instance so that you have a feel for how the plugin works.

You can also fork or clone the project from GitHub.

After activating the plugin, you can go to your Gutenberg Editor and add a Testimonials Slider to your content:

Testimonials Slider Block

Selecting the Testimonials Slider Block (Large preview)

Adding content to the Testimonials Slider Block

Adding content to the Testimonials Slider Block (Large preview)

Testimonials Slider Block in the frontend

Testimonials Slider Block in the frontend (Large preview)

Now I will go through how I built the plugin and how you too can build a similar one. To keep the article concise, I will not share the entire code in here. However, after reading this you should be able to create your own Gutenberg block.

Getting Started With The Configuration

A Gutenberg block is generally created as part of a plugin. Our plugin is not going to be any different.

Navigate to the plugins directory in your local WordPress instance. Move to the testimonials-slider-block. Notice the following files and folders:

gutenberg-testimonials-slider.php is the main file which has details of the plugin, such as name, description, author details and license. These details will be used in the plugin description in the Plugins menu in the dashboard. You will see that this file calls the init.php file.
The init.php file enqueues the different JavaScript and CSS files. This includes both the external libraries like Bootstrap and Font Awesome and our build files.
The .babelrc file instructs webpack what kind of JavaScript files we are writing.
The package.json file contains all the npm modules that are used in the plugin. You will use the npm install command to install all those packages.
webpack.config.js file contains the configuration for webpack to build our JavaScript and CSS. if you did not know, webpack is a package bundler mainly used for bundling our JavaScript modules and putting them into one file that is then enqueued by WordPress.

That was a lot of configuration files. Now we can go about actually building our Gutenberg block.

Registering A Block

Within the src folder you will see the index.js file. This is the fle that webpack looks for, to bundle the JavaScript. You can see that this file imports the slider.js file within the block folder.

The block folder has the following styles:

slider.js: contains the actual code for the block
editor.scss: the styles file describing the block within the Gutenberg Editor
style.scss: contains styles pertaining to how the block is displayed in the frontend.

Please open the slider.js file in your editor.

This file first imports both the editor and style scss files. Then it imports internationalization component, registerBlockType and the MediaUpload and PlainText components. The last two components will be used to upload the author image and to take in the different text inputs to save in the database.

Next you will see how a block is registered.

It takes in a name as the first parameter. The name must be prefixed with a namespace specific to your plugin in order to avoid any conflicts with another block with the same name.

The second parameter is an array with the following properties and functions:

Title
The name of the block which will appear when you add a new block in the Gutenberg Editor.
Icon
The block’s icon which will be picked up from dashicons. You can also specify your own SVG icons if you want to.
Category
Under which category of blocks will the block appear. Some of the categories are: common, formatting, layout widgets and embed.
Keywords
An array of strings that describe the block, similar to tags.
Attributes
A JavaScript object which contains a description of the data that is saved by the block.
Edit
The function that provides an interface for the block within the Gutenberg Editor.
Save
The function that describes how the block will be rendered in the frontend.

To learn more, please refer to this documentation.

Introducing Gutenberg Specific Syntax

Gutenberg is built with React and the blocks that we build for Gutenberg use a similar syntax.

It certainly helps to know a bit of React to build custom Gutenberg blocks though you don’t have to be an expert.

The following things are useful to know before starting the block development:

The HTML class is replaced with className like in React.
The edit and save methods return JSX, which stands for JavaScript XML. If you are wondering, JSX is syntax exactly like HTML, except you can use HTML tags and other components like PlainText and RichText within it.
The setAttributes method works similar to React’s setState. What it does is, when you call setAttributes the data in the block is updated and the block within the editor is refreshed.
The block uses props in the edit and save functions, just like React. The props object contains the attributes object, the setAttributes function and a ton of other data.

The attributes Object

The attributes object that was mentioned previously define the data within the Gutenberg block. The WordPress Gutenberg Handbook says:

Attribute sources are used to define the strategy by which block attribute values are extracted from saved post content. They provide a mechanism to map from the saved markup to a JavaScript representation of a block.

Each source accepts an optional selector as the first argument. If a selector is specified, the source behavior will be run against the corresponding element(s) contained within the block. Otherwise, it will be run against the block’s root node.

For more details on how to use attributes, please refer to this guide.

The following is the attributes object that is used in the Testimonials Slider Block:

attributes: {
id: {
source: “attribute”,
selector: “.carousel.slide”,
attribute: “id”
},
testimonials: {
source: “query”,
default: [],
selector: “blockquote.testimonial”,
query: {
image: {
source: “attribute”,
selector: “img”,
attribute: “src”
},
index: {
source: “text”,
selector: “span.testimonial-index”
},
content: {
source: “text”,
selector: “span.testimonial-text”
},
author: {
source: “text”,
selector: “span.testimonial-author span”
},
link: {
source: “text”,
selector: “.testimonial-author-link”
}
}
}
},

The source tells Gutenberg where to look for data within the markup.

Use attribute to extract the value of an attribute from markup, such as the src from img element. The selector and attribute tell what element to look for and what exact attribute to pick the data from respectively. Notice that the selector string picks up an HTML element from the save function.

Use text to extract the inner text from markup and html to extract the inner HTML from markup.

Use query to extract an array of values from markup. Entries of the array are determined by the selector argument, where each matched element within the block will have an entry structured corresponding to the query argument, an object of attribute and text sources.

You can access the attributes in the edit and save functions through props.attributes.

When you use console.log(props.attributes.testimonials) in the edit function, you get the following result:

▼(2) [{…}, {…}]
▼0:
author:”Muhammad”
content: “This is a testimonial”
image: “http://localhost/react-gutenberg/wp-content/uploads/2018/08/0.jpg”
index: 0
link: “https://twitter.com/muhsinlk”
▶__proto__: Object
▼1:
author: “Matt”
content: “This is another testimonial”
image: “http://localhost/react-gutenberg/wp-content/uploads/2018/08/767fc115a1b989744c755db47feb60.jpeg”
index: 1
link: “https://twitter.com/photomatt”
▶__proto__: Object
length: 2
▶__proto__: Array (0)

Therefore, in the above code, id is a text that uniquely describes each testimonial block whereas testimonials is an array of objects where each object has the properties as shown in the above screenshot.

The edit And save Functions

As mentioned above, these two functions describe how the block is rendered in the editor as well as in the frontend respectively.

Please read the full description here.

The edit Function

If you look at the edit function, you will notice the following:

I first get the props.attributes.testimonials array to a const variable. Notice the ES6 Object Destructuring to set the const value.
Then generate an id for the block which will be used to make each block unique when you add more than one Testimonials Slider Block to your content.
Then the testimonialsList is generated, which is got from sorting then mapping the testimonials array that we got in step 1.
Then, the return function gives out JSX, which we discussed earlier. The testimonialsList, which we constructed in step 3 is rendered. The + button is also rendered, pressing which will create a new testimonial inside the block.

If you dig into testimonialsList, you will see that it contains the PlainText and MediaUpload components. These provide the interface for entering the different texts and uploading the author image respectively.

The PlainText component looks like this:

<PlainText
className=”content-plain-text”
style={{ height: 58 }}
placeholder=”Testimonial Text”
value={testimonial.content}
autoFocus
onChange={content => {
const newObject = Object.assign({}, testimonial, {
content: content
});
props.setAttributes({
testimonials: [
…testimonials.filter(
item => item.index != testimonial.index
),
newObject
]
});
}}
/>

The attributes I have used for the PlainText component are:

className
The CSS class of the component in order to style it.
style
To give a minimum height so that the content does not look like a one-line text. Specifying the height using the class selector did not work.
placeholder
The text that will be displayed when no content is added.
value
The value of the component from the object within the testimonials array.
autoFocus
To tell the browser to focus on this component (input field) as soon as the user adds a new testimonial by clicking the + button.
onChange
What looks like the most complex attribute in this list. This function first gets a copy of the current testimonial and assigns the changed content to newObject. Then it spreads the array of objects, filters out the current object using index and then replaces the newObject within the array. This is set using the the props.setAttributes function to the testimonials array.

The save Function

This function does the following:

I first get the props.attributes.testimonials array and props.attributes.id string to const variables. Again, notice the ES6 Object Destructuring being used to set the values for the two const variables id and testimonials.
Then I create the carouselIndicators variable, which is essentially JSX constructed from the testimonials array.
Then the testimonialsList is created from the testimonials array. The snippet below is from the mapped function callback return.

{testimonial.content && (
<p className=”testimonial-text-container”>
<i className=”fa fa-quote-left pull-left” aria-hidden=”true” />
<span className=”testimonial-text”>{testimonial.content}</span>
<i class=”fa fa-quote-right pull-right” aria-hidden=”true” />
</p>
)}

Notice the conditional rendering. The markup will not be rendered for content if the content is not set.
Next, if the testimonials array has objects within it, the HTML is rendered. This is what will be serialized and saved to the database, and this is what will be shown in the frontend (not verbatim).

Continuing Development

I’m sure you want to tinker around this plugin and see what happens. You can continue developing the plugin:

Open up the terminal
Navigate to the plugin’s root directory
npm install
npm start

This will install all the packages, build the files and watch for changes. Every time you make a change to the files, webpack will rebuild the JS and CSS files.

Please note: Markup changes to the blocks will mess up the block in the Gutenberg Editor if you had added it before. Don’t be alarmed — you simply have to remove the block and add it again.

If you are done with developing you can npm run build to minify the files to make it ready for production!

Hopefully, you are now convinced Gutenberg block development is more approachable than it sounds.

I have the following plans in mind for this plugin:

Allow users to select color of text, background and accent.
Allow users to select the size of slider and font.
Avoid depending on libraries like Bootstrap and Font Awesome.

I encourage you to make a pull request with your improvements and extra features.

Starting A New Gutenberg Block

There are many ways to develop a Gutenberg block. One of the recommended ways is to use create-guten-block created by Ahmad Awais. In fact, this project was built based on guten-testimonial-block which was bootstrapped from create-guten-block.

You can also check out Zac Gordon’s repository where he shows how to use the different Gutenberg components in your new block.

Conclusion

We covered the following in today’s article:

Installing and using Gutenberg and Testimonials Slider Block plugins
Configuration for a typical Gutenberg block plugin
Registering a Gutenberg block
How to use the attributes object
The edit and save functions and how to use them.

I hope this article was useful for you. I can’t wait to see what you will build with and for Gutenberg!

Smashing Editorial
(dm, ra, yk, il)

Popular Design News of the Week: October 1, 2018 – October 7, 2018

Original Source: https://www.webdesignerdepot.com/2018/10/popular-design-news-of-the-week-october-1-2018-october-7-2018/

Every week users submit a lot of interesting stuff on our sister site Webdesigner News, highlighting great content from around the web that can be of interest to web designers. 

The best way to keep track of all the great stories and news being posted is simply to check out the Webdesigner News site, however, in case you missed some here’s a quick and useful compilation of the most popular designer news that we curated from the past week.

Note that this is only a very small selection of the links that were posted, so don’t miss out and subscribe to our newsletter and follow the site daily for all the news.

Sourcegraph is Now Open Source

 

How to Build a Case for a Product Redesign

 

Avoiding Zombie Startups

 

Site Design: Moment Zero

 

Why Mojave’s Dark Mode Isn’t Dark Enough

 

6 Types of Clients that End up in Designer’s Hell

 

Build an HTML Email Template from Scratch

 

Pantone Creates the World’s Most Unignorable Colour

 

One Small Step for the Web…

 

Stitch – A Simple, Powerful Database to Store your Creative Talent

 

Web Design Legends: Where are They Now?

 

We Killed the Blog. We Hope You like it

 

Solid – A Decentralized Web by Tim Berners Lee, Creator of the WWW

 

Google Estimated to Be Paying $9 Billion to Be Safari’s Default Search Engine

 

SEO for Startups: A Complete Guide for Startup Founders

 

Prototyping Tools in 2018

 

What is a Design System Anyway?

 

Why We Unfairly Judge Other Designers

 

Krita 4.1.3 Released

 

How Can You Tell if your App will Be a Success?

 

7 Ted Talks Every Designer Should Watch

 

140+ Free Beautiful Script Fonts for Designers in 2018

 

The Surprisingly Dark History of the Color Pink

 

Welcome to Inside Design

 

Is it Really Possible to Use the Internet Privately?

 

Want more? No problem! Keep track of top design news from around the web with Webdesigner News.

Add Realistic Chalk and Sketch Lettering Effects with Sketch’it – only $5!

Source

p img {display:inline-block; margin-right:10px;}
.alignleft {float:left;}
p.showcase {clear:both;}
body#browserfriendly p, body#podcast p, div#emailbody p{margin:0;}

20 Best New Portfolios, October 2018

Original Source: https://www.webdesignerdepot.com/2018/10/20-best-new-portfolios-october-2018/

Hello Readers! Can you believe that I have not found one single Halloween-themed portfolio? I guess no one wanted to base their entire site on a one-day holiday. While understandable, this disappoints me.

Someone get me a vector skeleton!

What we do have is a general mix of calm and soothing minimalist sites punctuated by riotous color which might, if you’re not ready for it, hurt your eyes for a second. Enjoy.

Note: I’m judging these sites by how good they look to me. If they’re creative and original, or classic but really well-done, it’s all good to me. Sometimes, UX and accessibility suffer. For example, many of these sites depend on JavaScript to display their content at all; this is a Bad Idea™, kids. If you find an idea you like and want to adapt to your own site, remember to implement it responsibly.

Landscape

To start us off, Landscape brings us an almost classically minimalist design, with a bit of an asymmetrical, collage-style layout. The (thankfully soundless) highlight reel on the home page can be a little jarring, but does a good job of showing the striking variety in their work.

Platform: WordPress

Louis Ansa

Continuing under “L”, Louis Ansa has an even bolder and even more animation-heavy site, though the animation is a bit easier on the eyes. There is a bit of “collage” in the design, but it’s a light touch that quickly gives way to a more typical layout style, while keeping everything (literally) moving. I personally love the way they used color for this one.

Platform: JS App

Serious Business

The logo for Serious Business has an ironic smiley face because of course it does. They even go so far as to promise to “make Millenials fall in love with your brand”… but I’ll try not to hold that against them.

I’ll say that they’re good at branding, though. The typography combined with some small graphical elements gives the site a distinct personality, while the variety in layout and presentation encourages exploration of the site. Animation takes you pretty seamlessly from one page to another in a way I can’t deny that I like.

Platform: Vue JS App

Fleur Moreau

Fleur Moreau is a studio that seems to make very minimalist and modern school supplies. When it comes right down to it, they do some pretty precision engineering, so their site reflects that professionalism, rather than going for the throw-colors-everywhere approach you might expect. For a site that sells things kids will inevitably destroy, it looks downright elegant, and this is accomplished mostly through typography.

Platform: Vue JS App

Ahmad Fakhry

Ahmad Fakhry is an interior/furniture designer, and so his site is predictably minimalist. What makes it fun for me is that I’m a sucker for those 50/50 split website layouts, though this one adapts, depending on which content is taking priority at any given moment. That last bit is something I like to see.

Platform: Static Site

Adele Bates

Adele Bates’ portfolio is one of those that puts the navigation all around the edges of the design. I’m normally not a fan, but there’s enough contrast to make it work.

The rest of the site is even structured specifically to draw your eyes to the sides of the page at any time, so you can’t miss the bits you’re supposed to click on. Combine that with a solid modernist design aesthetic, and it all works rather well.

Platform: WordPress

Mynd

Mynd’s portfolio site is fairly standard layout-wise, and depends on the graphical talents of its creators to stand out, and stick in your head. Said graphics are simple, but visually striking enough to pull it off. To paraphrase Star Wars, it’s an older approach, but it checks out.

Platform: Static Site

Erudito

Random blobs of color used to be the domain of cheap flyers made for local businesses in the ’90s. But if you make those colors kind-of-pastel, use the blobs sparingly, and throw them on to a delicious yet solid foundation of simple type and layout, you get Erudito.

I haven’t been this excited about blobs of color since I was eight years old, or so.

Platform: Static Site

Moshin

Moshin makes use of the good-old grid-as-aesthetic-element trick, though you’re not going to see any actual lines outside of project preview images. However, those hints at simplicity and order sort of train the eye to see the same principles at work in the rest of the website, which I thought was a nice touch.

Platform: WordPress

Brand Affair

Is it just me, or are branding-focused studios usually the ones that really go all out with the fun stuff? Well Brand Affair is carrying on the tradition with their sunsets, their animals, and their clear and ever-present flair for the dramatic. I guess when your color palette is “all of the colors”, you truly have some room to get wild.

And yet, according to my browser, it’s not quite as bandwidth-heavy as you’d think. On top of everything else, I have to give them props for their optimization.

Platform: Static Site

Fully Studios

Fully Studios is another one that’ll throw the rainbow at you, but this time it comes with a healthy dose of illustration, and SVG animation. The rest of the site is a lovely mix of soft colors, retro-style UI elements, and a bit of monospaced type.

Platform: Static Site

Benjamin Guedj

Bringing us back from the edge of color-induced hypnosis, Benjamin Guedj’s portfolio is clean and pretty, with elegant-feeling type. The serif font chosen here can get a little hard to read at smaller sizes, but otherwise this is just a small, good-looking site that doesn’t do any more than it needs to.

Platform: Static Site

Series Eight

Series Eight: It’s simple. It’s somewhat monochromatic. It’s very “sans-serif”. Those are all compliments.

Platform: Static Site

Faculty

Faculty doesn’t quite look like a spreadsheet or database, but it kind of feels like it was inspired by one. All of the content gets its own column, and stays there across all pages. The overall effect is one of clear organization and goals, and I love it.

Platform: WordPress

Alex Firs

Alex Firs’ portfolio evokes a little bit of comic book flavor in its typography in with its modernism, and goes for a quite bold look. It’s all black, white, and solid reds.

One thing I’d like to note for other portfolio designers: the video backgrounds are only animated when you hover over the projects associated with them. This is a good way to focus a user’s attention, and save bandwidth. I’m just saying.

Platform: WordPress

Common Works

Common Works embraces some, well… common design patterns, but it is a beautiful site nonetheless. It made the list specifically because I am a sucker for Easter eggs, though. The animated QR code can be a bit tough to scan because of the animation, but it’s worth it.

Platform: Static Site

Bix Archer

Now Bix Archer’s portfolio does have a spreadsheet that serves as her main project archive, and a collage of modals to feature specific projects. As models of curation go, it’s a good setup for a one-page portfolio.

Platform: Static Site

Light and Shadows

Light and Shadows evokes an early 00’s idea of what a futuristic interface would look like, while still retaining a distinctly contemporary feel overall in its presentation-style UI. It comes complete with animated lines, text that “descrambles” itself, everything.

And yet, there’s no auto-playing audio. Good work, guys. You designed a site that excited my inner child without annoying the rest of me.

Platform: WordPress

Bison Studio

Bison Studio is a lovely-looking portfolio with solid type (except for a few instances where it could use more contrast), and that thing where almost every elements will, at some point, overlap onto another one. Plus, how many websites will put a buffalo chewing on something on their home page? How many?

Platform: JS App

Dragon Rouge

Dragon Rouge doesn’t hold back on the personality. Start scrolling through the site, and you’ll get hit with some pretty large images out of nowhere, and then there’s that mouse cursor.

Look, I’m usually not a fan of custom cursors, because half the time they’re just harder to see. This one is… not like that. Just give the link a click. You’ll see what I mean.

Platform: WordPress

Add Realistic Chalk and Sketch Lettering Effects with Sketch’it – only $5!

Source

p img {display:inline-block; margin-right:10px;}
.alignleft {float:left;}
p.showcase {clear:both;}
body#browserfriendly p, body#podcast p, div#emailbody p{margin:0;}

How to Fix Stocks App Error in iOS12 and macOS Mojave

Original Source: https://www.hongkiat.com/blog/how-to-fix-stocks-app-not-working-ios12-mojave/

A step-by-step guide on fixing the Stocks app error in iOS12 and macOS Mojave.

The post How to Fix Stocks App Error in iOS12 and macOS Mojave appeared first on Hongkiat.

Visit hongkiat.com for full content.

The Future of E-Commerce Platforms

Original Source: https://www.webdesignerdepot.com/2018/10/the-future-of-e-commerce-platforms/

The competition in the e-commerce market is fiercer than ever, as brands wrangle to outdo rivals by deploying the latest techniques and practices technology can offer. However, it’s hard to predict an industry-leader for a longer duration with the future of e-commerce constantly shifting.

This fast-paced evolution of e-commerce has not only expanded the digital footprint of online brands but also served as an impetus to accelerate the performance of shopping carts and increase revenues for online merchants.

Retailers aren’t the only ones affected. Platform developers are also facing the challenge of meeting the demands of multi-channel users. All these criteria along with the expectation of improved delivery times, customer service and greater product selection will define the future of e-commerce platforms.

1. Personalization & Customer Experience

E-commerce personalization and enhanced user experience will remain as the leading fundamentals of e-commerce. Customer purchase decisions will be influenced by a combination of showrooming and webrooming; product demos as well as the unique in-store experience being offered by retailers. Hence, e-commerce platforms will evolve continuously to offer the great versatility and depth-of-choice that comes with online shopping, along with the option of in-store purchasing, collection, or returns.

e-commerce platforms will evolve continuously to offer the great versatility and depth-of-choice

Creating a perfect profile of your customers is essential to fabricate a hyper-personalized shopping experience. For many years, retailers have relied on “online-to-offline,” or O2O business tactics that include online ads, coupons, and other enticements to nudge customers into the sales funnel. However, as consumers are growing more mindful, the O2O is slowly deteriorating and we’re starting to see what might be described as an “O2O 2.0” approach.

Walmart Inc. stores in China now allow shoppers to pay for their purchases via WeChat, a multi-purpose Chinese messaging, social media, and mobile payment application. Developed by Tencent, WeChat analyzes the data on consumers’ shopping habits and preferences to suggest shopping lists, coupons, and other items.

2. Integration of AI Systems

Rapidly changing and improving technology will define the next big step for the online-retail industry, which is the full automation of the processes across e-commerce platforms. AI systems integrated with e-commerce platforms can run algorithms to determine the optimum conditions for the sales procedure, highest converting design, etc. for every unique online shop. By using algorithms to effectively run tests, optimize settings and repeat the process on loop, retailers can maximize their web store capabilities and yield higher conversions.

It also anticipated that visual content will play a more important role in buying decisions. While internet giants like Google and eBay have already launched their own versions of visual search—which are still very much in their infancy—retailers like West Elm are also capitalizing on latest AI technologies to add similar functionality to their stores.

In future stores will allow shoppers to input their height, weight, complexion, favorite color etc, and then suggest clothing purchases based on those results.

Digital marketing and e-commerce gurus predict that e-commerce platforms will integrate artificial intelligence and machine learning technologies into the shopping experience. This will give retailers more control over the buying process by gathering and storing information about shoppers’ buying habits. In future stores will allow shoppers to input their height, weight, complexion, favorite color etc, and then suggest clothing purchases based on those results. Retailers could use augmented reality to allow customers try on clothes virtually and further suggest other clothing items like shoes or trousers to round out a complete outfit.

3. Measurement Across All Devices

Owing to the abundance of available devices, consumers are now actively engaging on multiple devices at once. This means that e-commerce platforms must create solutions that can help retailers to engage with customers on all fronts. Though a lot of e-commerce platforms like Magento and WooCommerce are already providing extensions that can easily create a native mobile app for your store; a seamless mobile checkout is still a challenge for many platforms.

M-commerce has already achieved the trillion dollar mark

M-commerce has already achieved the trillion dollar mark and will slowly overtake e-commerce in the near future. Moreover, updates from Google mean that the mobile version of your website will soon become a starting point for what Google includes in their index, and an important ranking factor. So in future, we anticipate e-commerce platforms will work on providing more innovative mobile-friendly solutions for retailers.

4. The Decline of Monolithic Platforms

Traditional e-commerce platforms are inflexible and do not support features for performing dedicated tasks. To further define the problem, the issues can be broken down into three broad categories:

The first issue is the wastage of resources, that comes with getting a powerful server to handle the load from seasonal shoppers, but which may otherwise remain dormant during the rest of the year.
Secondly, servers in a certain physical location may not be able to provide the performance and speed to customers in another country. This can be a major setback to efforts in converting global customers.
Lastly, by housing all required servers in one location, they become more vulnerable to online attacks, server crashes, and numerous other issues—especially if the servers lack a backup. It can lead to major complications and tarnish brand reputation as well as loss of income.

To enhance customer experience retailers need to incorporate all sorts of customer analytics into their offerings. The efficiency ratio of this procedure varies depending on the platform and presents its challenges.

Converting a monolithic web application into smaller and simpler services…increases your website’s efficiency and its ability to scale

Custom-built platforms can successfully address these issues, but it can be a daunting task requiring a big team of highly-experienced developers working on the development and continuous optimization. Converting a monolithic web application into smaller and simpler services not only increases your website’s efficiency and its ability to scale, but will also allow you to react more quickly to change.

Back in 2011, Best Buy broke down its monolithic website into separate web services. This immediately benefited both the company and its customers. (However; this can be an expensive option for small retailers, who more than likely will not be able to rationalize these costs.)

5. Using Hyperscale Computing

Hyperscale is not only cost-effective and provides more space for innovation, but it allows retailers to explore different solutions for individual services. Moreover, retailers will have more freedom in managing the expenses and will be freed from the need of making a permanent commitment. Retailers will be able to focus on development in areas that highlight their strengths and attract customers in a highly competitive market.

There is no debate that cloud computing has helped e-commerce entrepreneurs to save both time and resources. It has opened the world to consumers and online retailers. Walmart has spent more than five years and millions of dollars just to built its own internal cloud network; this clearly indicates their determination to grab a bigger slice of online shopping and is an inspiration for all online retailers to quickly move to cloud computing not only to increase their sales but to improve their in-store operations as well.

What the Future Holds

New technologies and the latest products are increasingly changing the manner in which most consumers shop online. Innovative devices, such as Google Home, are decreasing the number of steps required for completing a purchase. Consumers can create a wish list using Google Home and directly place their orders without even launching a web browser or other apps.

the most elaborate solution may not necessarily be the most effective

Social media channels have also become a big part of the online retail process. They have proven effective means of advertising products according to demographics and specific customer behavior. More importantly, customers can use the social media channels to gain direct access to the e-commerce platform. The future of these integration tools seems to suggest that soon customers may even be able to purchase by simply selecting a product image displayed on a social media channel.

While the complexities of e-commerce continue to increase, retailers are starting to learn the most elaborate solution may not necessarily be the most effective.

Reducing the e-commerce platform into manageable sections and utilizing consumer data to better develop functions to address specific customer behavior are approaches which will set retailers on the track to prepare for the near future of e-commerce.

 

Featured image via DepositPhotos.

Add Realistic Chalk and Sketch Lettering Effects with Sketch’it – only $5!

Source

p img {display:inline-block; margin-right:10px;}
.alignleft {float:left;}
p.showcase {clear:both;}
body#browserfriendly p, body#podcast p, div#emailbody p{margin:0;}

Adobe MAX 2018: news, launches and all the action from the creative conference

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/Vw378P2AU1w/adobe-max

Adobe MAX 2018 is nearly here. At this annual gathering of over 12,000 graphic, web and multi-disciplinary designers, art directors, film, video and motion graphics pros and photographers, inspiration is very much the name of the game.

Leading creative conference Adobe MAX offers over 300 sessions, labs and creativity workshops taught by industry leaders to help ignite your imagination and grow your career. This is a place where you can learn about industry trends, see new products and technology in action and kickstart your creativity all under one roof. 

When and where is Adobe Max 2018?

This year's Adobe MAX is being held at the Los Angeles Convention Centre from the 15-17 October. If you can make it, we'll see you in (hopefully) sunny LA. But if you're not able to get to the Southern California city, never fear, you can still join in the action via Adobe's live stream. 

And action aplenty is pretty much guaranteed. Adobe always pulls out all the stops for its annual conference, and Adobe MAX 2018 is no exception. Among the keynote speakers you'll find legendary producer and director Ron Howard, DJ and musician Questlove, comic book artist Nicola Scott, YouTuber Lilly Singh, and photographer Albert Watson. 

Adobe MAX attendees will also be invited to witness all the latest and greatest updates to Adobe's Creative Cloud suite, as well as learn some techniques to create amazing content. The learning sessions range from lectures to hands-on demonstrations in everything from photography and videography to prototyping and character design – there really is something for everyone! 

What we already know about Adobe Max 2018

sneaks Adobe Max 2017

Last year’s Sneaks session revealed a number of new innovations, and this year is sure to be no different

For the past few weeks, Adobe has teased with a number of sneak previews of the updates made to some of its most popular creative apps. These included details of a supercharged Content-Aware Fill tool in Photoshop and an exciting new toolbar feature in Illustrator. 

These are no doubt the tip of the iceberg, with Adobe sure to wow audiences at Adobe MAX 2018 with even more handy new features and updates to help creatives realise their full artistic potential. While we currently don't know what these might be, we're super-excited to be reporting live from the event, so stay tuned for all the top Adobe MAX news. Don't forget to follow us on Twitter, Facebook and Instagram for the latest updates, and keep checking this page for all the latest news. 

Read more:

7 insane tech sneaks from Adobe MAXAdobe XD and Adobe Dimension launched at Adobe MAXHow to use Adobe Capture CC

CSS Debugging and Optimization: Code-quality Tools

Original Source: https://www.sitepoint.com/css-debugging-and-optimization-code-quality-tools/

The following introduction to CSS code-quality tools is an extract from Tiffany’s upcoming book, CSS Master, 2nd Edition, which will be available shortly.

On your road to becoming a CSS master, you’ll need to know how to troubleshoot and optimize your CSS. How do you diagnose and fix rendering problems? How do you ensure that your CSS creates no performance lags for end users? And how do you ensure code quality?

Knowing which tools to use will help you ensure that your front end works well.

In this article, we’ll discuss tools that help you analyze the quality of your CSS. We’ll focus on two:

stylelint
UnCSS

stylelint is a linting tool. A linter is an application that checks code for potential trouble spots, enforcing coding conventions such as spaces instead of tabs for indentation. stylelint can find problems such as duplicate selectors, invalid rules, or unnecessary specificity. These have the greatest impact on CSS maintainability.

UnCSS, on the other hand, checks your CSS for unused selectors and style rules. It parses a stylesheet and a list of HTML pages, returning a CSS file that’s stripped of unused rules.

Both of these tools use Node.js and can be installed using npm.

If you’re working on a small site, such as a personal blog or a few pages that are updated infrequently, many of the problems that these tools flag can safely be ignored. You’ll spend time refactoring for little gain in maintainability and speed. For larger projects, however, they’re invaluable. They’ll help you head off maintainability problems before they start.

stylelint

stylelint helps you avoid errors and enforce conventions in your styles. It has more than 160 error-catching rules and allows you to create your own as well via plugins.

stylelint Installation and Configuration

Install stylelint as you would any other npm package:

npm install -g stylelint

Once it’s installed, we’ll need to configure stylelint before using it. stylelint doesn’t ship with a default configuration file. Instead, we need to create one. Create a .stylelistrc file in your project directory. This file will contain our configuration rules, which can use JSON (JavaScript Object Notation) or YAML (YAML Ain’t Markup Language) syntax. Examples in this section use JSON.

Our .stylelistrc file must contain an object that has a rules property. The value of rules will itself be an object containing a set of stylelist rules and their values:

{
“rules”: {}
}

If, for example, we wanted to banish !important from declarations, we can set the declaration-no-important to true:

{
“rules”: {
“declaration-no-important”: true
}
}

stylelint supports over 150 rules that check for syntax errors, indentation and line-break consistency, invalid rules, and selector specificity. You’ll find a complete list of rules and their available values in the stylelint User Guide.

Starting with a Base stylelint Configuration

You’ll probably find it easier to start with a base configuration and then customize it to your project needs. The stylelint-config-recommended base configuration is a good starting configuration. It enables all of the “possible errors” rules. Install it using npm:

npm install -g stylelint-config-recommended

Then, in your project directory, create a .stylelistrc file that contains the following lines:

{
“extends”: “/absolute/path/to/stylelint-config-recommended”
}

Replace /absolute/path/to/ with the directory to which stylelint-config-recommended was installed. Global npm packages can usually be found in the %AppData%npmnode_modules directory on Windows 10 systems, and in /usr/local/lib/node_modules on Unix/Linux and macOS systems. Type npm list -g to locate your global node_modules directory.

We can then augment our configuration by adding a rules property. For example, to disallow vendor prefixes, our .stylelistrc file would look similar to the what’s below:

{
“extends”: “/absolute/path/to/stylelint-config-recommended”,
“rules”: {
“value-no-vendor-prefix”: true
}
}

What if we wanted to limit the maximum specificity of our selectors to 0,2,0? That would permit selectors such as .sidebar .title but not #footer_nav. We can do this by adding a selector-max-specificity rule to our configuration:

{
“extends”: “/absolute/path/to/stylelint-config-recommended”,
“rules”: {
“value-no-vendor-prefix”: true,
“selector-max-specificity”: “0,2,0”
}
}

The post CSS Debugging and Optimization: Code-quality Tools appeared first on SitePoint.

10+ Social Media Tools To Help You Publish At The Right Time

Original Source: https://www.hongkiat.com/blog/when-post-social-media/

A list of useful tools to manage social networks by scheduling posts and analyzing performances etc.

The post 10+ Social Media Tools To Help You Publish At The Right Time appeared first on Hongkiat.

Visit hongkiat.com for full content.

Can this font improve your memory?

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/RBwS7SfLz1w/can-this-font-improve-your-memory

Ever read a passage of text only to realise that you didn't take it in? It's a problem that affects a lot of readers, especially students cramming in exam season. To give text more traction and make it easier to remember, Melbourne-based researchers at RMIT University have created a fun font that makes reading harder.

The appropriately named Sans Forgetica does this by taking advantage of "desirable difficulty". This line of thought argues that a small obstruction aids the learning process by forcing a person to create a memory trace.

To make reading legible but also difficult, the Sans Forgetica typeface has been riddled with gaps and given a seven degree back slant. The result is a jarring font that requires an extra bit of effort on the reader's part. It only takes a fraction of a second longer to read, but Sans Forgetica already appears to be making a difference.

Stephen Banham sitting at a desk with samples of Sans Forgetica

Sans Forgetica co-creator Stephen Banham advises you read the typeface in small bursts

As part of a study by the university, students noticed a small increase in memory retention when reading text in Sans Forgetica compared to Arial. The 400 participants were found to remember 57 per cent of Sans Fogetica text, and only 50 per cent when reading Arial. 

Despite the promising statistics, Sans Forgetica has limitations. Typography lecturer and Sans Forgetica co-creator Stephen Banham told The Guardian that the typeface is best suited to short passages. "You wouldn’t want novels printed in it, it would probably induce a headache."

Sans Forgetica took six months to develop and went through three different iterations. With a promising study behind it, it's hoped that the typeface could also be used to aid proofreading. You can download this free font here.

Related articles:

Take a look at the world's most rubbish fontFamous logos redesigned as fontsHow to use web fonts

Build a Simple API Service with Express and GraphQL

Original Source: https://www.sitepoint.com/build-a-simple-api-service-with-express-and-graphql/

This article was originally published on the Okta developer blog. Thank you for supporting the partners who make SitePoint possible.

GraphQL has become an immensely popular alternative to REST APIs. The flexibility you get from using GraphQL makes it easier for developers to get any information they need for an app, and just the information they need for that portion of the app. That gives you the feel of a very customized API and can help cut down on bandwidth.

In this tutorial, I’ll show you how to write a custom GraphQL API using Node and Express. I’ll also show you how to secure parts of the API while making other parts open to the public.

Create the GraphQL API with Express

To create the API, start by creating a new folder and creating a package.json file to manage your dependencies. You’ll also need to install a few dependencies to get GraphQL with Express up and running:

mkdir graphql-express
cd graphql-express
npm init -y
npm install express@2.8.4 express-graphql@0.6.12 graphql@14.0.2 graphql-tag@2.9.2 cors@2.8.4

Now create a file named index.js. This will be your main entry point:

const express = require(‘express’)
const cors = require(‘cors’)
const graphqlHTTP = require(‘express-graphql’)
const gql = require(‘graphql-tag’)
const { buildASTSchema } = require(‘graphql’)

const app = express()
app.use(cors())

const schema = buildASTSchema(gql`
type Query {
hello: String
}
`)

const rootValue = {
hello: () => ‘Hello, world’
}

app.use(‘/graphql’, graphqlHTTP({ schema, rootValue }))

const port = process.env.PORT || 4000
app.listen(port)
console.log(`Running a GraphQL API server at localhost:${port}/graphql`)

This is about as simple as a GraphQL server gets. All this does is return “Hello, world” when you query “hello”, but it’s a start. To take it for a test spin, run node ., then in another tab open your browser to the GraphQL Playground. Once there, enter http://localhost:4000/graphql to access your GraphQL server.

graphql playground - enter endpoint url

The GraphQL Playground will help explore your schema and test out queries. It even automatically creates some documentation for you.

graphql playground - hello world schema

Try querying for hello using the following query:

query {
hello
}

hello world

Improve Your GraphQL Developer Experience

Here are a couple quick tips to help make your development experience a little better:

1. Install a linter to help catch bugs in your editor. This will help keep your styling consistent and catch any easily-avoidable bugs.

To install StandardJS, type npm install –save-dev standard@12.0.1. Most editors will be able to show you warnings and errors as you type.

You can also edit the scripts object of your package.json so that you can run the linter at any time with npm test:

“scripts”: {
“test”: “standard”
},

2. Automatically restart the server when you make changes.

Install nodemon with npm install –save-dev nodemon@1.18.4.

Add another script to package.json, so you can run the server with npm start. Combined with the above, your scripts object should look like this:

“scripts”: {
“test”: “standard”,
“start”: “nodemon .”
},

Go ahead and close the server you had run with node . and now type npm start to restart the development server. From now on, any changes you make will automatically restart the server.

Create the GraphQL Queries

To get something a little more useful, let’s make a post editor. GraphQL is strongly typed, allowing you to create a type for each object and connect them. A common scenario might be to have a post with some text, that was written by a person. Update your schema to include these types. You can also update your Query type to utilize these new types.

type Query {
posts: [Post]
post(id: ID): Post
authors: [Person]
author(id: ID): Person
}

type Post {
id: ID
author: Person
body: String
}

type Person {
id: ID
posts: [Post]
firstName: String
lastName: String
}

Even though the resolvers aren’t set up, you can already go back to GraphQL Playground and refresh the schema by clicking the circular arrow icon next to the localhost URL.

url and refresh button

The schema explorer is really useful for figuring out how to create your query. Click the green SCHEMA button to check out your new schema.

full query schema

You’ll need some way to store the data. To keep it simple, use JavaScript’s Map object for in-memory storage. You can also create some classes that will help connect the data from one object to another.

const PEOPLE = new Map()
const POSTS = new Map()

class Post {
constructor (data) { Object.assign(this, data) }
get author () {
return PEOPLE.get(this.authorId)
}
}

class Person {
constructor (data) { Object.assign(this, data) }
get posts () {
return […POSTS.values()].filter(post => post.authorId === this.id)
}
}

Now if you have an instance of a Person, you can find all of their posts by simply asking for person.posts. Since GraphQL lets you only ask for the data you want, the posts getter will never get called unless you ask for it, which could speed up the query if that’s an expensive operation.

You’ll also need to update your resolvers (the functions in rootValue) in order to accommodate these new types.

const rootValue = {
posts: () => POSTS.values(),
post: ({ id }) => POSTS.get(id),
authors: () => PEOPLE.values(),
author: ({ id }) => PEOPLE.get(id)
}

This is great, but there’s no data yet. For now, stub in some fake data. You can add this function and the call to it right after the assignment to rootValue.

const initializeData = () => {
const fakePeople = [
{ id: ‘1’, firstName: ‘John’, lastName: ‘Doe’ },
{ id: ‘2’, firstName: ‘Jane’, lastName: ‘Doe’ }
]

fakePeople.forEach(person => PEOPLE.set(person.id, new Person(person)))

const fakePosts = [
{ id: ‘1’, authorId: ‘1’, body: ‘Hello world’ },
{ id: ‘2’, authorId: ‘2’, body: ‘Hi, planet!’ }
]

fakePosts.forEach(post => POSTS.set(post.id, new Post(post)))
}

initializeData()

Now that you have your queries all set up and some data stubbed in, go back to GraphQL Playground and play around a bit. Try getting all the posts, or get all the authors and posts associated with each one.

query all posts

Or get weird and get a single post by id, then the author for that post, and all of that author’s posts (including the one you just queried).

get weird

Add User Authentication to Your Express + GraphQL API

One simple way to add authentication to your project is with Okta. Okta is a cloud service that allows developers to create, edit, and securely store user accounts and user account data, and connect them with one or multiple applications. If you don’t already have one, sign up for a forever-free developer account.

You’re going to need to save some information to use in the app. Create a new file named .env. In it, enter in your organization URL.

HOST_URL=http://localhost:4000
OKTA_ORG_URL=https://{yourOktaOrgUrl}

You will also need a random string to use as an App Secret for sessions. You can generate this with the following command:

echo “APP_SECRET=`openssl rand -base64 32`” >> .env

Next, log in to your developer console, navigate to Applications, then click Add Application. Select Web, then click Next.

create new application settings

The page you come to after creating an application has some more information you need to save to your .env file. Copy in the client ID and client secret.

OKTA_CLIENT_ID={yourClientId}
OKTA_CLIENT_SECRET={yourClientSecret}

The last piece of information you need from Okta is an API token. In your developer console, navigate to API -> Tokens, then click on Create Token. You can have many tokens, so just give this one a name that reminds you what it’s for, like “GraphQL Express”. You’ll be given a token that you can only see right now. If you lose the token, you’ll have to create another one. Add this to .env also.

OKTA_TOKEN={yourOktaAPIToken}

Create a new file named okta.js. This is where you’ll create some utility functions, as well as get the app initialized for Okta. When authenticated through Okta, your app will authenticate through an access token using JWT. You can use this to determine who a user is. To avoid dealing directly with authentication in your app, a user would sign in on Okta’s servers, then send you a JWT that you can verify.

okta.js

const session = require(‘express-session’)

const OktaJwtVerifier = require(‘@okta/jwt-verifier’)
const verifier = new OktaJwtVerifier({
clientId: process.env.OKTA_CLIENT_ID,
issuer: `${process.env.OKTA_ORG_URL}/oauth2/default`
})

const { Client } = require(‘@okta/okta-sdk-nodejs’)
const client = new Client({
orgUrl: process.env.OKTA_ORG_URL,
token: process.env.OKTA_TOKEN
})

const { ExpressOIDC } = require(‘@okta/oidc-middleware’)
const oidc = new ExpressOIDC({
issuer: `${process.env.OKTA_ORG_URL}/oauth2/default`,
client_id: process.env.OKTA_CLIENT_ID,
client_secret: process.env.OKTA_CLIENT_SECRET,
redirect_uri: `${process.env.HOST_URL}/authorization-code/callback`,
scope: ‘openid profile’
})

const initializeApp = (app) => {
app.use(session({
secret: process.env.APP_SECRET,
resave: true,
saveUninitialized: false
}))
app.use(oidc.router)
app.use(‘/access-token’, oidc.ensureAuthenticated(), async (req, res, next) => {
res.send(req.userContext.tokens.access_token)
})
}

module.exports = { client, verifier, initializeApp }

The initializeApp function adds some middleware to allow you to log in with Okta. Whenever you go to the http://localhost:4000/access-token, it will first check that you’re logged in. If you aren’t, it will first send you to Okta’s servers to authenticate. Once authentication is successful, it returns you to the /access-token route and will print out your current access token, which will be valid for about an hour.

The client that you’re exporting allows you to run some administrative calls on your server. You’ll be using it later to get more information about a user based on their ID.

the verifier is what you use to verify that a JWT is valid, and it gives you some basic information about a user, like their user ID and email address.

Now, in index.js, you’ll need to import this file and call the initializeApp function. You also need to use a tool called dotenv that will read your .env file and add the variables to process.env. At the very top of the file, add the following line:

require(‘dotenv’).config({ path: ‘.env’ })

Just after the app.use(cors()) line, add the following:

const okta = require(‘./okta’)
okta.initializeApp(app)

To make this all work, you’ll also need to install a few new dependencies:

npm i @okta/jwt-verifier@0.0.12 @okta/oidc-middleware@1.0.0 @okta/oidc-sdk-nodejs@1.2.0 dotenv@6.0.0 express-session@1.15.6

You should now be able to go to http://localhost:4000/access-token to log in and get an access token. If you were just at your developer console, you’ll probably find you’re already logged in. You can log out of your developer console to ensure the flow works properly.

Create GraphQL Mutations

Now it’s time to use real data. There may be some real John and Jane Does out there, but chances are they don’t have an account on your application yet. Next, I’ll show you how to add some mutations that will use your current user to create, edit, or delete a post.

To generate IDs for a post, you can use uuid. Install it with npm install uuid@3.3.2, then add it to index.js with:

const uuid = require(‘uuid/v4’)

That should go near the top of the file, next to the other require statements.

While still in index.js, add the following types to your schema:

The post Build a Simple API Service with Express and GraphQL appeared first on SitePoint.