In this week’s roundup, WebKit’s method for truncating multi-line text gets some love, a note on calculations using custom properties, and a new OpenType feature that prevents typographic logjams.
Truncating mutli-line text
The CSS -webkit-line-clamp property for truncating multi-line text is now widely supported (see my usage guide). If you use Autoprefixer, update it to the latest version (9.6.1). Previous versions would remove -webkit-box-orient: vertical, which caused this CSS feature to stop working.
Note that Autoprefixer doesn’t generate any prefixes for you in this case. You need to use the following four declarations exactly (all are required):
.line-clamp {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3; /* or any other integer */
}
In CSS, it is currently not possible to pre-calculate custom property values (spec). The computed value of a custom property is its specified value (with variables substituted); therefore, relative values in calc() expressions are not „absolutized” (e.g., em values are not computed to pixel values).
It may appear that the calculation in the above example is performed on the root element, specifically that the relative value 1em is computed and added to the absolute value 10px. Under default conditions (where 1em equals 16px on the root element), the computed value of --large would be 26px.
But that’s not what’s happening here. The computed value of --large is its specified value, calc(1em + 10px). This value is inherited and substituted into the value of the font-size property on the <blockquote> element.
blockquote {
/* the declaration after variable substitution */
font-size: calc(1em + 10px);
}
Finally, the calculation is performed and the relative 1em value absolute-ized in the scope of the <blockquote> element — not the root element where the calc() expression is declared.
The „Contextual Alternates” OpenType feature ensures that characters don’t overlap or collide when ligatures are turned off. You can check if your font supports this feature on wakamaifondue.com and enable it (if necessary) via the CSS font-variant-ligatures: contextual declaration.
👋 Hey folks! Silvestar pitched this post to us because he is genuinely enthusiastic about JAMstack and all of the opportunities it opens up for front-end development. We wanted to call that out because, although some of the points in here might come across as sponsored content and Netlify is indeed a CSS-Tricks sponsor, it’s completely independent of Netlify.
Being a JAMstack developer in 2019 makes me feel like I am living in a wonderland. All these modern frameworks, tools, and services make our lives as JAMstack developers quite enjoyable. In fact, Chris would say they give us superpowers.
Yet, there is one particular platform that stands out with its formidable products and features — Netlify. You’re probably pretty well familiar with Netlify if you read CSS-Tricks regularly. There’s a slew of articles on it. There are even two CSS-Tricks microsites that use it.
This article is more of a love letter to Netlify and all of the great things it does. I decided to sit down and list my most favorite things about it. So that’s what I’d like to share with you here. Hopefully, this gives you a good idea not only what Netlify is capable of doing, but helps you get the most out of it as well.
You can customize your site’s Netlify subdomain.
When creating a new project on Netlify, you start by either:
choosing a repository from a Git provider, or
uploading a folder.
The project should be ready in a matter of minutes, and you could start configuring it for your needs right away. Start by choosing the site name.
The site name determines the default URL for your site. Only alphanumeric characters and hyphens are allowed.
Netlify randomly creates a default name for a new project. If you don’t like the name, choose your own and make it one that would be much easier for you to remember.
The „Site information” section of the Netlify dashboard.
For example, my site name is silvestarcodes, and I could access my site by visiting silvestarcodes.netlify.com.
You can manage all your DNS on Netlify.
If you are setting up an actual site, you would want to add a custom domain. From the domain management panel, go to the custom domains section, click on the „Add custom domain” button, enter your domain, and click the „Verify” button.
Now you have two options:
Point your DNS records to Netlify load balancer IP address
For the second option, you should add or update the nameservers on your domain registrar. If you didn’t buy the domain already, you could register it right from the dashboard.
Netlify has a service for provisioning DNS records called Netlify DNS.
Once you have configured the custom domain, you could handle your DNS records from the Netlify dashboard.
The „DNS” section of the Netlify dashboard.
If you want to set up a dev subdomain for your dev branch to preview development changes for your site, you could do it automatically. From the Domain Management section in the Settings section of your site, select the dev branch and Netlify would add a new subdomain dev for you automagically. Now you could see the previews by visiting dev subdomain.
The „Subdomains” section of the Netlify dashboard.
You could configure a subdomain for a different website. To achieve this, create a new Netlify site, enter a new subdomain as a custom domain, and Netlify would automatically add the records for you.
As an icing on the DNS management cake, Netlify lets you create Let’s Encrypt certificates for your domain automatically… for free.
You can inject snippets into pages, which is sort of like a Tag Manager.
Snippet injection is another excellent feature. I am using it mostly for inserting analytics, but you could use it for adding meta tags for responsive behavior, favicon tags, or Webmention.io tags.
The „Snippet injection” section of the Netlify dashboard.
When inserting snippets, you could choose to append the code fragment at the end of the <head> block, or at the end of the <body> block.
They are immutable deployments that live on forever.
— Phil Hawksworth
I found this feature useful when completing tasks and sending the preview links to the clients. If there is a person in charge of handling Git-related tasks, like publishing to production, these preview links could be convenient to understand what to expect during the merge. You could even set up the preview builds for every pull request.
Netlify allows for the cleanest and most responsible A/B testing you can do.
If you ever wanted to run A/B tests on your site, you would find that Netlify makes running A/B tests quite straightforward. Split testing on Netlify allows you to display different versions of your website from different Git branches without any hackery.
The „Split testing” section of the Netlify dashboard.
Start by adding and publishing a separate branch with desired changes. From “Split testing” panel, select which branches to test, set a split percentage, and start the test. You could even set a variable in analytics code to track which branch is currently displayed. You might need to active branch deploys if you didn’t do this already.
Netlify’s Split Testing lets you divide traffic to your site between different deploys, straight from our CDN network, without losing any download performance, and without installing any third party JavaScript library.
— Netlify documentation
I have been using A/B testing on my site for a few different features so far:
Testing different versions of contact forms
Displaying different versions of banners
Tracking user behavior, like heatmaps
If you want to track split testing information, you could set up the process environment variable for this purpose. You could learn more about it in the official documentation. The best part? Most A/B testing services use client-side JavaScript to do it, which is unreliable and not great for performance. Doing it at the load balancer level like this is so much better.
There are lots of options for notifications, like email and Slack.
If you want to receive a notification when something happens with your Netlify project, you could choose from a wide variety of notification options. I prefer getting an email for every successful or failed build.
The „Notifications” section of the Netlify dashboard.
If you are using Gmail, you could notice „See the changes live” link for every successful build when hovering your message in Gmail inbox. That means you could open a preview link without opening the email. There are other links like „See full deploy logs” when your build have any issues or „Check usage details” when your plan is near its limits. How awesome is that?
Netlify email notifications include a preview link.
If you want to set up a hook for third-party services, all you need is a URL (JWS secret token is optional). Slack hooks are built-in with Netlify and could be set up within seconds if you know your Slack incoming webhook URL.
Conclusion
All of the features mentioned above are part of the free Netlify plan. I cannot even imagine the effort invested in providing a seamless experience as it is now. But Netlify doesn’t stop there. They are introducing more and more new and shiny features, like Netlify Dev CLI for local development and deploy cancelations. Netlify has established as an undoubtedly game-changing platform in modern web development of static websites, and it is a big part of the growth and popularity of static sites.
Promote your next business venture or current products with this super-easy tutorial that will help you attract more consumers. In this tutorial, I’ll show you how to make a flyer template.
Corporate business flyers are cost-effective advertising that you can use. Having an easy-to-use business flyer whose format you or your clients can quickly change is a huge advantage.
In this tutorial, I’ll show you how to make a flyer with the most essential tools. You’ll learn how to successfully set up a template with layers, Color Swatches, and Paragraph styles. These three components will make trouble-free business flyers that can be formatted in just minutes.
What You Will Need for Your InDesign Flyer Template
You’ll need access to Adobe InDesign and Adobe Illustrator. If you don’t have the software, you can download a trial from the Adobe website. You’ll also need:
Download the assets and make sure the font is installed on your system before starting. When you are ready, we can start designing the business flyer template!
1.Setting Up a Marketing Flyer Template InDesign File
Step 1
In InDesign, go to File > New. In the New Document window, select the Print Tab. Select the A4 preset and name the document „Marketing Flyer Template”. Change the settings to the following:
Width to 21 cm
Height to 29.7 cm
Orientation to Portrait
Units to Centimeters
Pages to 1
Uncheck Facing Pages
Margins to 1.27 cm
Bleeds to 0.3 cm (it’s best to seek your professional printer’s preference)
Click Create.
Step 2
For this open marketing flyer template, we will work with three Layers. Organizing layers is an important practice when designing a template as they will make it easier for the user to edit.
Bring up the Layers panel by going to Window > Layers. Double-click on Layer 1 and rename it Background.
In the Layers panel main menu, select New Layer. Name it Images. Click OK.
Additionally, create a new layer named Copy. Click OK.
Step 3
Head over to Window > Color > Swatches to expand the Swatches panel. Choose New Color Swatch from the main menu. Set the Swatch Name and values to the following:
Teal: C=60 M=0 Y=30 K=0
Dark Blue:C=100 M=80 Y=0 K=70
Click Add and OK after you input each color value.
Step 4
For this tutorial, we will create a list of Paragraph Styles that we will use to format the marketing flyer template.
Head over to Window > Styles > Paragraph Styles to open the Paragraph Styles panel. On the main menu, select New Paragraph Style and set the Style Name to Copy. Select the Basic Character Formats option from the left side menu. Use the following settings:
Font Family: RNS Sanz
Font Style: Normal
Size: 9 pt
Select the Character Color option from the left side menu. Set the color to the Blue swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Headline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 14 pt
Select the Character Color option from the left side menu. Set the color to the Teal swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Subheadline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 9 pt
Select the Character Color option from the left side menu. Set the color to the Teal swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Tagline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 18 pt
Select the Character Color option from the left side menu. Set the color to the Blue swatch. Click OK.
Step 5
Go to Layout > Create Guides. In the Create Guides option window, use the following settings:
2. How to Design a Marketing Flyer Template in InDesign
Step 1
Select the Background layer from the Layers panel.
Using the Rectangle Tool (M), create a rectangle that measures 15 cm in Width and 5 cm in Height.
On the Swatches panel, select the Blue swatch. Set the Tint to 10%.
Create a small text frame over the element and on the top right corner of the marketing flyer. Here, you can include contact information. Use the Paragraph Styles panel to format the frame into the Copy style. On the Control bar, select the Align Right button.
Step 2
Select the Images layer from the Layers panel.
Press Command-D to Place an image. Select the Social Media Logo EPS file and click Open.
Use the Selection Tool (V) to crop the frame to the preferred logo. Place the logo on the top left corner of the flyer design.
Step 3
Press Command-D to Place an image. Select the Female Asian Architect JPG file and click Open.
Place the image on the top guide of the first gutter.Use the Selection Tool (V) to crop the frame to the fourth row.
Use the Direct Selection Tool (A) to resize the image to 50%. Check for the Scale percentage on the Control bar.
Step 4
Select the Rectangle Tool (M) from the toolbar. Click on the document to open the Rectangle Option Window.
Create a rectangle that measures 10.55 cm in Width and 3.45 cm in Height. Click OK.
Step 5
On the Swatches panel, select the [Paper] swatch for the rectangle. Set the Opacity to 90%. Align the rectangle to the top left corner of the image.
Step 6
Select the Copy layer from the Layers panel.
Select the Text Tool (T) from the toolbar. Create a text frame over the rectangle that extends over the first column.
Step 7
Add content to the frame and use the Paragraph Styles panel to style the text. Use the Tagline style for the first two lines—this is great for a catchphrase to attract customers.
Use the Copy style for the description under the tagline.
Step 8
While selecting the text frame, press Command-B to open the Text Frame Options window.Under Inset Spacing, set the Right option to 0.5 cm. Click OK.
Step 9
Using the Text Tool (T), create a one-column text frame under the image. This frame can extend all the way to the bottom margin.
Add content and use the Paragraph Styles panel to style the frame. Use the Headline and Copy styles. Select the copy and change the color on the Swatches panel to [Paper].
Press Command-B to open the Text Frame Options window. Under Inset Spacing, set the Left side to 0.5 cm.
Using the Rectangle Tool (M), create a rectangle that covers the text frame we created in this step. On the Swatches panel, set the color to Blue. Place this element on the Background layer.
Step 10
Select the Text Tool (T) from the toolbar. Create a square text frame that measures 1 cm on all sides.
Set the color of the frame to Blue on the Swatches panel.
Add a number to the frame and use the Paragraph Styles panel to style it. Select the Headline style and change the color to [Paper] on the Swatches panel.
Step 11
Head over to the Control bar and select the AlignCenter button.
While selecting the text frame, press Command-B to open the Text Frame Options window.Under Inset Spacing, add 0.5 cm to all sides.Click OK.
Step 12
Open the Text Wrap panel by going to Window > Text Wrap. On the panel, set the Offset to 0.3 cm on all sides.
Step 13
Duplicate the text frame by pressing Option and dragging. Change the numbers to „2” and „3”. Place the frames over the full-column frame created previously.
Step 14
Using the Text Tool (T), create a second text frame on the opposite column.
Use the Paragraph Styles panel to design the frame with the Headline and Copy styles.
Step 15
Open the Digital Marketing Iconsin Illustrator. Select three icons and copy/paste them onto the marketing flyer template in InDesign.
Resize the icons on the Control bar. Set the Percentage Scale to 20%.
Step 16
You’ll notice the colors don’t match our design. On the Swatches panel, select the cream color and click on the Delete button. In the Delete Swatch options window, select the Replacement to Defined Swatch. In the dropdown menu, select the [Paper} swatch. Click OK.
Select the RGB teal coloron the Swatches panel. Delete it and replace it with the Blue swatch.
Step 17
Place each icon at the top of each gutter on the last three rows.
Create a text frame with the Text Tool (T) for each icon/row. Add content and use the Paragraph Styles panel to style it. Use the Subheadline and Copy styles.
Step 18
Using the Line Tool (/), create a stroke between each text frame.
Open the Stroke panel by going to Window > Stroke. Set the Stroke Weight to 1 pt and the Type to Dotted.
On the Swatches panel, set the Stroke color to Blue.
3.How to Export an InDesign Flyer Template File for Printing
Before exporting a file for printing, it is useful to take a look around all the edges to make sure all the images and vectors bleeding out are touching the bleeds.
Step 1
To export the file, go to File > Export. Name the file „Marketing Flyer Template”and choose Adobe PDF (Print) from the Format dropdown menu. Click Save.
Step 2
In the Export Adobe PDF window, set the Adobe PDF Preset to Press Quality.
On the left side of the panel, select Marks and Bleeds. Check All Printer’s Marks and Use Document Bleed Settings. Click Export. You will have a ready-to-print PDF file.
Great Job! You’ve Finished Your Business Flyer!
In this tutorial, we learned how to make a flyer template. We covered key tools that will help anyone edit this template fast and easy. Today, we learned to:
set up a ready-to-print InDesign file
create layers to keep an organized file
add color swatches and replace colors
create Paragraph styles to style text frames
use the Text Frame options and Text Wrap tool on text frames
Promote your next business venture or current products with this super-easy tutorial that will help you attract more consumers. In this tutorial, I’ll show you how to make a flyer template.
Corporate business flyers are cost-effective advertising that you can use. Having an easy-to-use business flyer whose format you or your clients can quickly change is a huge advantage.
In this tutorial, I’ll show you how to make a flyer with the most essential tools. You’ll learn how to successfully set up a template with layers, Color Swatches, and Paragraph styles. These three components will make trouble-free business flyers that can be formatted in just minutes.
What You Will Need for Your InDesign Flyer Template
You’ll need access to Adobe InDesign and Adobe Illustrator. If you don’t have the software, you can download a trial from the Adobe website. You’ll also need:
Download the assets and make sure the font is installed on your system before starting. When you are ready, we can start designing the business flyer template!
1.Setting Up a Marketing Flyer Template InDesign File
Step 1
In InDesign, go to File > New. In the New Document window, select the Print Tab. Select the A4 preset and name the document „Marketing Flyer Template”. Change the settings to the following:
Width to 21 cm
Height to 29.7 cm
Orientation to Portrait
Units to Centimeters
Pages to 1
Uncheck Facing Pages
Margins to 1.27 cm
Bleeds to 0.3 cm (it’s best to seek your professional printer’s preference)
Click Create.
Step 2
For this open marketing flyer template, we will work with three Layers. Organizing layers is an important practice when designing a template as they will make it easier for the user to edit.
Bring up the Layers panel by going to Window > Layers. Double-click on Layer 1 and rename it Background.
In the Layers panel main menu, select New Layer. Name it Images. Click OK.
Additionally, create a new layer named Copy. Click OK.
Step 3
Head over to Window > Color > Swatches to expand the Swatches panel. Choose New Color Swatch from the main menu. Set the Swatch Name and values to the following:
Teal: C=60 M=0 Y=30 K=0
Dark Blue:C=100 M=80 Y=0 K=70
Click Add and OK after you input each color value.
Step 4
For this tutorial, we will create a list of Paragraph Styles that we will use to format the marketing flyer template.
Head over to Window > Styles > Paragraph Styles to open the Paragraph Styles panel. On the main menu, select New Paragraph Style and set the Style Name to Copy. Select the Basic Character Formats option from the left side menu. Use the following settings:
Font Family: RNS Sanz
Font Style: Normal
Size: 9 pt
Select the Character Color option from the left side menu. Set the color to the Blue swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Headline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 14 pt
Select the Character Color option from the left side menu. Set the color to the Teal swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Subheadline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 9 pt
Select the Character Color option from the left side menu. Set the color to the Teal swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Tagline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 18 pt
Select the Character Color option from the left side menu. Set the color to the Blue swatch. Click OK.
Step 5
Go to Layout > Create Guides. In the Create Guides option window, use the following settings:
2. How to Design a Marketing Flyer Template in InDesign
Step 1
Select the Background layer from the Layers panel.
Using the Rectangle Tool (M), create a rectangle that measures 15 cm in Width and 5 cm in Height.
On the Swatches panel, select the Blue swatch. Set the Tint to 10%.
Create a small text frame over the element and on the top right corner of the marketing flyer. Here, you can include contact information. Use the Paragraph Styles panel to format the frame into the Copy style. On the Control bar, select the Align Right button.
Step 2
Select the Images layer from the Layers panel.
Press Command-D to Place an image. Select the Social Media Logo EPS file and click Open.
Use the Selection Tool (V) to crop the frame to the preferred logo. Place the logo on the top left corner of the flyer design.
Step 3
Press Command-D to Place an image. Select the Female Asian Architect JPG file and click Open.
Place the image on the top guide of the first gutter.Use the Selection Tool (V) to crop the frame to the fourth row.
Use the Direct Selection Tool (A) to resize the image to 50%. Check for the Scale percentage on the Control bar.
Step 4
Select the Rectangle Tool (M) from the toolbar. Click on the document to open the Rectangle Option Window.
Create a rectangle that measures 10.55 cm in Width and 3.45 cm in Height. Click OK.
Step 5
On the Swatches panel, select the [Paper] swatch for the rectangle. Set the Opacity to 90%. Align the rectangle to the top left corner of the image.
Step 6
Select the Copy layer from the Layers panel.
Select the Text Tool (T) from the toolbar. Create a text frame over the rectangle that extends over the first column.
Step 7
Add content to the frame and use the Paragraph Styles panel to style the text. Use the Tagline style for the first two lines—this is great for a catchphrase to attract customers.
Use the Copy style for the description under the tagline.
Step 8
While selecting the text frame, press Command-B to open the Text Frame Options window.Under Inset Spacing, set the Right option to 0.5 cm. Click OK.
Step 9
Using the Text Tool (T), create a one-column text frame under the image. This frame can extend all the way to the bottom margin.
Add content and use the Paragraph Styles panel to style the frame. Use the Headline and Copy styles. Select the copy and change the color on the Swatches panel to [Paper].
Press Command-B to open the Text Frame Options window. Under Inset Spacing, set the Left side to 0.5 cm.
Using the Rectangle Tool (M), create a rectangle that covers the text frame we created in this step. On the Swatches panel, set the color to Blue. Place this element on the Background layer.
Step 10
Select the Text Tool (T) from the toolbar. Create a square text frame that measures 1 cm on all sides.
Set the color of the frame to Blue on the Swatches panel.
Add a number to the frame and use the Paragraph Styles panel to style it. Select the Headline style and change the color to [Paper] on the Swatches panel.
Step 11
Head over to the Control bar and select the AlignCenter button.
While selecting the text frame, press Command-B to open the Text Frame Options window.Under Inset Spacing, add 0.5 cm to all sides.Click OK.
Step 12
Open the Text Wrap panel by going to Window > Text Wrap. On the panel, set the Offset to 0.3 cm on all sides.
Step 13
Duplicate the text frame by pressing Option and dragging. Change the numbers to „2” and „3”. Place the frames over the full-column frame created previously.
Step 14
Using the Text Tool (T), create a second text frame on the opposite column.
Use the Paragraph Styles panel to design the frame with the Headline and Copy styles.
Step 15
Open the Digital Marketing Iconsin Illustrator. Select three icons and copy/paste them onto the marketing flyer template in InDesign.
Resize the icons on the Control bar. Set the Percentage Scale to 20%.
Step 16
You’ll notice the colors don’t match our design. On the Swatches panel, select the cream color and click on the Delete button. In the Delete Swatch options window, select the Replacement to Defined Swatch. In the dropdown menu, select the [Paper} swatch. Click OK.
Select the RGB teal coloron the Swatches panel. Delete it and replace it with the Blue swatch.
Step 17
Place each icon at the top of each gutter on the last three rows.
Create a text frame with the Text Tool (T) for each icon/row. Add content and use the Paragraph Styles panel to style it. Use the Subheadline and Copy styles.
Step 18
Using the Line Tool (/), create a stroke between each text frame.
Open the Stroke panel by going to Window > Stroke. Set the Stroke Weight to 1 pt and the Type to Dotted.
On the Swatches panel, set the Stroke color to Blue.
3.How to Export an InDesign Flyer Template File for Printing
Before exporting a file for printing, it is useful to take a look around all the edges to make sure all the images and vectors bleeding out are touching the bleeds.
Step 1
To export the file, go to File > Export. Name the file „Marketing Flyer Template”and choose Adobe PDF (Print) from the Format dropdown menu. Click Save.
Step 2
In the Export Adobe PDF window, set the Adobe PDF Preset to Press Quality.
On the left side of the panel, select Marks and Bleeds. Check All Printer’s Marks and Use Document Bleed Settings. Click Export. You will have a ready-to-print PDF file.
Great Job! You’ve Finished Your Business Flyer!
In this tutorial, we learned how to make a flyer template. We covered key tools that will help anyone edit this template fast and easy. Today, we learned to:
set up a ready-to-print InDesign file
create layers to keep an organized file
add color swatches and replace colors
create Paragraph styles to style text frames
use the Text Frame options and Text Wrap tool on text frames
Promote your next business venture or current products with this super-easy tutorial that will help you attract more consumers. In this tutorial, I’ll show you how to make a flyer template.
Corporate business flyers are cost-effective advertising that you can use. Having an easy-to-use business flyer whose format you or your clients can quickly change is a huge advantage.
In this tutorial, I’ll show you how to make a flyer with the most essential tools. You’ll learn how to successfully set up a template with layers, Color Swatches, and Paragraph styles. These three components will make trouble-free business flyers that can be formatted in just minutes.
What You Will Need for Your InDesign Flyer Template
You’ll need access to Adobe InDesign and Adobe Illustrator. If you don’t have the software, you can download a trial from the Adobe website. You’ll also need:
Download the assets and make sure the font is installed on your system before starting. When you are ready, we can start designing the business flyer template!
1.Setting Up a Marketing Flyer Template InDesign File
Step 1
In InDesign, go to File > New. In the New Document window, select the Print Tab. Select the A4 preset and name the document „Marketing Flyer Template”. Change the settings to the following:
Width to 21 cm
Height to 29.7 cm
Orientation to Portrait
Units to Centimeters
Pages to 1
Uncheck Facing Pages
Margins to 1.27 cm
Bleeds to 0.3 cm (it’s best to seek your professional printer’s preference)
Click Create.
Step 2
For this open marketing flyer template, we will work with three Layers. Organizing layers is an important practice when designing a template as they will make it easier for the user to edit.
Bring up the Layers panel by going to Window > Layers. Double-click on Layer 1 and rename it Background.
In the Layers panel main menu, select New Layer. Name it Images. Click OK.
Additionally, create a new layer named Copy. Click OK.
Step 3
Head over to Window > Color > Swatches to expand the Swatches panel. Choose New Color Swatch from the main menu. Set the Swatch Name and values to the following:
Teal: C=60 M=0 Y=30 K=0
Dark Blue:C=100 M=80 Y=0 K=70
Click Add and OK after you input each color value.
Step 4
For this tutorial, we will create a list of Paragraph Styles that we will use to format the marketing flyer template.
Head over to Window > Styles > Paragraph Styles to open the Paragraph Styles panel. On the main menu, select New Paragraph Style and set the Style Name to Copy. Select the Basic Character Formats option from the left side menu. Use the following settings:
Font Family: RNS Sanz
Font Style: Normal
Size: 9 pt
Select the Character Color option from the left side menu. Set the color to the Blue swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Headline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 14 pt
Select the Character Color option from the left side menu. Set the color to the Teal swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Subheadline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 9 pt
Select the Character Color option from the left side menu. Set the color to the Teal swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Tagline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 18 pt
Select the Character Color option from the left side menu. Set the color to the Blue swatch. Click OK.
Step 5
Go to Layout > Create Guides. In the Create Guides option window, use the following settings:
2. How to Design a Marketing Flyer Template in InDesign
Step 1
Select the Background layer from the Layers panel.
Using the Rectangle Tool (M), create a rectangle that measures 15 cm in Width and 5 cm in Height.
On the Swatches panel, select the Blue swatch. Set the Tint to 10%.
Create a small text frame over the element and on the top right corner of the marketing flyer. Here, you can include contact information. Use the Paragraph Styles panel to format the frame into the Copy style. On the Control bar, select the Align Right button.
Step 2
Select the Images layer from the Layers panel.
Press Command-D to Place an image. Select the Social Media Logo EPS file and click Open.
Use the Selection Tool (V) to crop the frame to the preferred logo. Place the logo on the top left corner of the flyer design.
Step 3
Press Command-D to Place an image. Select the Female Asian Architect JPG file and click Open.
Place the image on the top guide of the first gutter.Use the Selection Tool (V) to crop the frame to the fourth row.
Use the Direct Selection Tool (A) to resize the image to 50%. Check for the Scale percentage on the Control bar.
Step 4
Select the Rectangle Tool (M) from the toolbar. Click on the document to open the Rectangle Option Window.
Create a rectangle that measures 10.55 cm in Width and 3.45 cm in Height. Click OK.
Step 5
On the Swatches panel, select the [Paper] swatch for the rectangle. Set the Opacity to 90%. Align the rectangle to the top left corner of the image.
Step 6
Select the Copy layer from the Layers panel.
Select the Text Tool (T) from the toolbar. Create a text frame over the rectangle that extends over the first column.
Step 7
Add content to the frame and use the Paragraph Styles panel to style the text. Use the Tagline style for the first two lines—this is great for a catchphrase to attract customers.
Use the Copy style for the description under the tagline.
Step 8
While selecting the text frame, press Command-B to open the Text Frame Options window.Under Inset Spacing, set the Right option to 0.5 cm. Click OK.
Step 9
Using the Text Tool (T), create a one-column text frame under the image. This frame can extend all the way to the bottom margin.
Add content and use the Paragraph Styles panel to style the frame. Use the Headline and Copy styles. Select the copy and change the color on the Swatches panel to [Paper].
Press Command-B to open the Text Frame Options window. Under Inset Spacing, set the Left side to 0.5 cm.
Using the Rectangle Tool (M), create a rectangle that covers the text frame we created in this step. On the Swatches panel, set the color to Blue. Place this element on the Background layer.
Step 10
Select the Text Tool (T) from the toolbar. Create a square text frame that measures 1 cm on all sides.
Set the color of the frame to Blue on the Swatches panel.
Add a number to the frame and use the Paragraph Styles panel to style it. Select the Headline style and change the color to [Paper] on the Swatches panel.
Step 11
Head over to the Control bar and select the AlignCenter button.
While selecting the text frame, press Command-B to open the Text Frame Options window.Under Inset Spacing, add 0.5 cm to all sides.Click OK.
Step 12
Open the Text Wrap panel by going to Window > Text Wrap. On the panel, set the Offset to 0.3 cm on all sides.
Step 13
Duplicate the text frame by pressing Option and dragging. Change the numbers to „2” and „3”. Place the frames over the full-column frame created previously.
Step 14
Using the Text Tool (T), create a second text frame on the opposite column.
Use the Paragraph Styles panel to design the frame with the Headline and Copy styles.
Step 15
Open the Digital Marketing Iconsin Illustrator. Select three icons and copy/paste them onto the marketing flyer template in InDesign.
Resize the icons on the Control bar. Set the Percentage Scale to 20%.
Step 16
You’ll notice the colors don’t match our design. On the Swatches panel, select the cream color and click on the Delete button. In the Delete Swatch options window, select the Replacement to Defined Swatch. In the dropdown menu, select the [Paper} swatch. Click OK.
Select the RGB teal coloron the Swatches panel. Delete it and replace it with the Blue swatch.
Step 17
Place each icon at the top of each gutter on the last three rows.
Create a text frame with the Text Tool (T) for each icon/row. Add content and use the Paragraph Styles panel to style it. Use the Subheadline and Copy styles.
Step 18
Using the Line Tool (/), create a stroke between each text frame.
Open the Stroke panel by going to Window > Stroke. Set the Stroke Weight to 1 pt and the Type to Dotted.
On the Swatches panel, set the Stroke color to Blue.
3.How to Export an InDesign Flyer Template File for Printing
Before exporting a file for printing, it is useful to take a look around all the edges to make sure all the images and vectors bleeding out are touching the bleeds.
Step 1
To export the file, go to File > Export. Name the file „Marketing Flyer Template”and choose Adobe PDF (Print) from the Format dropdown menu. Click Save.
Step 2
In the Export Adobe PDF window, set the Adobe PDF Preset to Press Quality.
On the left side of the panel, select Marks and Bleeds. Check All Printer’s Marks and Use Document Bleed Settings. Click Export. You will have a ready-to-print PDF file.
Great Job! You’ve Finished Your Business Flyer!
In this tutorial, we learned how to make a flyer template. We covered key tools that will help anyone edit this template fast and easy. Today, we learned to:
set up a ready-to-print InDesign file
create layers to keep an organized file
add color swatches and replace colors
create Paragraph styles to style text frames
use the Text Frame options and Text Wrap tool on text frames
Promote your next business venture or current products with this super-easy tutorial that will help you attract more consumers. In this tutorial, I’ll show you how to make a flyer template.
Corporate business flyers are cost-effective advertising that you can use. Having an easy-to-use business flyer whose format you or your clients can quickly change is a huge advantage.
In this tutorial, I’ll show you how to make a flyer with the most essential tools. You’ll learn how to successfully set up a template with layers, Color Swatches, and Paragraph styles. These three components will make trouble-free business flyers that can be formatted in just minutes.
What You Will Need for Your InDesign Flyer Template
You’ll need access to Adobe InDesign and Adobe Illustrator. If you don’t have the software, you can download a trial from the Adobe website. You’ll also need:
Download the assets and make sure the font is installed on your system before starting. When you are ready, we can start designing the business flyer template!
1.Setting Up a Marketing Flyer Template InDesign File
Step 1
In InDesign, go to File > New. In the New Document window, select the Print Tab. Select the A4 preset and name the document „Marketing Flyer Template”. Change the settings to the following:
Width to 21 cm
Height to 29.7 cm
Orientation to Portrait
Units to Centimeters
Pages to 1
Uncheck Facing Pages
Margins to 1.27 cm
Bleeds to 0.3 cm (it’s best to seek your professional printer’s preference)
Click Create.
Step 2
For this open marketing flyer template, we will work with three Layers. Organizing layers is an important practice when designing a template as they will make it easier for the user to edit.
Bring up the Layers panel by going to Window > Layers. Double-click on Layer 1 and rename it Background.
In the Layers panel main menu, select New Layer. Name it Images. Click OK.
Additionally, create a new layer named Copy. Click OK.
Step 3
Head over to Window > Color > Swatches to expand the Swatches panel. Choose New Color Swatch from the main menu. Set the Swatch Name and values to the following:
Teal: C=60 M=0 Y=30 K=0
Dark Blue:C=100 M=80 Y=0 K=70
Click Add and OK after you input each color value.
Step 4
For this tutorial, we will create a list of Paragraph Styles that we will use to format the marketing flyer template.
Head over to Window > Styles > Paragraph Styles to open the Paragraph Styles panel. On the main menu, select New Paragraph Style and set the Style Name to Copy. Select the Basic Character Formats option from the left side menu. Use the following settings:
Font Family: RNS Sanz
Font Style: Normal
Size: 9 pt
Select the Character Color option from the left side menu. Set the color to the Blue swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Headline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 14 pt
Select the Character Color option from the left side menu. Set the color to the Teal swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Subheadline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 9 pt
Select the Character Color option from the left side menu. Set the color to the Teal swatch. Click OK.
Create a New Paragraph Style, setting the Style Name to Tagline. Set the Basic Character Formats option to the following:
Font Family: RNS Sanz
Font Style: Extra Bold
Size: 18 pt
Select the Character Color option from the left side menu. Set the color to the Blue swatch. Click OK.
Step 5
Go to Layout > Create Guides. In the Create Guides option window, use the following settings:
2. How to Design a Marketing Flyer Template in InDesign
Step 1
Select the Background layer from the Layers panel.
Using the Rectangle Tool (M), create a rectangle that measures 15 cm in Width and 5 cm in Height.
On the Swatches panel, select the Blue swatch. Set the Tint to 10%.
Create a small text frame over the element and on the top right corner of the marketing flyer. Here, you can include contact information. Use the Paragraph Styles panel to format the frame into the Copy style. On the Control bar, select the Align Right button.
Step 2
Select the Images layer from the Layers panel.
Press Command-D to Place an image. Select the Social Media Logo EPS file and click Open.
Use the Selection Tool (V) to crop the frame to the preferred logo. Place the logo on the top left corner of the flyer design.
Step 3
Press Command-D to Place an image. Select the Female Asian Architect JPG file and click Open.
Place the image on the top guide of the first gutter.Use the Selection Tool (V) to crop the frame to the fourth row.
Use the Direct Selection Tool (A) to resize the image to 50%. Check for the Scale percentage on the Control bar.
Step 4
Select the Rectangle Tool (M) from the toolbar. Click on the document to open the Rectangle Option Window.
Create a rectangle that measures 10.55 cm in Width and 3.45 cm in Height. Click OK.
Step 5
On the Swatches panel, select the [Paper] swatch for the rectangle. Set the Opacity to 90%. Align the rectangle to the top left corner of the image.
Step 6
Select the Copy layer from the Layers panel.
Select the Text Tool (T) from the toolbar. Create a text frame over the rectangle that extends over the first column.
Step 7
Add content to the frame and use the Paragraph Styles panel to style the text. Use the Tagline style for the first two lines—this is great for a catchphrase to attract customers.
Use the Copy style for the description under the tagline.
Step 8
While selecting the text frame, press Command-B to open the Text Frame Options window.Under Inset Spacing, set the Right option to 0.5 cm. Click OK.
Step 9
Using the Text Tool (T), create a one-column text frame under the image. This frame can extend all the way to the bottom margin.
Add content and use the Paragraph Styles panel to style the frame. Use the Headline and Copy styles. Select the copy and change the color on the Swatches panel to [Paper].
Press Command-B to open the Text Frame Options window. Under Inset Spacing, set the Left side to 0.5 cm.
Using the Rectangle Tool (M), create a rectangle that covers the text frame we created in this step. On the Swatches panel, set the color to Blue. Place this element on the Background layer.
Step 10
Select the Text Tool (T) from the toolbar. Create a square text frame that measures 1 cm on all sides.
Set the color of the frame to Blue on the Swatches panel.
Add a number to the frame and use the Paragraph Styles panel to style it. Select the Headline style and change the color to [Paper] on the Swatches panel.
Step 11
Head over to the Control bar and select the AlignCenter button.
While selecting the text frame, press Command-B to open the Text Frame Options window.Under Inset Spacing, add 0.5 cm to all sides.Click OK.
Step 12
Open the Text Wrap panel by going to Window > Text Wrap. On the panel, set the Offset to 0.3 cm on all sides.
Step 13
Duplicate the text frame by pressing Option and dragging. Change the numbers to „2” and „3”. Place the frames over the full-column frame created previously.
Step 14
Using the Text Tool (T), create a second text frame on the opposite column.
Use the Paragraph Styles panel to design the frame with the Headline and Copy styles.
Step 15
Open the Digital Marketing Iconsin Illustrator. Select three icons and copy/paste them onto the marketing flyer template in InDesign.
Resize the icons on the Control bar. Set the Percentage Scale to 20%.
Step 16
You’ll notice the colors don’t match our design. On the Swatches panel, select the cream color and click on the Delete button. In the Delete Swatch options window, select the Replacement to Defined Swatch. In the dropdown menu, select the [Paper} swatch. Click OK.
Select the RGB teal coloron the Swatches panel. Delete it and replace it with the Blue swatch.
Step 17
Place each icon at the top of each gutter on the last three rows.
Create a text frame with the Text Tool (T) for each icon/row. Add content and use the Paragraph Styles panel to style it. Use the Subheadline and Copy styles.
Step 18
Using the Line Tool (/), create a stroke between each text frame.
Open the Stroke panel by going to Window > Stroke. Set the Stroke Weight to 1 pt and the Type to Dotted.
On the Swatches panel, set the Stroke color to Blue.
3.How to Export an InDesign Flyer Template File for Printing
Before exporting a file for printing, it is useful to take a look around all the edges to make sure all the images and vectors bleeding out are touching the bleeds.
Step 1
To export the file, go to File > Export. Name the file „Marketing Flyer Template”and choose Adobe PDF (Print) from the Format dropdown menu. Click Save.
Step 2
In the Export Adobe PDF window, set the Adobe PDF Preset to Press Quality.
On the left side of the panel, select Marks and Bleeds. Check All Printer’s Marks and Use Document Bleed Settings. Click Export. You will have a ready-to-print PDF file.
Great Job! You’ve Finished Your Business Flyer!
In this tutorial, we learned how to make a flyer template. We covered key tools that will help anyone edit this template fast and easy. Today, we learned to:
set up a ready-to-print InDesign file
create layers to keep an organized file
add color swatches and replace colors
create Paragraph styles to style text frames
use the Text Frame options and Text Wrap tool on text frames
Web design changes rapidly year on year. After all, many design elements are only added after the route and wireframe of a site has been built, so adjusting things like typography and images is technically a relatively easy process. That doesn’t diminish its importance however, as the visual aesthetic of any website is what will always get noticed first. Having a strong, unified brand look has never been more important; with so many fish in the sea, standing out is necessary if you want to be noticed.
The serif is back in town
One major shift in the last year has been away from sans-serif fonts. The ubiquitous Helvetica-inspired typography which seemed in use on every major site has suffered from oversaturation, and now many more classic serif fonts are popping up. Indeed, many websites are making their choice of font front and center of their design philosophy, and quirky takes on traditional serif favorites are growing in popularity.
Colour blocks and monochrome
Another trend growing in popularity is the increase in monochrome images, offset by colored blocks. It gives the impression of a serious and nuanced approach to imagery and provides an easy way to maintain a consistent visual brand without too much effort. It allows any blocks of color to stand out more as well, giving the option to highlight particular sections which would otherwise be lost in a riot of color.
Flexible design
The ever-increasing use of mobile devices and tablets has been driving a radical change in web design philosophy for several years now, and that shows no signs of abating. While it first manifested as a necessity to have all elements of a site able to switch readily between portrait and landscape, touchscreen and monitor, more recent changes have incorporated elements that will work easily on any sort of device. This has meant a trend towards simple, bold elements in a design, which are both eye-catching when viewed on a large screen, and easy to navigate when held in the hand. Designers are now looking towards more asymmetric designs, breaking from the traditional grid-based approach to have more organically laid-out elements. It’s a careful balancing act, but when designers get it right it’s both spectacular and intuitive.
New media
An increase in the use of other forms of media, from micro-animations to video, has also become the norm. This is down in part to the increased bandwidth allowances that many mobile devices now have; and with the forthcoming introduction of 5G networking, and the vast upgrade in data that will allow, having media-rich design elements will become more and more common. Embedded video, interactive forms, chatbots, and even sound will all become commonplace as users are able to send and receive more data, more quickly. More powerful devices and browsers will also mean more interactivity with sites, from animated navigation to built-in applications.
Maximum minimalism. Finding a way to combine all these elements without overcrowding the screen is a challenge for any designer, and some designers are now reacting to that by hugely reducing the elements they wish to display. Minimalism will always have a certain chic, and that’s definitely a current trend, with many sites displaying copious white space and minimal content; a brave decision in many ways, necessitating trust that the content you display will keep your users interested. Certainly, the year ahead provides exciting and difficult challenges for designers and web development agencies alike to integrate new technologies and an ever more competitive fight for a share of the audience.
Web design changes rapidly year on year. After all, many design elements are only added after the route and wireframe of a site has been built, so adjusting things like typography and images is technically a relatively easy process. That doesn’t diminish its importance however, as the visual aesthetic of any website is what will always get noticed first. Having a strong, unified brand look has never been more important; with so many fish in the sea, standing out is necessary if you want to be noticed.
The serif is back in town
One major shift in the last year has been away from sans-serif fonts. The ubiquitous Helvetica-inspired typography which seemed in use on every major site has suffered from oversaturation, and now many more classic serif fonts are popping up. Indeed, many websites are making their choice of font front and center of their design philosophy, and quirky takes on traditional serif favorites are growing in popularity.
Colour blocks and monochrome
Another trend growing in popularity is the increase in monochrome images, offset by colored blocks. It gives the impression of a serious and nuanced approach to imagery and provides an easy way to maintain a consistent visual brand without too much effort. It allows any blocks of color to stand out more as well, giving the option to highlight particular sections which would otherwise be lost in a riot of color.
Flexible design
The ever-increasing use of mobile devices and tablets has been driving a radical change in web design philosophy for several years now, and that shows no signs of abating. While it first manifested as a necessity to have all elements of a site able to switch readily between portrait and landscape, touchscreen and monitor, more recent changes have incorporated elements that will work easily on any sort of device. This has meant a trend towards simple, bold elements in a design, which are both eye-catching when viewed on a large screen, and easy to navigate when held in the hand. Designers are now looking towards more asymmetric designs, breaking from the traditional grid-based approach to have more organically laid-out elements. It’s a careful balancing act, but when designers get it right it’s both spectacular and intuitive.
New media
An increase in the use of other forms of media, from micro-animations to video, has also become the norm. This is down in part to the increased bandwidth allowances that many mobile devices now have; and with the forthcoming introduction of 5G networking, and the vast upgrade in data that will allow, having media-rich design elements will become more and more common. Embedded video, interactive forms, chatbots, and even sound will all become commonplace as users are able to send and receive more data, more quickly. More powerful devices and browsers will also mean more interactivity with sites, from animated navigation to built-in applications.
Maximum minimalism. Finding a way to combine all these elements without overcrowding the screen is a challenge for any designer, and some designers are now reacting to that by hugely reducing the elements they wish to display. Minimalism will always have a certain chic, and that’s definitely a current trend, with many sites displaying copious white space and minimal content; a brave decision in many ways, necessitating trust that the content you display will keep your users interested. Certainly, the year ahead provides exciting and difficult challenges for designers and web development agencies alike to integrate new technologies and an ever more competitive fight for a share of the audience.
I’m assuming most of you have already heard about Gatsby, and at least loosely know that it’s basically a static site generator for React sites. It generally runs like this:
Data Sources → Pull data from anywhere.
Build → Generate your website with React and GraphQL.
Deploy → Send the site to any static site host.
What this typically means is that you can get your data from any recognizable data source — CMS, markdown, file systems and databases, to name a few — manage the data through GraphQL to build your website, and finally deploy your website to any static web host (such as Netlify or Zeit).
The Gatsby homepage illustration of the Gatsby workflow.
In this article, we are concerned with the build process, which is powered by GraphQL. This is the part where your data is managed. Unlike traditional REST APIs where you often need to send anonymous data to test your endpoints, GraphQL consolidates your APIs into a self-documenting IDE. Using this IDE, you can perform GraphQL operations such as queries, mutations, and subscriptions, as well as view your GraphQL schema, and documentation.
GraphQL has an IDE built right into it, but what if we want something a little more powerful? That’s where GraphQL Playground comes in and we’re going to walk through the steps to switch from the default over to GraphQL Playground so that it works with Gatsby.
GraphiQL and GraphQL Playground
GraphiQL is GraphQL’s default IDE for exploring GraphQL operations, but you could switch to something else, like GraphQL Playground. Both have their advantages. For example, GraphQL Playground is essentially a wrapper over GraphiQL but includes additional features such as:
Interactive, multi-column schema documentation
Automatic schema reloading
Support for GraphQL Subscriptions
Query history
Configuration of HTTP headers
Tabs
Extensibility (themes, etc.)
Choosing either GraphQL Playground or GraphiQL most likely depends on whether you need to use those additional features. There’s no strict rule that will make you write better GraphQL operations, or build a better website or app.
This post isn’t meant to sway you toward one versus the other. We’re looking at GraphQL Playground in this post specifically because it’s not the default IDE and there may be use cases where you need the additional features it provides and needs to set things up to work with Gatsby. So, let’s dig in and set up a new Gatsby project from scratch. We’ll integrate GraphQL Playground and configure it for the project.
Setting up a Gatsby Project
To set up a new Gatsby project, we first need to install the gatsby-cli. This will give us Gatsby-specific commands we can use in the Terminal.
npm install -g gatsby-cli
Now, let’s set up a new site. I’ve decided to call this example „gatsby-playground” but you can name it whatever you’d like.
gatsby new gatsby-playground
Let’s navigate to the directory where it was installed.
cd gatsby-playground
And, finally, flip on our development server.
gatsby develop
Head over to http://localhost:8000 in the browser for the opening page of the project. Your Gatsby GraphQL operations are going to be located at http://localhost:8000/___graphql.
The GraphiQL interface.
At this point, I think it’s worth calling out that there is a desktop app for GraphQL Playground. You could just access your Gatsby GraphQL operations with the URL Endpoint localhost:8000/___graphql without going any further with this article. But, we want to get our hands dirty and have some fun under the hood!
Since we’re not going to be relying on the desktop app, we’ll need to do a little bit of Environmental Variable setup.
Environmental Variables are variables used specifically to customize the behavior of a website in different environments. These environments could be when the website is in active development, or perhaps when it is live in production and available for the world to see. We can have as many environments as we want, and define different Environmental Variables for each of the environments.
Gatsby supports two environments: development and production. To set a development environmental variable, we need to have a .env.development file at the root of the project. Same sort of deal for production, but it’s .env.production.
To swap out both environments, we’ll need to set an environment variable in a cross-platform compatible way. Let’s create a .env.development file at the root of the project. Here, we set a key/value pair for our variables. The key will be GATSBY_GRAPHQL_IDE, and the value will be playground, like so:
GATSBY_GRAPHQL_IDE=playground
Accessing Environment Variables in JavaScript
In Gatsby, our Environmental Variables are only available at build time, or when Node.JS is running (what we’ll call run time). Since the variables are loaded client-side at build time, we need to use them dynamically at run time. It is important that we restart our server or rebuild our website every time we modify any of these variables.
To load our environmental variables into our project, we need to install a package:
And that’s it! But, hey, remember to restart the server since we change the variable.
yarn start // npm run develop
If you refresh the http://localhost:8000/___graphql in the browser, you should now see GraphQL playground. Cool? Cool!
GraphQL Playground with Gatsby.
And that’s how we get GraphQL Playground to work with Gatsby!
So that’s how we get from GraphQL’s default GraphiQL IDE to GraphQL Playground. Like we covered earlier, the decision of whether or not to make the switch at all comes down to whether the additional features offered in GraphQL Playground are required for your project. Again, we’re basically working with a GraphiQL wrapper that piles on more features.
Resources
Here are some additional articles around the web to get you started with Gatsby and more familiar with GraphiQL, GraphQL Playground, and Environment Variables.
I recently drew up a wireframe for a code beautifier. The next day, I decided to turn it into a real tool. The whole project took less than two days to complete.
I’d been thinking about building a new code beautifier for a while. The idea isn’t unique, but every time I use someone else’s tool, I find myself reapplying the same settings and dodging advertisements every single time. 🤦🏻
I wanted a simple tool that worked well without the hassle, so last week I grabbed some paper and started sketching one out. I’m a huge fan of wireframing by hand. There’s just something about pencil and paper that makes the design part of my brain work better than staring at a screen.
I kicked off the design process by hand-drawing wireframes for the app.
I was immediately inspired after drawing the wireframe. The next day, I took a break from my usual routine to turn it into a something real. 👨🏻💻
I knew I wanted the code editor to be the main focus of the tool, so I created a thin menu bar at the top that controls the mode (i.e. HTML, CSS, JavaScript) and settings. I eventually added an About button too.
The editor itself takes up most of the screen, but it blends in so you don’t really notice it. Instead of wasting space with instructions, I used a placeholder that disappears when you start typing.
The Dark Mode UI is based on a toggle that updates the styles.
At the bottom, I created a status bar that shows live stats about the code including the current mode, indentation settings, number of lines, number of characters, and document size in bytes. The right side of the status bar has a „Clear” and „Clean + Copy” button. The center has a logo shamelessly plugging my own service.
I don’t think many developers really code on phones, but I wanted this to work on mobile devices anyway. Aside from the usual responsive techniques, I had to watch the window size and adjust the tab position when the screen becomes too narrow.
I’m using flexbox and viewport units for vertical sizing. This was actually pretty easy to do with the exception of a little iOS quirk. Here’s a pen showing the basic wireframe. Notice how the textarea stretches to fill the unused space between the header and footer.
If you look at the JavaScript tab, you’ll see the iOS quirk and the workaround. I’m not sure how to feature detect something like this, so for now it’s just a simple device check.
Handling settings
I wanted to keep the most commonly used settings easy to access, but also expose advanced settings for each mode. To do this, I made the settings button a popover with a link to more advanced settings inside. When a setting is changed, the UI updates immediately and the settings are persisted to localStorage.
The most common settings are contained in a small panel that provides quick access to them, while advanced settings are still accessible via a link in the panel.
I took advantage of Vue.js here. Each setting gets mapped to a data property, and when one of them changes, the UI updates (if required) and I call saveSettings(). It works something like this.
function saveSettings() {
const settings = {};
// settingsToStore is an array of property names that will be persisted
// and "this" is referencing the current Vue model
settingsToStore.map(key => settings[key] = this[key]);
localStorage.setItem('settings', JSON.stringify(settings);
}
Every setting is a data property that gets synced to localStorage. This is a rather primitive way to store state, so I might update the app to use a state management library such as Vuex later on.
To restore settings, I have a restoreSettings() function that runs when the app starts up.
function restoreSettings() {
const json = localStorage.getItem('settings');
if (json) {
try {
const settings = JSON.parse(json);
Object.keys(settings).forEach(key => {
if (settingsToStore.includes(key)) {
this[key] = settings[key];
}
});
} catch (err) {
window.alert('There was an error loading your previous settings');
}
}
}
The function fetches settings from localStorage, then applies them one by one ensuring only valid settings in settingsToStore get imported.
The Advanced Settings link opens a dialog with tabs for each mode. Despite having over 30 settings total, everything is organized and easy to access so users won’t feel overwhelmed.
Clicking the „Advanced Settings” link opens up language-specific preferences and shortcuts.
Applying themes
Dark mode is all the rage these days, so it’s enabled by default. There’s also a light theme for those who prefer it. The entire UI changes, except for popovers and dialogs.
I considered using prefers-color-scheme, which coincidentally landed in Firefox 67 recently, but I decided a toggle would probably be better. Browser support for the color theme preference query isn’t that great yet, plus developers are weird. (For example, I use macOS with the light theme, but my text editor is dark.)
The app with Light Mode UI enabled.
Defining features
Coming up with feature ideas is fairly easy. It’s limiting features for an initial release that’s hard. Here are the most relevant features I shipped right away:
Beautifies HTML, CSS, and JavaScript code
Syntax highlighting with tag/bracket matching
Paste or drop files to load code
Auto-detects indentation preference based on pasted code or dropped file
Light and dark themes
Clean and copy in one click
Keyboard shortcuts
Most JS Beautify options are configurable
Settings get stored indefinitely in localStorage
Minimal UI without ads (just an unobtrusive plug to my own service) 🙈
I also threw in a few easter eggs for fun. Try refreshing the page, exploring shortcuts, and sharing it on Facebook or Twitter to find them. 😉
The tools and libraries I used
I’m a big fan of Vue.js. It’s probably overkill for this project, but the Vue CLI let me start building with all the latest tooling via one simple command.
vue create beautify-code
I didn’t have to waste any time scaffolding, which helped me build this out quickly. Plus, Vue came in handy for things like live stats, changing themes, toggling settings, etc. I used various Element UI components for things like buttons, form elements, popovers, and dialogs.
The editor is powered by CodeMirror using custom styles. It’s a well-supported and fantastic project that I can’t recommend enough for in-browser code editing.
The library that does all the beautifying is called JS Beautify, which handles JavaScript, HTML, and CSS. JS Beautify runs on the client-side, so there’s really no backend to this app — your browser does all the work!
JS Beautify is incredibly easy to use. Install it with npm install js-beautify and run your code through the appropriate function.
import beautify from 'js-beautify';
const code = 'Your code here';
const settings = {
// Your settings here
};
// HTML
const html = beautify.html(code, settings)
// CSS
const css = beautify.css(code, settings)
// JavaScript
const js = beautify.js(code, settings)
Each function returns a string containing the beautified code. You can change how each language is output by passing in your own settings.
I’ve been asked a few times about Prettier, which is a comparable tool, so it’s worth mentioning that I chose JS Beautify because it’s less opinionated and more configurable. If there’s enough demand, I’ll consider adding an option to toggle between JS Beautify and Prettier.
I’ve used all of these libraries before, so integration was actually pretty easy. 😅
This project was made possible by my app, Surreal CMS. If you’re looking for a great CMS for static websites, check it out — it’s free for personal, educational, and non-profit websites!
Oh, and if you’re wondering what editor I used… it’s Visual Studio Code. 👨🏻💻