emGee Software Solutions Custom Database Applications

Share this

Web Technologies

Font Playground

CSS-Tricks - Fri, 07/20/2018 - 12:29

This is a wondrous little project by Wenting Zhang that showcases a series of variable fonts and lets you manipulate their settings to see the results. It’s interesting that there’s so many tools like this that have been released over the past couple of months, such as v-fonts, Axis-Praxis and Wakamai Fondue just to name a few.

Direct Link to ArticlePermalink

The post Font Playground appeared first on CSS-Tricks.

Categories: Web Technologies

Weird things variable fonts can do

CSS-Tricks - Fri, 07/20/2018 - 12:28

I tend to think of variable fonts as a font format in which a single font file is capable of displaying type at near-infinite variations of things like boldness, width, and slantyness. In my experience, that's a common use case. Just check out many of the interactive demos over at Axis-Praxis:


Make sure to go play around at v-fonts.com as well for loads of variable font demonstrations.

But things like boldness, width, and slantyness and just a few of the attributes that a type designer might want to make controllable. There are no rules that say you have to make boldness a controllable attribute. Literally, anything is possible, and people have been experimenting with that quite a bit.

If you're interested in variable fonts, we have a whole guide with all the best articles we've published on the subject.

Here's some, ahem, weirder things that variable fonts can do.

A variable font can change its own serifyness

A typical job for a variable font is changing weight/width/slant... but it really can be _anything_.

Foreday is a font where you can change it's serifyness(1).https://t.co/t4soiQaYqH

(1) real word now ok. pic.twitter.com/5X0oGauUbf

— Chris Coyier (@chriscoyier) April 24, 2018

A variable font can be used for animation

Kind of like sprite sheet animation!

Y'all seem to be pretty into ➡️ variable fonts doing weird things ⬅️ so here's another mind-blower. pic.twitter.com/U2ok2tR6r8

— Chris Coyier (@chriscoyier) May 3, 2018

Toshi Omagari has made a number of absolutely bananas demos, including stuff like this pixelated video, which straight up breaks my brain:

A variable font can adjust its own attributes on three different axes

Another variable font thing that's pretty 😲 https://t.co/dzp92UxXqX pic.twitter.com/1mLxIhqoVR

— Chris Coyier (@chriscoyier) May 2, 2018

A variable font can change the hat on some poop

I hope you don't mind me tootin' my own horn, but there's also the glorious pioneering work of a variable color font called... Mr. Poo: https://t.co/aE2qWE69Cm pic.twitter.com/X3ylXzqtnT

— Roel Nieskens (@pixelambacht) May 8, 2018

A variable font can make the grass grow

This is a demo by Mandy Michael using Decovar, a "multistyle decorative variable font" by David Berlow.

See the Pen Grassy Text with Variable fonts. by Mandy Michael (@mandymichael) on CodePen.

Decovar is weird.

A variable font can make blood drip

This one is called Krabat by Josefína Karlíková:

There are loads of cool ones on The Next Big Thing in Type to check out. Here's another awesome one:

Variable fonts are a ripe field for experimentation!

The post Weird things variable fonts can do appeared first on CSS-Tricks.

Categories: Web Technologies

Building “Renderless” Vue Components

CSS-Tricks - Fri, 07/20/2018 - 07:00

There's this popular analogy of Vue that goes like this: Vue is what you get when React and Angular come together and make a baby. I've always shared this feeling. With Vue’s small learning curve, it's no wonder so many people love it. Since Vue tries to give the developer power over components and their implementation as much as it possibly can, this sentiment has led to today's topic.

The term renderless components refers to components that don’t render anything. In this article, we'll cover how Vue handles the rendering of a component.

We'll also see how we can use the render() function to build renderless components.

You may want to know a little about Vue to get the most out of this article. If you are a newbie Sarah Drasner's got your back. The official documentation is also a very good resource.

Demystifying How Vue Renders a Component

Vue has quite a few ways of defining a component's markup. There's:

  • Single file components that let us define components and their markup like we would a normal HTML file.
  • The template component property which allows us to use JavaScript's template literals to define the markup for our component.
  • The el component property tells Vue to query the DOM for a markup to use as the template.

You've probably heard the (possibly rather annoying): at the end of the day, Vue and all its components are just JavaScript. I could see why you may think that statement is wrong with the amount of HTML and CSS we write. Case and point: single file components.

With single file components, we can define a Vue component like this:

<template> <div class="mood"> {{ todayIsSunny ? 'Makes me happy' : 'Eh! Doesn't bother me' }} </div> </template> <script> export default { data: () => ({ todayIsSunny: true }) } </script> <style> .mood:after { content: '&#x1f389;&#x1f389;'; } </style>

How can we say Vue is "just JavaScript" with all of that gobbledygook above? But, at the end of the day, it is. Vue does try to make it easy for our views to manage their styling and other assets, but Vue doesn't directly do that — it leaves it up to the build process, which is probably webpack.

When webpack encounters a .vue file, it'll run it through a transform process. During this process, the CSS is extracted from the component and placed in its own file, and the remaining contents of the file get transformed into JavaScript. Something like this:

export default { template: ` <div class="mood"> {{ todayIsSunny ? 'Makes me happy' : 'Eh! Doesn't bother me' }} </div>`, data: () => ({ todayIsSunny: true }) }

Well... not quite what we have above. To understand what happens next, we need to talk about the template compiler.

The Template Compiler and the Render Function

This part of a Vue component’s build process is necessary for compiling and running every optimization technique Vue currently implements.

When the template compiler encounters this:

{ template: `<div class="mood">...</div>`, data: () => ({ todayIsSunny: true }) }

...it extracts the template property and compiles its content into JavaScript. A render function is then added to the component object. This render function will, in turn, return the extracted template property content that was converted into JavaScript.

This is what the template above will look like as a render function:

... render(h) { return h( 'div', { class: 'mood' }, this.todayIsSunny ? 'Makes me happy' : 'Eh! Doesn't bother me' ) } ...

Refer to the official documentation to learn more about the render function.

Now, when the component object gets passed to Vue, the render function of the component goes through some optimizations and becomes a VNode (virtual node). VNode is what gets passed into snabbdom (the library Vue uses internally to manage the virtual DOM). Sarah Drasner does a good job explaining the "h" in the render function above.

A VNode is how Vue renders components. By the way, the render function also allows us to use JSX in Vue!

We also don’t have to wait for Vue to add the render function for us — we can define a render function and it should take precedence over el or the template property. Read here to learn about the render function and its options.

By building your Vue components with Vue CLI or some custom build process, you don't have to import the template compiler which can bloat your build file size. Your components are also pre-optimized for a brilliant performance and really lightweight JavaScript files.

So... Renderless Vue Components

Like I mentioned, the term renderless components means components that don’t render anything. Why would we want components that don't render anything?

We can chalk it up to creating an abstraction of common component functionality as its own component and extending said component to create better and even more robust components. Also, S.O.L.I.D.

According to the Single responsibility principle of S.O.L.I.D.:

A class should only have one purpose.

We can port over that concept into Vue development by making each component have only one responsibility.

You may be like Nicky and, "pfft, yeah I know." Okay, sure! Your component may have the name "password-input" and it surely renders a password input. The problem with this approach is that when you want to reuse this component in another project, you may have to go into the component’s source to modify the style or the markup to keep in line with the new project’s style guide.

This breaks a rule of S.O.L.I.D. known as the open-closed principle which states that:

A class or a component, in this case, should be open for extension, but closed for modification.

This is saying that instead of editing the component's source, you should be able to extend it.

Since Vue understands S.O.L.I.D. principles, it lets components have props, events, slots, and scoped slots which makes communication and extension of a component a breeze. We can then build components that have all the features, without any of the styling or markup. Which is really great for re-usability and efficient code.

Build a "Toggle" Renderless Component

This will be simple. No need to set up a Vue CLI project.

The Toggle component will let you toggle between on and off states. It'll also provide helpers that let you do that. It's useful for building components like, well, on/off components such as custom checkboxes and any components that need an on/off state.

Let's quickly stub our component: Head to the JavaScript section of a CodePen pen and follow along.

// toggle.js const toggle = { props: { on: { type: Boolean, default: false } }, render() { return [] }, data() { return { currentState: this.on } }, methods: { setOn() { this.currentState = true }, setOff() { this.currentState = false }, toggle() { this.currentState = !this.currentState } } }

This is pretty minimal and not yet complete. It needs a template, and since we don't want this component to render anything, we have to make sure it works with any component that does.

Cue the slots!

Slots in Renderless Components

Slots allow us to place content between the opening and close tags of a Vue component. Like this:

<toggle> This entire area is a slot. </toggle>

In Vue's single file components, we could do this to define a slot:

<template> <div> <slot/> </div> </template>

Well, to do that using a render() function, we can:

// toggle.js render() { return this.$slots.default }

We can automatically place stuff within our toggle component. No markup, nothing.

Sending Data up the Tree with Scoped Slots

In toggle.js, we had some on state and some helper functions in the methods object. It’d be nice if we could give the developer access to them. We are currently using slots and they don’t let us expose anything from the child component.

What we want is scoped slots. Scoped slots work exactly like slots with the added advantage of a component having a scoped slot being able to expose data without firing events.

We can do this:

<toggle> <div slot-scope="{ on }"> {{ on ? 'On' : 'Off' }} </div> </toggle>

That slot-scope attribute you can see on the div is de-structuring an object exposed from the toggle component.

Going back to the render() function, we can do:

render() { return this.$scopedSlots.default({}) }

This time around, we are calling the default property on the $scopedSlots object as a method because scoped slots are methods that take an argument. In this case, the method's name is default since the scoped slot wasn't given a name and it's the only scoped slot that exists. The argument we pass to a scoped slot can then be exposed from the component. In our case, let’s expose the current state of on and the helpers to help manipulate that state.

render() { return this.$scopedSlots.default({ on: this.currentState, setOn: this.setOn, setOff: this.setOff, toggle: this.toggle, }) } Using the Toggle Component

We can do this all in CodePen. Here is what we’re building:

See the Pen ZRaYWm by Samuel Oloruntoba (@kayandrae07) on CodePen.

Here’s the markup in action:

<div id="app"> <toggle> <div slot-scope="{ on, setOn, setOff }" class="container"> <button @click="click(setOn)" class="button">Blue pill</button> <button @click="click(setOff)" class="button isRed">Red pill</button> <div v-if="buttonPressed" class="message"> <span v-if="on">It's all a dream, go back to sleep.</span> <span v-else>I don't know how far the rabbit hole goes, I'm not a rabbit, neither do I measure holes.</span> </div> </div> </toggle> </div>
  1. First, we are de-structuring the state and helpers from the scoped slot.
  2. Then, within the scoped slot, we created two buttons, one to toggle current state on and the other off.
  3. The click method is just there to make sure a button was actually pressed before we display a result. You can check out the click method below.
new Vue({ el: '#app', components: { toggle }, data: { buttonPressed: false, }, methods: { click(fn) { this.buttonPressed = true fn() }, }, })

We can still pass props and fire events from the Toggle component. Using a scoped slot changes nothing.

new Vue({ el: '#app', components: { toggle }, data: { buttonPressed: false, }, methods: { click(fn) { this.buttonPressed = true fn() }, }, })

This is a basic example, but we can see how powerful this can get when we start building components like a date picker or an autocomplete widget. We can reuse these components across multiple projects without having to worry about those pesky stylesheets getting in the way.

One more thing we can do is expose the attributes needed for accessibility from the scoped slot and also don’t have to worry about making components that extend this component accessible.

In Summary
  • A component’s render function is incredibly powerful.
  • Build your Vue components for a faster run-time.
  • Component’s el, template or even single file components all get compiled into render functions.
  • Try to build smaller components for more reusable code.
  • Your code need not be S.O.L.I.D., but it’s a damn good methodology to code by.

The post Building “Renderless” Vue Components appeared first on CSS-Tricks.

Categories: Web Technologies

Oracle: Switch now from Nashorn JavaScript engine to GraalVM

InfoWorld JavaScript - Fri, 07/20/2018 - 03:00

With plans to deprecate the Nashorn JavaScript engine in the upcoming Java Development Kit (JDK) 11, Oracle is encouraging developers to take a look at GraalVM virtual machine instead. Oracle says it’s more capable than Nashorn, and it has laid out a migration path from Nashorn to GraalVM. Oracle does plan to support Nashorn for a few years to provide time to migrate.

To read this article in full, please click here

Categories: Web Technologies

PHP 7.1.20 Released - PHP: Hypertext Preprocessor

Planet PHP - Thu, 07/19/2018 - 17:00
The PHP development team announces the immediate availability of PHP 7.1.20. This is a security release. Several security bugs have been fixed in this release. All PHP 7.1 users are encouraged to upgrade to this version. For source downloads of PHP 7.1.20 please visit our downloads page, Windows source and binaries can be found on windows.php.net/download/. The list of changes is recorded in the ChangeLog.
Categories: Web Technologies

CSS: A New Kind of JavaScript

CSS-Tricks - Thu, 07/19/2018 - 13:37

In this wacky and satirical post, Heydon Pickering describes a wild new technology called Cascading Style Sheets that solves a lot of the problems you might bump into when styling things with JavaScript:

A good sign that a technology is not fit for purpose is how much we have to rely on workarounds and best practices to get by. Another sign is just how much code we have to write in order to get simple things done. When it comes to styling, JavaScript is that technology.

CSS solves JavaScript’s styling problems, and elegantly. The question is: are you willing to embrace the change, or are you married to an inferior methodology?

Yes, this is a funny post but the topic of CSS-in-JS is hot and quite active. We recently shared a video of Bruce Lawson's excellent talk on the subject and published a roundup of chatter about it as it relates to React. Chris also linked the conversation back to the age-old question of how we deal with unused CSS.

Direct Link to ArticlePermalink

The post CSS: A New Kind of JavaScript appeared first on CSS-Tricks.

Categories: Web Technologies

Accessibility for Teams

CSS-Tricks - Thu, 07/19/2018 - 13:37

Maya Benari:

Accessibility is a crucial part of government product design. First, it’s the law. Federal agencies face legal consequences when they don’t meet accessibility requirements. Second, it affects us all. Whether you have a motor disability, you sprained your wrist playing dodgeball, you need a building to have a ramp for your wheelchair or stroller, or you literally just have your hands full, we all find ourselves unable to do certain things at different points in our lives. Accessible products are better products for everyone.

But accessibility is hard: It comes across as a set of complex rules that are hard to follow. Not everyone feels confident that they’re doing it right. It’s difficult to prioritize alongside other work and project needs. How do you make sure you’re building products that are accessible and inclusive?

So they set about building a guide and did a heck of a job. This is 18F work, the same team that did the U.S. Web Design System (see video presentation).

Direct Link to ArticlePermalink

The post Accessibility for Teams appeared first on CSS-Tricks.

Categories: Web Technologies

Security Vulnerability Announcement: html_QuickForm - Official Blog of the PEAR Group/PEAR President

Planet PHP - Thu, 07/19/2018 - 11:22

A vulnerability in the html_QuickForm package has been found which potentially allows remote code execution.

A new release of the package is available which fixes this issue. One is strongly encouraged to upgrade to it by using:

$ pear upgrade html_QuickForm-3.2.15

Thanks to Patrick Fingle and the CiviCRM Security Team who reported this issue.

Categories: Web Technologies


1 2 3 4 5 6 7 8 9 next › last »