Wednesday, July 18, 2018

The 9 Biggest Mistakes when using CSS Grid

#349 — July 18, 2018

Read on the Web

Frontend Focus

▶  The 9 Biggest Mistakes when using CSS Grid — A fast-paced 14 minute video (ideal for a lunch break!) that runs through things like overusing CSS Grid, reaching for frameworks too quickly, or worrying about IE11 too much.

Jen Simmons

Chrome's 'Site Isolation' for Web Developers — Chrome’s new Site Isolation feature ensures pages from different sites run in a sandbox to improve security and prevent cross-site data sniffing techniques. This introduces some possibly unexpected considerations for Web developers, as covered here.

Mathias Bynens

Choosing the Right JavaScript Framework: Whitepaper — How do you choose one JavaScript framework over another for your next web application? Learn about the current state of Angular, React and Vue and how they compare against a comprehensive set of criteria. Download now.

Progress Kendo UI sponsor

The Holy Grail of Reusable Components: Custom Elements, Shadow DOM, and NPM — A look at augmenting HTML with components that have built-in functionality and styles as well as reusing them across projects via npm.

Oliver Williams

Building the Google Photos Web UI — It’s always fantastic to get a detailed look under the hood of how some of the web’s most heavily used apps are built.

Antin Harasymiv (Google Design)

Is It Worth Using IE's Version of Grid Layout? — Last week, we ran an item about coding CSS grid to work in IE 11 too but Rachel Andrew suspects it’s not necessarily worth the compromises.

Rachel Andrew

▶  CSS in JavaScript: FTW or WTF? — 10-15 years ago there was a heavy push in the webdev world to keep HTML, CSS, and JavaScript far apart but this is increasingly changing in modern webapps. This talk reflects on the concepts, pros and cons involved.

Bruce Lawson

💻 Jobs

Sr. Front-End Engineer, OTT - New York City — Vimeo is a place where all stories can be beautifully told. Build the future with us.

Vimeo

Senior Developer, New York or Remote — We're looking for a Sr Dev to join our team to help build, deliver and produce quality products for our growing customer base.

Apartment Therapy Media

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

Vettery

📘 Tutorials & Articles

How to Build an Animated Slider Component

Eder Diaz

❄️ ColdFront and a Holistic Future Outlook at the Front-End Landscape

ColdFront Conf sponsor

What Are Service Workers and How They Help Improve Performance — Service workers run in the background of a user’s browser and help provide various extended features.

Cody Arsenault

CSS Quick Tip: The Valid Characters in a Custom CSS Selector — Ultimately, though, don’t try to be too clever.

Adam Laki

An Experiment in Delivering WordPress in 7KB

Jack Lenox

▶  The Friction of Web Standards — Why does it take a long time to ship some new Web standards and what are the challenges implementors and spec authors face?

Eric Meyer

Which Podcasts Should Web Designers And Developers Be Listening To? — A shortlist of current podcasts for web designers and developers.

Smashing Magazine

🔧 Code and Tools

PWACompat: The Web App Manifest for All Browsers — Use the PWACompat library to easily bring your Web App Manifest to all browsers, even non-compliant ones.

Google Developers

Pinpointer: A Firefox Addon to Link to Specific Elements on Pages

Firefox Addons

Popbox.js: Stackable Modals for Web Pages — If you need a modal on top of your modal..

popbox.js

SlickMap CSS: A Stylesheet to Turn HTML Lists into Elegant SitemapsDemo here.

Astuteo

Phenomenon: A 2KB Low-Level WebGL Library — Provides the essentials to deliver high performance visuals easily. Several neat demos with code including throwing 10000 cubes around.

Colin van Eenige

Recurss: Recursive CSS Experiments — Take a big pile of nested DIVs, apply a style, what happens?

Matt Bierner

An Interesting 'Scrolling Gradient' Effect in Pure CSS — Overlaying two gradients leads to an interesting effect here.

CodePen


by via Frontend Focus

Ethereum DApps: Cross-contract Communication & Token Selling

In part 4 of this tutorial series on building DApps with Ethereum, we started building and testing our DAO contract. Now let’s go one step further and handle adding content and tokens to the story, as per our introduction.

Adding Tokens

For a contract to be able to interact with another contract, it needs to be aware of that other contract’s interface — the functions available to it. Since our TNS token has a fairly straightforward interface, we can include it as such in the contract of our DAO, above the contract StoryDao declaration and under our import statements:

contract LockableToken is Ownable {
    function totalSupply() public view returns (uint256);
    function balanceOf(address who) public view returns (uint256);
    function transfer(address to, uint256 value) public returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    function allowance(address owner, address spender) public view returns (uint256);
    function transferFrom(address from, address to, uint256 value) public returns (bool);
    function approve(address spender, uint256 value) public returns (bool);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    function approveAndCall(address _spender, uint256 _value, bytes _data) public payable returns (bool);
    function transferAndCall(address _to, uint256 _value, bytes _data) public payable returns (bool);
    function transferFromAndCall(address _from, address _to, uint256 _value, bytes _data) public payable returns (bool);

    function increaseLockedAmount(address _owner, uint256 _amount) public returns (uint256);
    function decreaseLockedAmount(address _owner, uint256 _amount) public returns (uint256);
    function getLockedAmount(address _owner) view public returns (uint256);
    function getUnlockedAmount(address _owner) view public returns (uint256);
}

Notice that we don’t need to paste in the “meat” of the functions, but only their signatures (skeletons). This is all that’s needed to interact between contracts.

Now we can use these functions in the DAO contract. The plan is as follows:

  • launch the token (we already did this)
  • launch the DAO from the same address
  • send all tokens from the token-launcher to the DAO, then transfer ownership over the contract to the DAO itself
  • at this point the DAO owns all tokens and can sell them to people using the transfer function, or can reserve them for spending using the approve function (useful during votes), etc.

But how does the DAO know which address the token is deployed on? We tell it.

First, we add a new variable at the top of the DAO contract:

LockableToken public token;

Then, we add some functions:

constructor(address _token) public {
    require(_token != address(0), "Token address cannot be null-address");
    token = LockableToken(_token);
}

The constructor is the function which gets called automatically when a contract is deployed. It’s useful for initializing values like linked contracts, default values, etc. In our case, we’ll use it to consume and save the address of the TNS token. The require check is there to make sure the token’s address is valid.

While we’re at it, let’s add a function that lets users check how many tokens remain for sale in the DAO, and the ability to change to another token should something go wrong and such a change be required. This change deserves an event, too, so let’s add that in as well.

event TokenAddressChange(address token);

function daoTokenBalance() public view returns (uint256) {
    return token.balanceOf(address(this));
}

function changeTokenAddress(address _token) onlyOwner public {
    require(_token != address(0), "Token address cannot be null-address");
    token = LockableToken(_token);
    emit TokenAddressChange(_token);
}

The first function is set to view because it doesn’t change the state of the blockchain; it doesn’t alter any values. This means it’s a free, read-only function call to the blockchain: it doesn’t need a paid transaction. It also returns the balance of tokens as a number, so this needs to be declared on the function’s signature with returns (uint256). The token has a balanceOf function (see the interface we pasted in above) and it accepts one parameter — the address whose balance to check. We’re checking our (this) DAO’s balance, so “this”, and we turn “this” into an address with address().

The token address changing function allows the owner (admin) to change the token contract. It’s identical to the logic of the constructor.

Let’s see how we can let people buy the tokens now.

Buying Tokens

As per the previous part of the series, users can buy tokens by:

  • Using the fallback function if already whitelisted. In other words, just sending ether to the DAO contract.
  • Using the whitelistAddress function by sending more than the fee required for whitelisting.
  • Calling the buyTokens function directly.

There is a caveat, however. When someone calls the buyTokens function from the outside, we want it to fail if there aren’t enough tokens in the DAO to sell. But when someone buys tokens via the whitelist function by sending in too much in the first whitelisting attempt, we don’t want it to fail, because then the whitelisting process will get canceled as everything fails at once. Transactions in Ethereum are atomic: either everything has to succeed, or nothing. So we’ll make two buyTokens functions.

// This goes at the top of the contract with other properties
uint256 public tokenToWeiRatio = 10000;

function buyTokensThrow(address _buyer, uint256 _wei) external {

    require(whitelist[_buyer], "Candidate must be whitelisted.");
    require(!blacklist[_buyer], "Candidate must not be blacklisted.");

    uint256 tokens = _wei * tokenToWeiRatio;
    require(daoTokenBalance() >= tokens, "DAO must have enough tokens for sale");
    token.transfer(_buyer, tokens);
}

function buyTokensInternal(address _buyer, uint256 _wei) internal {
    require(!blacklist[_buyer], "Candidate must not be blacklisted.");
    uint256 tokens = _wei * tokenToWeiRatio;
    if (daoTokenBalance() < tokens) {
        msg.sender.transfer(_wei);
    } else {
        token.transfer(_buyer, tokens);
    }
}

So, 100 million TNS tokens exist. If we set a price of 10000 tokens per one ether, that comes down to around 4–5 cents per token, which is acceptable.

The functions do some calculations after doing sanity checks against banned users and other factors, and immediately send the tokens out to the buyer, who can start using them as they see fit — either for voting, or for selling on exchanges. If there’s fewer tokens in the DAO than the buyer is trying to buy, the buyer is refunded.

The part token.transfer(_buyer, tokens) is us using the TNS token contract to initiate a transfer from the current location (the DAO) to the destination _buyer for amount tokens.

Now that we know people can get their hands on the tokens, let’s see if we can implement submissions.

The post Ethereum DApps: Cross-contract Communication & Token Selling appeared first on SitePoint.


by Bruno Skvorc via SitePoint

Instagram Plans to Replace its Old Method of Authenticating Accounts With a More Reliable Verification Process

According to TechCrunch, Instagram is busy developing a new two-factor authentication mechanism for its application, which would not demand users' phone numbers to proceed, making it more secure than ever before. Apparently, this development has been made in response to the article released...

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

by Neha Zaidi via Digital Information World

Irby’s Tavern

One Pager built on WordPress for Atlanta-based sports bar, Irby's Tavern.

Full Review | Direct Link


by Rob Hope @robhope via One Page Love

Creating Animations With MotionLayout for Android

Canvas Slicer Slider with JavaScript

Canvas Slicer is a unique and easy to use slider with awesome transition effects, which you can also create yourself. Written with pure object oriented javascript. It has easy to implement and configure. This slider will add your page eye-catching effect.

  • 9 unique animation effects or set your effect.
  • Responsive
  • Directional navigation
  • Touch screen support
  • Helpful API functions are provided
  • Developed with pure object oriented javascript
  • Simple clean and valid markup

The post Canvas Slicer Slider with JavaScript appeared first on Best jQuery.


by Admin via Best jQuery

parallaxContent : jQuery Parallax Content Plugin

ParallaxContent is a jQuery parallax content plugin based on GSAP .

The post parallaxContent : jQuery Parallax Content Plugin appeared first on Best jQuery.


by Admin via Best jQuery