Wednesday, October 9, 2019

Instagram Takes Steps to Protect Users from Phishing

There are a lot of scams out there, so much so that the internet resembles the old west in a lot of ways in that it is an often lawless place that can end up costing the unsuspecting passers by a lot of money that they would lose simply because of the fact that they were not aware of what would...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Zia Zaidi via Digital Information World

Apple CEO Tim Cook Criticized Facebook on Introducing A New Digital Currency

In a recent interview, Tim Cook took a not-so-subtle shot on Facebook by criticizing the social media giant on their new venture to introduce cryptocurrency. For those who are not aware, Facebook is the first company that is involved in introducing their new digital currency but many others are...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Madiha via Digital Information World

Getting Started with GraphQL and React Native

In 2012, Facebook engineer Nick Schrock started work on a small prototype to facilitate moving away from an old, unsupported partner API that powered the current Facebook News Feed. At the time, this was called “SuperGraph”. Fast forward to today and SuperGraph has helped shape the open-source query language GraphQL, which has been much of the buzzword in recent times.

Facebook describes GraphQL as a “query language for APIs and a runtime for fulfilling those queries with your existing data”. Put simply, GraphQL is an alternative to REST that has been steadily gaining popularity since its release. Whereas with REST a developer would usually collate data from a series of endpoint requests, GraphQL allows the developer to send a single query to the server that describes the exact data requirement.

Prerequisites

For this tutorial, you’ll need a basic knowledge of React Native and some familiarity with the Expo environment. You’ll also need the Expo client installed on your mobile device or a compatible simulator installed on your computer. Instructions on how to do this can be found here.

Project Overview

In this tutorial, we’re going to demostrate the power of GraphQL in a React Native setting by creating a simple coffee bean comparison app. So that you can focus on all of the great things GraphQL has to offer, I’ve put together the base template for the application using Expo.

A mockup of our coffee comparison app

To get started, you can clone this repo and navigate to the “getting-started” branch, which includes all of our basic views to start adding our GraphQL data to, as well as all of our initial dependencies, which at this stage are:

{
    "expo": "^32.0.0",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
    "react-navigation": "^3.6.1"
}

To clone this branch, you’ll need to open up terminal and run this command:

git clone https://github.com/jamiemaison/graphql-coffee-comparison.git

To then navigate to the getting-started branch, you move into the newly cloned repo with cd graphql-coffee-comparison and run git checkout getting-started.

The next stage is to install our dependencies. To do this, make sure you’re on Node v11.10.1 and run npm install in the root directory of the project. This will add all of the dependencies listed above to your node_modules folder.

To start adding GraphQL to our React Native app, we’re going to need to install a few more dependencies that help us perform a few simple GraphQL functions. As is common with modern JavaScript development, you don’t need all of these dependencies to complete the data request, but they certainly help in giving the developer a better chance of structuring some clean, easy-to-read code. The dependencies you’ll need can be installed by running npm install --save apollo-boost react-apollo graphql-tag graphql.

Here’s an overview of what these dependencies are:

  • apollo-boost: a zero-configuration way of getting started with GraphQL in React/React Native
  • react-apollo: this provides an integration between GraphQL and the Apollo client
  • graphql-tag: a template literal tag that parses GraphQL queries
  • graphql: the JavaScript reference implementation for GraphQL

Once all of the necessary dependencies have finished installing, run npm start. You should now see your familiar Expo window, and if you launch the app (either via a simulator or on a device) then you should see a screen similar to this:

A mockup of our getting started page

In basic terms, this application has two screens that are managed by react-navigation, Home.js and CoffeePage.js. The Home screen contains a simple FlatList that renders all of the coffee beans supplied to its data field. When clicked on, the user is navigated to the CoffeePage for that item, which displays more information about the product. It’s our job to now populate these views with interesting data from GraphQL.

The complete coffee page

Apollo Server Playground

There are two main elements to any successful GraphQL transaction: the server holding the data, and the front-end query making the request. For the purposes of this tutorial, we aren’t going to start delving into the wonderful world of server-side code, so I’ve created our server for us ready to go. All you need to do is navigate to yq42lj36m9.sse.codesandbox.io in your favorite browser and leave it running throughout the course of development. For those interested, the server itself is running using apollo-server and contains just enough code to hold the data we need and serve it upon receiving an appropriate query. For further reading, you can head over to apollographql.com to read more about apollo-server.

GraphQL Query Basics

Before we get into writing the actual code that’s going to request the data we need for our coffee bean comparison app, we should understand just how GraphQL queries work. If you already know how queries work or just want to get started with coding, you can skip ahead to the next section.

Note: these queries won’t work with our codesandbox server, but feel free to create your own at codesandbox.io if you’d like to test out the queries.

At its simplest level, we can use a flat structure for our queries when we know the shape of the data we’re requesting:

QUERY:                                RESPONSE:
{                                     {
  coffee {                              "coffee": {
    blend                                 "blend": "rich"
  }                                     }
}                                     }

On the left, we see the GraphQL query requesting the blend field from coffee. This works well when we know exactly what our data structure is, but what about when things are less transparent? In this example, blend returns us a string, but queries can be used to request objects as well:

QUERY:                                RESPONSE:
{                                     {
  coffee {                              "coffee": {
    beans {                               "beans": [
        blend                               {
    }                                         blend: "rich"
  }                                         },
}                                           {
                                              blend: "smooth"
                                            }
                                          ]
                                        }
                                      }

Here you can see we are simply requesting the beans object, with only the field blend being returned from that object. Each object in the beans array may very well contain other data other than blend, but GraphQL queries help us request only the data we need, cutting out any extra information that’s not necessary for our application.

So what about when we need to be more specific than this? GraphQL provides the capability for many things, but something that allows for extremely powerful data requests is the ability to pass arguments in your query. Take the following example:

QUERY:                                RESPONSE:
{                                     {
  coffee(companyId: "2") {              "coffee": {
    beans {                               "beans": [
        blend                               {
    }                                         blend: "rich"
  }                                         },
}                                           {
                                              blend: "smooth"
                                            }
                                          ]
                                        }
                                      }

What we see is that we can pass an argument — in this case, the companyId — which ensures that we are only returned beans from one particular company. With REST, you can pass a single set of arguments via query params and URL segments, but with GraphQL querying every single field, it can get its own set of arguments. This allows GraphQL to be a dynamic solution for making multiple API fetches per request.

The post Getting Started with GraphQL and React Native appeared first on SitePoint.


by Jamie Maison via SitePoint

Facebook's Mark Zuckerberg nodded with Sanders that Billionaires should not exist, capitalists and socialists handshake!

Capitalists and Socialists come on one plane! CEO of Facebook. Inc, Mark Zuckerberg, agreed with the statement of Baernie Sanders, candidate of presidential elections, that billionaires should not exist. In an internal Questions and Answers session, last week, one of the employee asked him to...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by aqsqa qadir via Digital Information World

Google Chrome’s Tab Groups Feature Gets an Update

A significant part of Google’s attempts to improve its Chrome web browser as of late has involved tidying up the manner in which tabs are displayed. This is because of the fact that a common complaint among people that use Chrome on a regular basis has to do with the cluttered look that tabs often...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Zia Zaidi via Digital Information World

Build a Tabbed Product Archive for Your WooCommerce Store

In this tutorial you will learn how to make your WooCommerce store a little more stylish by organizing the product archive with tabs. We’ll create tabs with a multi-column layout, a multi-row carousel, and a grid layout.

What We’re Going to Build

Over the coming steps we will create a WordPress plugin, inside which we will setup the required shortcodes. Should you wish to take your WooCommerce product archive further, you could convert it to a Gutenberg block, use it with Elementor as a widget, or integrate it with Visual Composer.

This tabbed product archive will be perfect for showing recent, featured, sale, and best selling products, like this:

tabbed product archive in woocommerce
Our product archive, showing tabs and carousel controls

So let’s get started!

1. Create a WordPress Plugin

In your WordPress site under wp-content/plugins create a folder called (perhaps not the most original name) “woocommerce-products”, then inside that folder create a php file with the same name. Open the file and paste into it the code below (change the details to fit your own):

Here we’ve done nothing more than define our plugin name and provided some meta info.

Enqueue Scripts and Styles

For our WooCommerce product archive plugin we will next need to enqueue the required scripts and styles, so add the following code snippet:

First, we’ve added a basic CSS file to store our styles. Next we loaded the built-in imageLoaded plugin (which comes with the WordPress core), and to create the carousel we will use the wildly popular jQuery plugin owlCarousel. And, of course, the main js file. 

Note: Make sure these files are added to your plugin folder in the relevant subfolders. 

For more on WordPress plugin and shortcode creation, or further information on using owl.js, here are some recommended tutorials on Tuts+:

2. Create a Tab Shortcode

In this step we will create a tab shortcode. It will consist of two shortcodes actually; the parent tab container, and then child tab items. For the first parent container add this code to the PHP file:

This shortcode doesn’t require any attributes, it just wraps the tab items inside it.

Speaking of tab items, next add the code below to create the child tab item element:

This shortcode has two attributes; the title and the active indicator, in case you want to make the targeted tab active on first load. 

When used in the WordPress editor the two shortcodes together will look like this:

At this point, if you were to add them to your front-page, then view the result in your browser, you would see unstyled and non-functional HTML output. So let’s fix it. 

3. Add jQuery to Power the Tabbed Content

Go to the main.js file and paste the code

I won’t describe all this code in great detail, but the logic here powers the tab functionality. If you are not familiar with JavaScript or jQuery, I highly recommend this amazing free course for beginners:

Style the Tabs

Now the tabs work, but they still appear ugly, so let’s add some basic CSS:

4. Create WooCommerce Products Shortcode

We’re making great progress; our tabbed WooCommerce product archive is nearly there! The time has come to create a shortcode for the products. This will fetch the products with a query, then from those results create a series of arrays: featured, sale, and best-selling products. It will then output the contents of those arrays to give us our tabs of products.

Add this code to the PHP file:

The shortcode we’ve created here has several attributes:

  • Layout – this can be grid or carousel
  • Autoplaytrue or false, this is an additional option for the carousel layout
  • Columns – here you can specify how many columns you want
  • Rows – this is the same as columns, and only applies to the carousel layout
  • Quantity – the number of items to display
  • Type – here you can specify recent products, best sellers, sale, or featured products

A Note on Our Carousel Rows

When you have a carousel, each product becomes a carousel item–normal behavior when you have one row. However, what happens if you want two, three, or four rows per carousel item? 

In this case you would need to wrap each of these possibilities inside a wrapper that would act as the carousel item. And you have the question: do you do this with JavaScript or with PHP? I prefer the second option, as JS has some delay on execution. So if you examine the shortcode you will find the following:

Note the

right after the

This is very similar to a for loop, we need an increment to loop through our query and wrap each two, each three, and each four product items inside the carousel item wrapper markup.

You’ll notice the %, which is the modulo operator. It gives the remainder of a division; 0 when the number is exactly divisible by 2/3/4, and 1 when not. And with each loop we will need to increment the counter with:

This happens right after the code:

5. Add Owl Styles 🦉

We’re almost ready, but first let’s add some owl carousel styles and some additional styling to our products. 

Open the style.css file and paste the owl carousel styles (you should find these in your owlCarousel plugin download .zip file). And some additional style for carousel navigation and our products:

But wait a minute, we haven’t yet called the carousel plugin, so let’s now go to the main.js file, and right after the tab code add the following:

Here we use two plugins at the same time: first we make sure that our images are loaded to avoid any kind of content overlapping, and then we call the plugin for our carousel products layout.

6. Fix Carousel Glitch

One thing remains to be done: if you now go to the tabs and state that you want a carousel based layout you will see it working on the active tab for the first page load, but if you start switching from tab to tab your carousel layout will break. On the tab change event our carousel needs to updated. So at the very beginning of the file add the function:

This function refreshes the carousel layout each time the tab is changed. And now inside tab function right after the code:

call the function:

Now, clear the browser cache and add the following shortcode content to your page:

In this case I am using the default WordPress theme with Gutenberg editor (hence the Gutenberg comments <!-- wp:separator -->), if you have the classic editor, just copy the shortcodes.

And now if you have done everything right you will see a beautiful layout like this!

Conclusion

You are free to use and modify this plugin in your projects, both commercial and non-commercial. Visit the repo on Github to grab the source code in full. I hope you find it useful, thanks for reading!

Best WooCommerce Themes on Envato Market


by Karen Pogosyan via Envato Tuts+ Code

A web accessibility win following Supreme Court decision

#412 — October 9, 2019

Read on the Web

Frontend Focus

Supreme Court Hands Victory to Blind Man Who Sued Domino's Over Site AccessibilityBack in August we shared news that pizza company Domino’s was requesting for a lawsuit, requiring its website to be accessible to blind people, to be shut down. The Supreme Court has now denied that petition — a significant win for disability advocates.

Tucker Higgins

ASPIRE: Ideals to Aspire to When Building Websites — In relation to the item above, here Scott makes the case that sites should aspire to be Accessible, Secure, Performant, Inclusive, Responsive and Ethical.

Scott Jehl

A Technical Deep Dive into FeathersJS — FeathersJS is easy to integrate, data agnostic, and highly customizable. Is it the holy grail of frameworks for realtime apps and APIs? This article puts Feathers through its paces and answers the question: when is FeathersJS too lightweight?

Ably sponsor

The Evolution of Web Content Management — A look at the evolution of web content management from the early days of the web to the headless, cloud-based CMS systems of today.

Brian Rinaldi

How to Read A Web Page Test Waterfall Chart — If like me, you often look at a waterfall chart and get a bit lost as to what it all means, you’ll find this to be a handy reference, explaining it all in very accessible way.

Matt Hobbs

💻 Jobs

React JS Developer (Remote) — We’re looking for an ambitious React developer to help us make komoot the place to go to plan outdoor adventures.

KOMOOT

Mobile App Developer Wanted for High-Growth Fundraising Platform — This company has a big vision, and everyone embraces it, not because it’s a weird cult or something, but only because it’s ethical and cool.

CareersJS

Find A Job Through Vettery — Vettery specializes in tech roles and is completely free for job seekers. Create a profile to get started.

Vettery

📙 Articles, Tutorials & Opinion

Avoid 100vh On Mobile Web — If you’re using viewport units in CSS to style an element to take up the full screen height (using height: 100vh), you may want to reconsider. David recommends an alternative approach using JavaScript.

David Chanin

An Interview with an 'Adult Site' Developer — Now this won’t be for everyone, but regardless of your stance, this is an interesting look into the decisions behind the tech choices and how they all work at one of the web’s largest adult sites.

David Walsh

Clipping, Clipping, and More Clipping! — An exploration of how the CSS clip-path property can be used to create interesting effects.

Mikael Ainalem

The React Hooks Guide: In-Depth Tutorial with Examples. Start Learning — Learn all about React Hooks as we comprehensively cover: State and Effects, Context, Reducers, and Custom React Hooks.

Progress KendoReact sponsor

Retro Nostalgia & Why My New Website Looks Like Windows 98 — This developer was feeling “particularly nostalgic for the days of Geocities and floppy disks” so created a new (and well-realised) Windows 98-style personal site paying homage to such an ‘idealized past’. Here’s the UI library behind it.

Ash Kyd

Verify Phone Numbers On The Web with The SMS Receiver API — It’s still early days for this API, but here’s an initial look at how the planned SMS Receiver API will work.

Eiji Kitamura

How to Build a Progressive Web App (PWA) with only Vanilla JS — Bring a native-like experience to your webapps with this grab bag of techniques including styling, fonts, Service Workers, and creating a manifest file.

Sayan Mondal

▶  Accessibility in Web Standards and Its Future in Software. Listen Now

Heroku sponsorpodcast

Spacing, Grids and Layouts: Creating a Spatial System — How to define baseline grids, column grids, spacing and layouts.

Elliot Dahl

Trying to Make Sense of Gmail CSS Support — As an email publisher this sort of knowledge can prove invaluable…

Rémi Parmentier

💡 Tip of the Week

supported by

Defining quotation styles with the <q> tag

When styling your site you may be happy with the "default, straight quotation style", but if you're keen on getting your typography just right then there is a way to ensure your quotation marks are “smart” via CSS.

As explained here, the HTML <q> element signals that the contained text is a short inline quotation. Most browsers implement this by surrounding the text in "quotation marks". You can, however, add a style to modify what automatically appears around the text:

q {
 quotes: "“" "”";
}

It may be hard to make out in email, but this rule will wrap your inline quote with alternative 'smart' quotation marks. This blog post expands on how this simple tip can be used for multilingual sites, such as using differing quotation rules for different languages (like German).

Another idea is outlined in this recent blog post from Michael Lazarski, who shows how this technique can even be used with emoji for an 🙌 altogether different 🙌 approach.

This Tip of the Week is sponsored by Flatiron School, where you can learn software engineering, data science, or UX/UI design in just 15 weeks online or on campus.

🔧 Code, Tools & Resources

moveable: A Library for Dragging, Resizing, Scaling and More — If you want to manipulate an element in any way (warping, pinching, rotating, etc) this library can probably help. Demo here.

Daybrush (Younkue Choi)

Facebook Design: Images and Sketch Files of Popular Devices — These sort of collections always prove handy to have stored away in your bookmarks.

Facebook

AniX: A 'Super Easy and Lightweight' CSS Animation Library

AniX

   ðŸ—“ Upcoming Events

Accessibility Scotland, October 25 — Edinburgh, UK — One day of talks. Friendly, open discussion about accessibility.

Performance Now, November 21-22 — Amsterdam, Netherlands — A single track conference with fourteen world-class speakers, covering the most important web performance insights.

VueConfTO 2019, November 11-12 — Toronto, Canada — First ever Vue Conference in Canada. Biggest in North America, with great workshops and talks.

Frontend Con, November 26-27 — Warsaw, Poland — Brings together 30+ top experts with over 500 experienced frontend pros from all over the world.


by via Frontend Focus