Should I Use Source Maps in Production?

Post pobrano z: Should I Use Source Maps in Production?

It’s a valid question. A „source map” is a special file that connects a minified/uglified version of an asset (CSS or JavaScript) to the original authored version. Say you’ve got a filed called _header.scss that gets imported into global.scss which is compiled to global.css. That final CSS file is what gets loaded in the browser, so for example, when you inspect an element in DevTools, it might tell you that the <nav> is display: flex; because it says so on line 387 in global.css.

On line 528 of page.css</, we can find out that <code>.meta has position: relative;

But because that final CSS file is probably minified (all whitespace removed), DevTools is likely to tell us that we’ll find the declaration we’re looking for on line 1! Unfortunate, and not helpful for development.

That’s where source maps come in. Like I said up top, source maps are special files that connect that final output file the browser is actually using with the authored files that you actually work with and write code in on your file system.

Typically, source maps are a configuration option from the preprocessor. Here’s Babel’s options. I believe that with Sass, you don’t even have to pass a flag for it in the command or anything because it produces source maps by default.

So, these source maps are for developers. They are particularly useful for you and your team because they help tremendously for debugging issues as well as day-to-day work. I’m sure I make use of them just about every day. I’d say in general, they are used for local development. You might even .gitignore them or skip them in a deployment process in order to serve and store fewer assets to production. But there’s been some recent chatter about making sure they go to production as well.

David Heinemeier Hansson:

But source maps have long been seen merely as a local development tool. Not something you ship to production, although people have also been doing that, such that live debugging would be easier. That in itself is a great reason to ship source maps. […]

Additional, Rails 6 just committed to shipping source maps by default in production, also thanks to Webpack. You’ll be able to turn that feature off, but I hope you won’t. The web is a better place when we allow others to learn from our work.

Check out that issue thread for more interesting conversation about shipping source maps to production. The benefits boil down to these two things:

  1. It might help you track down bugs in production more easily
  2. It helps other people learn from your website more easily

Both are cool. Personally, I’d be opposed to shipping performance-optimized code for learning purposes alone. I wrote about that last year:

I don’t want my source to be human-readable, not for protective reasons, but because I care about web performance more. I want my website to arrive at light speed on a tiny spec of magical network packet dust and blossom into a complete website. Or do whatever computer science deems is the absolute fastest way to send website data between computers. I’m much more worried about the state of web performance than I am about web education. But even if I was very worried about web education, I don’t think it’s the network’s job to deliver teachability.

Shipping source maps to production is a nice middle ground. There’s no hit on performance (source maps don’t get loaded unless you have DevTools open, which is, IMO, irrelevant to a real performance discussion) with the benefit of delivering debugging and learning benefits.

The downsides brought up in recent discussion boil down to:

  1. Sourcemaps require compilation time
  2. It allows people to, I dunno, steal your code or something

I don’t care about #2 (sorry), and #1 seems generally negligible for a small or what we think of as the average site, though I’m afraid I can’t speak for mega sites.

One thing I should add though is that source maps can even be generated for CSS-in-JS tooling, so for those that literally inject styles into the DOM for you, those source maps are injected as well. I’ve seen major slowdowns in those situations, so I would say definitely do not ship source maps to production if you can’t split them out of your main bundles. Otherwise, I’d vote strongly that you do.

The post Should I Use Source Maps in Production? appeared first on CSS-Tricks.

Writing Tests for React Applications Using Jest and Enzyme

Post pobrano z: Writing Tests for React Applications Using Jest and Enzyme

While it is important to have a well-tested API, solid test coverage is a must for any React application. Tests increase confidence in the code and helps prevent shipping bugs to users.

That’s why we’re going to focus on testing in this post, specifically for React applications. By the end, you’ll be up and running with tests using Jest and Enzyme.

No worries if those names mean nothing to you because that’s where we’re headed right now!

Installing the test dependencies

Jest is a unit testing framework that makes testing React applications pretty darn easy because it works seamlessly with React (because, well, the Facebook team made it, though it is compatible with other JavaScript frameworks). It serves as a test runner that includes an entire library of predefined tests with the ability to mock functions as well.

Enzyme is designed to test components and it’s a great way to write assertions (or scenarios) that simulate actions that confirm the front-end UI is working correctly. In other words, it seeks out components on the front end, interacts with them, and raises a flag if any of the components aren’t working the way it’s told they should.

So, Jest and Enzyme are distinct tools, but they complement each other well.

For our purposes, we will spin up a new React project using create-react-app because it comes with Jest configured right out of the box.

yarn create react-app my-app

We still need to install enzyme and enzyme-adapter-react-16 (that number should be based on whichever version of React version you’re using).

yarn add enzyme enzyme-adapter-react-16 --dev

OK, that creates our project and gets us both Jest and Enzyme in our project in two commands. Next, we need to create a setup file for our tests. We’ll call this file setupTests.js and place it in the src folder of the project.

Here’s what should be in that file:

import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });

This brings in Enzyme and sets up the adapter for running our tests.

To make things easier on us, we are going to write tests for a React application I have already built. Grab a copy of the app over on GitHub.

Taking snapshots of tests

Snapshot testing is used to keep track of changes in the app UI. If you’re wonder whether we’re dealing with literal images of the UI, the answer is no, but snapshots are super useful because they capture the code of a component at a moment in time so we can compare the component in one state versus any other possible states it might take.

The first time a test runs, a snapshot of the component code is composed and saved in a new __snapshots__ folder in the src directory. On test runs, the current UI is compared to the existing. Here’s a snapshot of a successful test of the sample project’s App component.

it("renders correctly", () => {
  const wrapper = shallow(
    <App />
  );
  expect(wrapper).toMatchSnapshot();
});

Every new snapshot that gets generated when the test suite runs will be saved in the __tests__ folder. What’s great about that Jest will check to see if the component matches is then on subsequent times when we run the test, Jest will check to see if the component matches the snapshot on subsequent tests. Here’s how that files looks.

Let’s create a conditions where the test fails. We’ll change the <h2> tag of our component from <h2>Random User</h2> to <h2>CSSTricks Tests</h2> and here’s what we get in the command line when the tests run:

If we want our change to pass the test, we either change the heading to what it was before, or we can update the snapshot file. Jest even provides instructions for how to update the snapshot right from the command line so there’s no need to update the snapshot manually:

Inspect your code changes or press `u` to update them.

So, that’s what we’ll do in this case. We press u to update the snapshot, the test passes, and we move on.

Did you catch the shallow method in our test snapshot? That’s from the Enzyme package and instructs the test to run a single component and nothing else — not even any child components that might be inside it. It’s a nice clean way to isolate code and get better information when debugging and is especially great for simple, non-interactive components.

In addition to shallow, we also have render for snapshot testing. What’s the difference, you ask? While shallow excludes child components when testing a component, render includes them while rendering to static HTML.

There is one more method in the mix to be aware of: mount. This is the most engaging type of test in the bunch because it fully renders components (like shallow and render) and their children (like render) but puts them in the DOM, which means it can fully test any component that interacts with the DOM API as well as any props that are passed to and from it. It’s a comprehensive test for interactivity. It’s also worth noting that, since it does a full mount, we’ll want to make a call to .unmount on the component after the test runs so it doesn’t conflict with other tests.

Testing Component’s Lifecycle Methods

Lifecycle methods are hooks provided by React, which get called at different stages of a component’s lifespan. These methods come in handy when handling things like API calls.
Since they are often used in React components, you can have your test suite cover them to ensure all things work as expected.

We do the fetching of data from the API when the component mounts. We can check if the lifecycle method gets called by making use of jest, which makes it possible for us to mock lifecycle methods used in React applications.

it('calls componentDidMount', () => {
  jest.spyOn(App.prototype, 'componentDidMount')
  const wrapper = shallow(<App />)
  expect(App.prototype.componentDidMount.mock.calls.length).toBe(1)
})

We attach spy to the component’s prototype, and the spy on the componentDidMount() lifecycle method of the component. Next, we assert that the lifecycle method is called once by checking for the call length.

Testing component props

How can you be sure that props from one component are being passed to another? We have a test confirm it, of course! The Enzyme API allows us to create a “mock” function so tests can simulate props being passed between components.

Let’s say we are passing user props from the main App component into a Profile component. In other words, we want the App to inform the Profile with details about user information to render a profile for that user.

First, let’s mock the user props:

const user = {
  name: 'John Doe',
  email: 'johndoe@gmail.com',
  username: 'johndoe',
  image: null
}

Mock functions look a lot like other tests in that they’re wrapped around the components. However, we’re using an additional describe layer that takes the component being tested, then allows us to proceed by telling the test the expected props and values that we expect to be passed.

describe ('<Profile />', () => {
  it ('contains h4', () => {
    const wrapper = mount(<Profile user={user} />)
    const value = wrapper.find('h4').text()
    expect(value).toEqual('John Doe')
  })
  it ('accepts user props', () => {
    const wrapper = mount(<Profile user={user} />);
    expect(wrapper.props().user).toEqual(user)
  })
})

This particular example contains two tests. In the first test, we pass the user props to the mounted Profile component. Then, we check to see if we can find a <h4> element that corresponds to what we have in the Profile component.

In the second test, we want to check if the props we passed to the mounted component equals the mock props we created above. Note that even though we are destructing the props in the Profile component, it does not affect the test.

Mock API calls

There’s a part in the project we’ve been using where an API call is made to fetch a list of users. And guess what? We can test that API call, too!

The slightly tricky thing about testing API calls is that we don’t actually want to hit the API. Some APIs have call limits or even costs for making making calls, so we want to avoid that. Thankfully, we can use Jest to mock axios requests. See this post for a more thorough walkthrough of using axios to make API calls.

First, we’ll create a new folder called __mock__ in the same directory where our __tests__ folder lives. This is where our mock request files will be created when the tests run.

module.exports = {
  get: jest.fn(() => {
    return Promise.resolve({
    data: [
      {
        id: 1,
        name: 'Jane Doe',
        email: 'janedoe@gmail.com',
        username: 'jdoe'
      }
    ]
    })
  })
}

We want to check and see that the GET request is made. We’ll import axios for that:

import axios from 'axios';

Just below the import statements, we need Jest to replace axios with our mock, so we add this:

jest.mock('axios')

The Jest API has a spyOn() method that takes an accessType? argument that can be used to check whether we are able to “get” data from an API call. We use jest.spyOn() to call the spied method, which we implemented in our __mock__ file, and it can be used with the shallow, render and mount tests we covered earlier.

it('fetches a list of users', () => {
  const getSpy = jest.spyOn(axios, 'get')
  const wrapper = shallow(
    <App />
  )
  expect(getSpy).toBeCalled()
})

We passed the test!

That’s a primer into the world of testing in a React application. Hopefully you now see the value that testing adds to a project and how relatively easy it can be to implement, thanks to the heavy lifting done by the joint powers of Jest and Enzyme.

Further reading

How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Post pobrano z: How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Final product image
What You’ll Be Creating

In this tutorial, I’ll show you how to create your own denim texture using filters in Adobe Photoshop and then how to create an action for the stitched jeans text effect.

This action is based on Stitched Leather and Jeans Actions from Envato Market.
These actions transform any text or shape into a stitched leather or jeans type.

Leather and jeans actions

Tutorial Assets

The following assets were used during this Photoshop action tutorial:

1. How to Create a Denim Texture

First of all, I’ll show you how you can create your own denim texture using Photoshop filters. If you prefer, you can skip these steps and download the denim texture from the tutorial assets.

Step 1

Start Adobe Photoshop and open a new document (Control-N) with 1024 x 1024 px and a resolution of 72 DPI. Then go to Filter > Filter Gallery… and select Halftone Pattern from the Sketch folder and use these settings:

  • Size: 2
  • Contrast: 20
  • Pattern Type: Dot

Hit OK.

Add halftone pattern

Step 2

Go to Filter > Pixelate > Mezzotint…, set Type to Fine Dots, and hit OK. Then go to Filter > Blur > Motion Blur…, and set the Angle to -45° and the Distance to 20 px. Hit OK.

Add mezzotint and blur

Step 3

Go to Filter > Noise > Add Noise, and set the Amount to 10% and Distribution to Gaussian. Check the Monochromatic box and hit OK. Then go to Filter > Blur > Gaussian Blur, set the Radius to 0.5 px, and hit OK.

Add noise and blur

Step 4

Go to Layer > New Adjustment Layer > Levels and set Inputs to 210.52199 and Outputs to 53163. Then select the Background layer and go to Edit > Define Pattern, change the name to denim-texture, and hit OK.

Done. You have just created your own denim texture which we will use in our Photoshop action. We could finish it with a blue color overlay, but I like to leave it in shades of gray, which lets you change the texture to any color later.

Add levels

2. How to Set the Background and Add Text

For this Photoshop action, I chose the wood planks background, which you can get from the tutorial assets, but it is not mandatory for the action to work.

Step 1

Open the wood planks image (Control-O). Then hit Control-Alt-I, change the Resolution to 72 Pixels/Inch and the Width to 850 px, and hit OK.

Set the background

Step 2

Take your Type tool (T), change the font to Varsity Team Bold, and set the Size to 450 pt. Then write „JB” on your artboard.

Type the text

3. How to Start Recording a Photoshop Action

Now we are going to start recording a Photoshop action. It’s important to follow the steps in order and to avoid unnecessary mouse clicks and keystrokes.

Step 1

Hit Alt-F9 to open your Actions panel. At the bottom of this panel, hit the Create new set icon, name it Jeans Action, and hit OK. Then hit the Create new action icon next to it and name it Start. Now hit the Record button and start recording the Photoshop action.

Start recording an action

Step 2

To start off our Photoshop action, right-click on the JB layer in your Layers panel and select Duplicate Layer, name it jeans-base, and hit OK. Then right-click on the jeans-base layer and select Duplicate Layer again, name it jeans-rim, and hit OK.

Duplicate layers

4. How to Create and Style the Jeans Rim

Step 1

Right-click on the jeans-rim layer and select Blending Options. Then set the Fill Opacity to 0%.

Add blending options

Step 2

Add a Stroke with Size of 16 px, set the Position to Outside, and hit OK. Then right-click the jeans-rim layer and select Convert to Smart Object.

Add a stroke

Step 3

Right-click on the jeans-rim layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 888%
  • Direction: Down
  • Size: 2 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 135°
  • Altitude: 30°
  • Highlight Mode: Linear Burn with color #000000
  • Highlight Mode – Opacity: 27%
  • Highlight Mode: Color Dodge with color #ffffff
  • Shadow Mode – Opacity: 44%
Add a bevel and emboss

Step 4

Add a Texture for the Bevel and Emboss with these settings:

  • Pattern: denim-texture (the one you have created before)
  • Scale: 50%
  • Depth: 95%
Add a texture

Step 5

Add an Inner Shadow with these settings:

  • Color: #6b6b6b
  • Uncheck the Use Global Light box
  • Angle: -45°
  • Distance: 6 px
  • Choke: 45%
  • Size: 5 px
  • Check the Anti-aliased box
Add an inner shadow

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 80%
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Distance: 2 px
  • Spread: 0%
  • Size: 3 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

This is the result of the text effect applied to our Photoshop action.

Partial result

5. How to Create and Style the Jeans Main Layer

Step 1

Select the jeans-base layer in your Layers panel. Right-click on it and select Blending Options. Now add a Stroke with Size of 15 px, change Position to Outside, and hit OK. Then right-click this layer again and select Convert to Smart Object.

Add a stroke

Step 2

Right-click on the jeans-base layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 100%
  • Direction: Up
  • Size: 49 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 180°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Color Dodge with color #ffffff
  • Highlight Mode – Opacity: 30%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 13%
Add a bevel and emboss

Step 3

Add an Inner Shadow with these settings:

  • Blend Mode: Multiply
  • Color: #7a7a7a
  • Uncheck the Use Global Light box
  • Angle: 132°
  • Distance: 0 px
  • Choke: 18%
  • Size: 35 px
  • Check the Anti-aliased box
Add an inner shadow

Step 4

Add an Inner Glow with these settings:

  • Blend Mode: Linear Burn
  • Opacity: 24%
  • Color: #6a6a6a
  • Technique: Softer
  • Source: Edge
  • Choke: 60%
  • Size: 38 px
  • Check the Anti-aliased box
Add an inner glow

Step 5

Add a Satin style with these settings:

  • Blend Mode: Linear Burn
  • Color: #000000
  • Opacity: 13%
  • Angle:
  • Distance: 45 px
  • Size: 46 px
  • Check the Anti-aliased box
  • Check the Invert box
Add a satin

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 36%
  • Uncheck the Use Global Light box
  • Angle: 105°
  • Distance: 9 px
  • Spread: 11%
  • Size: 8 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

And this is the result of the text effect applied to our Photoshop action.

Partial result

6. How to Add and Style the Jeans Stitch

We are almost done with our Photoshop action. The last thing we need to add is a cool stitch to this text effect. So let’s do it.

Step 1

Create a new layer by going to Layer > New > Layer and name it stitch. Then Controlclick the jeans-base layer to make a selection. Go to Select > Modify > Contract, set the value to 24 px, and hit OK. Finally, go to your Paths panel and click the Make work path from selection icon at the bottom.

Create a work path

Step 2

Select your Brush Tool (B) and select jeans-stitch from the tutorial assets as your brush. Then right-click on the Work Path layer in Paths panel and select Stroke Path…, choose Brush as your tool, and hit OK. Lastly, hit Delete to delete the work path layer.

Stroke the path

Step 3

Right-click on the stitch layer and select Blending Options. Then add a Bevel and Emboss with these settings:

  • Style: Pillow Emboss
  • Technique: Smooth
  • Depth: 200%
  • Direction: Up
  • Size: 9 px
  • Soften: 5 px
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Linear Dodge (Add) with color #ffffff
  • Highlight Mode – Opacity: 24%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 18%
Add a bevel and emboss

Step 4

Add a Color Overlay and choose the color #d19f5f. Then hit OK to apply the text effect. Now go back to your Actions panel and hit the Stop button at the bottom to stop recording this Photoshop action.

Add a color overlay

Congratulations! You’re Done!

In this tutorial, you learned how to create a Photoshop action for a jeans text effect and also how to create your own denim texture using Photoshop filters.

We started by creating the main denim texture, and then we recorded an action for the jeans text effect using layer styles and a stitch brush.

Final result

I hope you have enjoyed this Photoshop action tutorial. Please feel free to leave your
comments, suggestions, and outcomes below. The text effect action we just
created is based on Stitched Leather and Jeans Actions.

Leather and jeans actions

Looking for more? I recommend the following tutorials:

How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Post pobrano z: How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Final product image
What You’ll Be Creating

In this tutorial, I’ll show you how to create your own denim texture using filters in Adobe Photoshop and then how to create an action for the stitched jeans text effect.

This action is based on Stitched Leather and Jeans Actions from Envato Market.
These actions transform any text or shape into a stitched leather or jeans type.

Leather and jeans actions

Tutorial Assets

The following assets were used during this Photoshop action tutorial:

1. How to Create a Denim Texture

First of all, I’ll show you how you can create your own denim texture using Photoshop filters. If you prefer, you can skip these steps and download the denim texture from the tutorial assets.

Step 1

Start Adobe Photoshop and open a new document (Control-N) with 1024 x 1024 px and a resolution of 72 DPI. Then go to Filter > Filter Gallery… and select Halftone Pattern from the Sketch folder and use these settings:

  • Size: 2
  • Contrast: 20
  • Pattern Type: Dot

Hit OK.

Add halftone pattern

Step 2

Go to Filter > Pixelate > Mezzotint…, set Type to Fine Dots, and hit OK. Then go to Filter > Blur > Motion Blur…, and set the Angle to -45° and the Distance to 20 px. Hit OK.

Add mezzotint and blur

Step 3

Go to Filter > Noise > Add Noise, and set the Amount to 10% and Distribution to Gaussian. Check the Monochromatic box and hit OK. Then go to Filter > Blur > Gaussian Blur, set the Radius to 0.5 px, and hit OK.

Add noise and blur

Step 4

Go to Layer > New Adjustment Layer > Levels and set Inputs to 210.52199 and Outputs to 53163. Then select the Background layer and go to Edit > Define Pattern, change the name to denim-texture, and hit OK.

Done. You have just created your own denim texture which we will use in our Photoshop action. We could finish it with a blue color overlay, but I like to leave it in shades of gray, which lets you change the texture to any color later.

Add levels

2. How to Set the Background and Add Text

For this Photoshop action, I chose the wood planks background, which you can get from the tutorial assets, but it is not mandatory for the action to work.

Step 1

Open the wood planks image (Control-O). Then hit Control-Alt-I, change the Resolution to 72 Pixels/Inch and the Width to 850 px, and hit OK.

Set the background

Step 2

Take your Type tool (T), change the font to Varsity Team Bold, and set the Size to 450 pt. Then write „JB” on your artboard.

Type the text

3. How to Start Recording a Photoshop Action

Now we are going to start recording a Photoshop action. It’s important to follow the steps in order and to avoid unnecessary mouse clicks and keystrokes.

Step 1

Hit Alt-F9 to open your Actions panel. At the bottom of this panel, hit the Create new set icon, name it Jeans Action, and hit OK. Then hit the Create new action icon next to it and name it Start. Now hit the Record button and start recording the Photoshop action.

Start recording an action

Step 2

To start off our Photoshop action, right-click on the JB layer in your Layers panel and select Duplicate Layer, name it jeans-base, and hit OK. Then right-click on the jeans-base layer and select Duplicate Layer again, name it jeans-rim, and hit OK.

Duplicate layers

4. How to Create and Style the Jeans Rim

Step 1

Right-click on the jeans-rim layer and select Blending Options. Then set the Fill Opacity to 0%.

Add blending options

Step 2

Add a Stroke with Size of 16 px, set the Position to Outside, and hit OK. Then right-click the jeans-rim layer and select Convert to Smart Object.

Add a stroke

Step 3

Right-click on the jeans-rim layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 888%
  • Direction: Down
  • Size: 2 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 135°
  • Altitude: 30°
  • Highlight Mode: Linear Burn with color #000000
  • Highlight Mode – Opacity: 27%
  • Highlight Mode: Color Dodge with color #ffffff
  • Shadow Mode – Opacity: 44%
Add a bevel and emboss

Step 4

Add a Texture for the Bevel and Emboss with these settings:

  • Pattern: denim-texture (the one you have created before)
  • Scale: 50%
  • Depth: 95%
Add a texture

Step 5

Add an Inner Shadow with these settings:

  • Color: #6b6b6b
  • Uncheck the Use Global Light box
  • Angle: -45°
  • Distance: 6 px
  • Choke: 45%
  • Size: 5 px
  • Check the Anti-aliased box
Add an inner shadow

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 80%
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Distance: 2 px
  • Spread: 0%
  • Size: 3 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

This is the result of the text effect applied to our Photoshop action.

Partial result

5. How to Create and Style the Jeans Main Layer

Step 1

Select the jeans-base layer in your Layers panel. Right-click on it and select Blending Options. Now add a Stroke with Size of 15 px, change Position to Outside, and hit OK. Then right-click this layer again and select Convert to Smart Object.

Add a stroke

Step 2

Right-click on the jeans-base layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 100%
  • Direction: Up
  • Size: 49 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 180°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Color Dodge with color #ffffff
  • Highlight Mode – Opacity: 30%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 13%
Add a bevel and emboss

Step 3

Add an Inner Shadow with these settings:

  • Blend Mode: Multiply
  • Color: #7a7a7a
  • Uncheck the Use Global Light box
  • Angle: 132°
  • Distance: 0 px
  • Choke: 18%
  • Size: 35 px
  • Check the Anti-aliased box
Add an inner shadow

Step 4

Add an Inner Glow with these settings:

  • Blend Mode: Linear Burn
  • Opacity: 24%
  • Color: #6a6a6a
  • Technique: Softer
  • Source: Edge
  • Choke: 60%
  • Size: 38 px
  • Check the Anti-aliased box
Add an inner glow

Step 5

Add a Satin style with these settings:

  • Blend Mode: Linear Burn
  • Color: #000000
  • Opacity: 13%
  • Angle:
  • Distance: 45 px
  • Size: 46 px
  • Check the Anti-aliased box
  • Check the Invert box
Add a satin

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 36%
  • Uncheck the Use Global Light box
  • Angle: 105°
  • Distance: 9 px
  • Spread: 11%
  • Size: 8 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

And this is the result of the text effect applied to our Photoshop action.

Partial result

6. How to Add and Style the Jeans Stitch

We are almost done with our Photoshop action. The last thing we need to add is a cool stitch to this text effect. So let’s do it.

Step 1

Create a new layer by going to Layer > New > Layer and name it stitch. Then Controlclick the jeans-base layer to make a selection. Go to Select > Modify > Contract, set the value to 24 px, and hit OK. Finally, go to your Paths panel and click the Make work path from selection icon at the bottom.

Create a work path

Step 2

Select your Brush Tool (B) and select jeans-stitch from the tutorial assets as your brush. Then right-click on the Work Path layer in Paths panel and select Stroke Path…, choose Brush as your tool, and hit OK. Lastly, hit Delete to delete the work path layer.

Stroke the path

Step 3

Right-click on the stitch layer and select Blending Options. Then add a Bevel and Emboss with these settings:

  • Style: Pillow Emboss
  • Technique: Smooth
  • Depth: 200%
  • Direction: Up
  • Size: 9 px
  • Soften: 5 px
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Linear Dodge (Add) with color #ffffff
  • Highlight Mode – Opacity: 24%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 18%
Add a bevel and emboss

Step 4

Add a Color Overlay and choose the color #d19f5f. Then hit OK to apply the text effect. Now go back to your Actions panel and hit the Stop button at the bottom to stop recording this Photoshop action.

Add a color overlay

Congratulations! You’re Done!

In this tutorial, you learned how to create a Photoshop action for a jeans text effect and also how to create your own denim texture using Photoshop filters.

We started by creating the main denim texture, and then we recorded an action for the jeans text effect using layer styles and a stitch brush.

Final result

I hope you have enjoyed this Photoshop action tutorial. Please feel free to leave your
comments, suggestions, and outcomes below. The text effect action we just
created is based on Stitched Leather and Jeans Actions.

Leather and jeans actions

Looking for more? I recommend the following tutorials:

How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Post pobrano z: How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Final product image
What You’ll Be Creating

In this tutorial, I’ll show you how to create your own denim texture using filters in Adobe Photoshop and then how to create an action for the stitched jeans text effect.

This action is based on Stitched Leather and Jeans Actions from Envato Market.
These actions transform any text or shape into a stitched leather or jeans type.

Leather and jeans actions

Tutorial Assets

The following assets were used during this Photoshop action tutorial:

1. How to Create a Denim Texture

First of all, I’ll show you how you can create your own denim texture using Photoshop filters. If you prefer, you can skip these steps and download the denim texture from the tutorial assets.

Step 1

Start Adobe Photoshop and open a new document (Control-N) with 1024 x 1024 px and a resolution of 72 DPI. Then go to Filter > Filter Gallery… and select Halftone Pattern from the Sketch folder and use these settings:

  • Size: 2
  • Contrast: 20
  • Pattern Type: Dot

Hit OK.

Add halftone pattern

Step 2

Go to Filter > Pixelate > Mezzotint…, set Type to Fine Dots, and hit OK. Then go to Filter > Blur > Motion Blur…, and set the Angle to -45° and the Distance to 20 px. Hit OK.

Add mezzotint and blur

Step 3

Go to Filter > Noise > Add Noise, and set the Amount to 10% and Distribution to Gaussian. Check the Monochromatic box and hit OK. Then go to Filter > Blur > Gaussian Blur, set the Radius to 0.5 px, and hit OK.

Add noise and blur

Step 4

Go to Layer > New Adjustment Layer > Levels and set Inputs to 210.52199 and Outputs to 53163. Then select the Background layer and go to Edit > Define Pattern, change the name to denim-texture, and hit OK.

Done. You have just created your own denim texture which we will use in our Photoshop action. We could finish it with a blue color overlay, but I like to leave it in shades of gray, which lets you change the texture to any color later.

Add levels

2. How to Set the Background and Add Text

For this Photoshop action, I chose the wood planks background, which you can get from the tutorial assets, but it is not mandatory for the action to work.

Step 1

Open the wood planks image (Control-O). Then hit Control-Alt-I, change the Resolution to 72 Pixels/Inch and the Width to 850 px, and hit OK.

Set the background

Step 2

Take your Type tool (T), change the font to Varsity Team Bold, and set the Size to 450 pt. Then write „JB” on your artboard.

Type the text

3. How to Start Recording a Photoshop Action

Now we are going to start recording a Photoshop action. It’s important to follow the steps in order and to avoid unnecessary mouse clicks and keystrokes.

Step 1

Hit Alt-F9 to open your Actions panel. At the bottom of this panel, hit the Create new set icon, name it Jeans Action, and hit OK. Then hit the Create new action icon next to it and name it Start. Now hit the Record button and start recording the Photoshop action.

Start recording an action

Step 2

To start off our Photoshop action, right-click on the JB layer in your Layers panel and select Duplicate Layer, name it jeans-base, and hit OK. Then right-click on the jeans-base layer and select Duplicate Layer again, name it jeans-rim, and hit OK.

Duplicate layers

4. How to Create and Style the Jeans Rim

Step 1

Right-click on the jeans-rim layer and select Blending Options. Then set the Fill Opacity to 0%.

Add blending options

Step 2

Add a Stroke with Size of 16 px, set the Position to Outside, and hit OK. Then right-click the jeans-rim layer and select Convert to Smart Object.

Add a stroke

Step 3

Right-click on the jeans-rim layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 888%
  • Direction: Down
  • Size: 2 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 135°
  • Altitude: 30°
  • Highlight Mode: Linear Burn with color #000000
  • Highlight Mode – Opacity: 27%
  • Highlight Mode: Color Dodge with color #ffffff
  • Shadow Mode – Opacity: 44%
Add a bevel and emboss

Step 4

Add a Texture for the Bevel and Emboss with these settings:

  • Pattern: denim-texture (the one you have created before)
  • Scale: 50%
  • Depth: 95%
Add a texture

Step 5

Add an Inner Shadow with these settings:

  • Color: #6b6b6b
  • Uncheck the Use Global Light box
  • Angle: -45°
  • Distance: 6 px
  • Choke: 45%
  • Size: 5 px
  • Check the Anti-aliased box
Add an inner shadow

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 80%
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Distance: 2 px
  • Spread: 0%
  • Size: 3 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

This is the result of the text effect applied to our Photoshop action.

Partial result

5. How to Create and Style the Jeans Main Layer

Step 1

Select the jeans-base layer in your Layers panel. Right-click on it and select Blending Options. Now add a Stroke with Size of 15 px, change Position to Outside, and hit OK. Then right-click this layer again and select Convert to Smart Object.

Add a stroke

Step 2

Right-click on the jeans-base layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 100%
  • Direction: Up
  • Size: 49 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 180°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Color Dodge with color #ffffff
  • Highlight Mode – Opacity: 30%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 13%
Add a bevel and emboss

Step 3

Add an Inner Shadow with these settings:

  • Blend Mode: Multiply
  • Color: #7a7a7a
  • Uncheck the Use Global Light box
  • Angle: 132°
  • Distance: 0 px
  • Choke: 18%
  • Size: 35 px
  • Check the Anti-aliased box
Add an inner shadow

Step 4

Add an Inner Glow with these settings:

  • Blend Mode: Linear Burn
  • Opacity: 24%
  • Color: #6a6a6a
  • Technique: Softer
  • Source: Edge
  • Choke: 60%
  • Size: 38 px
  • Check the Anti-aliased box
Add an inner glow

Step 5

Add a Satin style with these settings:

  • Blend Mode: Linear Burn
  • Color: #000000
  • Opacity: 13%
  • Angle:
  • Distance: 45 px
  • Size: 46 px
  • Check the Anti-aliased box
  • Check the Invert box
Add a satin

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 36%
  • Uncheck the Use Global Light box
  • Angle: 105°
  • Distance: 9 px
  • Spread: 11%
  • Size: 8 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

And this is the result of the text effect applied to our Photoshop action.

Partial result

6. How to Add and Style the Jeans Stitch

We are almost done with our Photoshop action. The last thing we need to add is a cool stitch to this text effect. So let’s do it.

Step 1

Create a new layer by going to Layer > New > Layer and name it stitch. Then Controlclick the jeans-base layer to make a selection. Go to Select > Modify > Contract, set the value to 24 px, and hit OK. Finally, go to your Paths panel and click the Make work path from selection icon at the bottom.

Create a work path

Step 2

Select your Brush Tool (B) and select jeans-stitch from the tutorial assets as your brush. Then right-click on the Work Path layer in Paths panel and select Stroke Path…, choose Brush as your tool, and hit OK. Lastly, hit Delete to delete the work path layer.

Stroke the path

Step 3

Right-click on the stitch layer and select Blending Options. Then add a Bevel and Emboss with these settings:

  • Style: Pillow Emboss
  • Technique: Smooth
  • Depth: 200%
  • Direction: Up
  • Size: 9 px
  • Soften: 5 px
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Linear Dodge (Add) with color #ffffff
  • Highlight Mode – Opacity: 24%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 18%
Add a bevel and emboss

Step 4

Add a Color Overlay and choose the color #d19f5f. Then hit OK to apply the text effect. Now go back to your Actions panel and hit the Stop button at the bottom to stop recording this Photoshop action.

Add a color overlay

Congratulations! You’re Done!

In this tutorial, you learned how to create a Photoshop action for a jeans text effect and also how to create your own denim texture using Photoshop filters.

We started by creating the main denim texture, and then we recorded an action for the jeans text effect using layer styles and a stitch brush.

Final result

I hope you have enjoyed this Photoshop action tutorial. Please feel free to leave your
comments, suggestions, and outcomes below. The text effect action we just
created is based on Stitched Leather and Jeans Actions.

Leather and jeans actions

Looking for more? I recommend the following tutorials:

How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Post pobrano z: How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Final product image
What You’ll Be Creating

In this tutorial, I’ll show you how to create your own denim texture using filters in Adobe Photoshop and then how to create an action for the stitched jeans text effect.

This action is based on Stitched Leather and Jeans Actions from Envato Market.
These actions transform any text or shape into a stitched leather or jeans type.

Leather and jeans actions

Tutorial Assets

The following assets were used during this Photoshop action tutorial:

1. How to Create a Denim Texture

First of all, I’ll show you how you can create your own denim texture using Photoshop filters. If you prefer, you can skip these steps and download the denim texture from the tutorial assets.

Step 1

Start Adobe Photoshop and open a new document (Control-N) with 1024 x 1024 px and a resolution of 72 DPI. Then go to Filter > Filter Gallery… and select Halftone Pattern from the Sketch folder and use these settings:

  • Size: 2
  • Contrast: 20
  • Pattern Type: Dot

Hit OK.

Add halftone pattern

Step 2

Go to Filter > Pixelate > Mezzotint…, set Type to Fine Dots, and hit OK. Then go to Filter > Blur > Motion Blur…, and set the Angle to -45° and the Distance to 20 px. Hit OK.

Add mezzotint and blur

Step 3

Go to Filter > Noise > Add Noise, and set the Amount to 10% and Distribution to Gaussian. Check the Monochromatic box and hit OK. Then go to Filter > Blur > Gaussian Blur, set the Radius to 0.5 px, and hit OK.

Add noise and blur

Step 4

Go to Layer > New Adjustment Layer > Levels and set Inputs to 210.52199 and Outputs to 53163. Then select the Background layer and go to Edit > Define Pattern, change the name to denim-texture, and hit OK.

Done. You have just created your own denim texture which we will use in our Photoshop action. We could finish it with a blue color overlay, but I like to leave it in shades of gray, which lets you change the texture to any color later.

Add levels

2. How to Set the Background and Add Text

For this Photoshop action, I chose the wood planks background, which you can get from the tutorial assets, but it is not mandatory for the action to work.

Step 1

Open the wood planks image (Control-O). Then hit Control-Alt-I, change the Resolution to 72 Pixels/Inch and the Width to 850 px, and hit OK.

Set the background

Step 2

Take your Type tool (T), change the font to Varsity Team Bold, and set the Size to 450 pt. Then write „JB” on your artboard.

Type the text

3. How to Start Recording a Photoshop Action

Now we are going to start recording a Photoshop action. It’s important to follow the steps in order and to avoid unnecessary mouse clicks and keystrokes.

Step 1

Hit Alt-F9 to open your Actions panel. At the bottom of this panel, hit the Create new set icon, name it Jeans Action, and hit OK. Then hit the Create new action icon next to it and name it Start. Now hit the Record button and start recording the Photoshop action.

Start recording an action

Step 2

To start off our Photoshop action, right-click on the JB layer in your Layers panel and select Duplicate Layer, name it jeans-base, and hit OK. Then right-click on the jeans-base layer and select Duplicate Layer again, name it jeans-rim, and hit OK.

Duplicate layers

4. How to Create and Style the Jeans Rim

Step 1

Right-click on the jeans-rim layer and select Blending Options. Then set the Fill Opacity to 0%.

Add blending options

Step 2

Add a Stroke with Size of 16 px, set the Position to Outside, and hit OK. Then right-click the jeans-rim layer and select Convert to Smart Object.

Add a stroke

Step 3

Right-click on the jeans-rim layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 888%
  • Direction: Down
  • Size: 2 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 135°
  • Altitude: 30°
  • Highlight Mode: Linear Burn with color #000000
  • Highlight Mode – Opacity: 27%
  • Highlight Mode: Color Dodge with color #ffffff
  • Shadow Mode – Opacity: 44%
Add a bevel and emboss

Step 4

Add a Texture for the Bevel and Emboss with these settings:

  • Pattern: denim-texture (the one you have created before)
  • Scale: 50%
  • Depth: 95%
Add a texture

Step 5

Add an Inner Shadow with these settings:

  • Color: #6b6b6b
  • Uncheck the Use Global Light box
  • Angle: -45°
  • Distance: 6 px
  • Choke: 45%
  • Size: 5 px
  • Check the Anti-aliased box
Add an inner shadow

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 80%
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Distance: 2 px
  • Spread: 0%
  • Size: 3 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

This is the result of the text effect applied to our Photoshop action.

Partial result

5. How to Create and Style the Jeans Main Layer

Step 1

Select the jeans-base layer in your Layers panel. Right-click on it and select Blending Options. Now add a Stroke with Size of 15 px, change Position to Outside, and hit OK. Then right-click this layer again and select Convert to Smart Object.

Add a stroke

Step 2

Right-click on the jeans-base layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 100%
  • Direction: Up
  • Size: 49 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 180°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Color Dodge with color #ffffff
  • Highlight Mode – Opacity: 30%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 13%
Add a bevel and emboss

Step 3

Add an Inner Shadow with these settings:

  • Blend Mode: Multiply
  • Color: #7a7a7a
  • Uncheck the Use Global Light box
  • Angle: 132°
  • Distance: 0 px
  • Choke: 18%
  • Size: 35 px
  • Check the Anti-aliased box
Add an inner shadow

Step 4

Add an Inner Glow with these settings:

  • Blend Mode: Linear Burn
  • Opacity: 24%
  • Color: #6a6a6a
  • Technique: Softer
  • Source: Edge
  • Choke: 60%
  • Size: 38 px
  • Check the Anti-aliased box
Add an inner glow

Step 5

Add a Satin style with these settings:

  • Blend Mode: Linear Burn
  • Color: #000000
  • Opacity: 13%
  • Angle:
  • Distance: 45 px
  • Size: 46 px
  • Check the Anti-aliased box
  • Check the Invert box
Add a satin

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 36%
  • Uncheck the Use Global Light box
  • Angle: 105°
  • Distance: 9 px
  • Spread: 11%
  • Size: 8 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

And this is the result of the text effect applied to our Photoshop action.

Partial result

6. How to Add and Style the Jeans Stitch

We are almost done with our Photoshop action. The last thing we need to add is a cool stitch to this text effect. So let’s do it.

Step 1

Create a new layer by going to Layer > New > Layer and name it stitch. Then Controlclick the jeans-base layer to make a selection. Go to Select > Modify > Contract, set the value to 24 px, and hit OK. Finally, go to your Paths panel and click the Make work path from selection icon at the bottom.

Create a work path

Step 2

Select your Brush Tool (B) and select jeans-stitch from the tutorial assets as your brush. Then right-click on the Work Path layer in Paths panel and select Stroke Path…, choose Brush as your tool, and hit OK. Lastly, hit Delete to delete the work path layer.

Stroke the path

Step 3

Right-click on the stitch layer and select Blending Options. Then add a Bevel and Emboss with these settings:

  • Style: Pillow Emboss
  • Technique: Smooth
  • Depth: 200%
  • Direction: Up
  • Size: 9 px
  • Soften: 5 px
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Linear Dodge (Add) with color #ffffff
  • Highlight Mode – Opacity: 24%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 18%
Add a bevel and emboss

Step 4

Add a Color Overlay and choose the color #d19f5f. Then hit OK to apply the text effect. Now go back to your Actions panel and hit the Stop button at the bottom to stop recording this Photoshop action.

Add a color overlay

Congratulations! You’re Done!

In this tutorial, you learned how to create a Photoshop action for a jeans text effect and also how to create your own denim texture using Photoshop filters.

We started by creating the main denim texture, and then we recorded an action for the jeans text effect using layer styles and a stitch brush.

Final result

I hope you have enjoyed this Photoshop action tutorial. Please feel free to leave your
comments, suggestions, and outcomes below. The text effect action we just
created is based on Stitched Leather and Jeans Actions.

Leather and jeans actions

Looking for more? I recommend the following tutorials:

How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Post pobrano z: How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Final product image
What You’ll Be Creating

In this tutorial, I’ll show you how to create your own denim texture using filters in Adobe Photoshop and then how to create an action for the stitched jeans text effect.

This action is based on Stitched Leather and Jeans Actions from Envato Market.
These actions transform any text or shape into a stitched leather or jeans type.

Leather and jeans actions

Tutorial Assets

The following assets were used during this Photoshop action tutorial:

1. How to Create a Denim Texture

First of all, I’ll show you how you can create your own denim texture using Photoshop filters. If you prefer, you can skip these steps and download the denim texture from the tutorial assets.

Step 1

Start Adobe Photoshop and open a new document (Control-N) with 1024 x 1024 px and a resolution of 72 DPI. Then go to Filter > Filter Gallery… and select Halftone Pattern from the Sketch folder and use these settings:

  • Size: 2
  • Contrast: 20
  • Pattern Type: Dot

Hit OK.

Add halftone pattern

Step 2

Go to Filter > Pixelate > Mezzotint…, set Type to Fine Dots, and hit OK. Then go to Filter > Blur > Motion Blur…, and set the Angle to -45° and the Distance to 20 px. Hit OK.

Add mezzotint and blur

Step 3

Go to Filter > Noise > Add Noise, and set the Amount to 10% and Distribution to Gaussian. Check the Monochromatic box and hit OK. Then go to Filter > Blur > Gaussian Blur, set the Radius to 0.5 px, and hit OK.

Add noise and blur

Step 4

Go to Layer > New Adjustment Layer > Levels and set Inputs to 210.52199 and Outputs to 53163. Then select the Background layer and go to Edit > Define Pattern, change the name to denim-texture, and hit OK.

Done. You have just created your own denim texture which we will use in our Photoshop action. We could finish it with a blue color overlay, but I like to leave it in shades of gray, which lets you change the texture to any color later.

Add levels

2. How to Set the Background and Add Text

For this Photoshop action, I chose the wood planks background, which you can get from the tutorial assets, but it is not mandatory for the action to work.

Step 1

Open the wood planks image (Control-O). Then hit Control-Alt-I, change the Resolution to 72 Pixels/Inch and the Width to 850 px, and hit OK.

Set the background

Step 2

Take your Type tool (T), change the font to Varsity Team Bold, and set the Size to 450 pt. Then write „JB” on your artboard.

Type the text

3. How to Start Recording a Photoshop Action

Now we are going to start recording a Photoshop action. It’s important to follow the steps in order and to avoid unnecessary mouse clicks and keystrokes.

Step 1

Hit Alt-F9 to open your Actions panel. At the bottom of this panel, hit the Create new set icon, name it Jeans Action, and hit OK. Then hit the Create new action icon next to it and name it Start. Now hit the Record button and start recording the Photoshop action.

Start recording an action

Step 2

To start off our Photoshop action, right-click on the JB layer in your Layers panel and select Duplicate Layer, name it jeans-base, and hit OK. Then right-click on the jeans-base layer and select Duplicate Layer again, name it jeans-rim, and hit OK.

Duplicate layers

4. How to Create and Style the Jeans Rim

Step 1

Right-click on the jeans-rim layer and select Blending Options. Then set the Fill Opacity to 0%.

Add blending options

Step 2

Add a Stroke with Size of 16 px, set the Position to Outside, and hit OK. Then right-click the jeans-rim layer and select Convert to Smart Object.

Add a stroke

Step 3

Right-click on the jeans-rim layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 888%
  • Direction: Down
  • Size: 2 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 135°
  • Altitude: 30°
  • Highlight Mode: Linear Burn with color #000000
  • Highlight Mode – Opacity: 27%
  • Highlight Mode: Color Dodge with color #ffffff
  • Shadow Mode – Opacity: 44%
Add a bevel and emboss

Step 4

Add a Texture for the Bevel and Emboss with these settings:

  • Pattern: denim-texture (the one you have created before)
  • Scale: 50%
  • Depth: 95%
Add a texture

Step 5

Add an Inner Shadow with these settings:

  • Color: #6b6b6b
  • Uncheck the Use Global Light box
  • Angle: -45°
  • Distance: 6 px
  • Choke: 45%
  • Size: 5 px
  • Check the Anti-aliased box
Add an inner shadow

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 80%
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Distance: 2 px
  • Spread: 0%
  • Size: 3 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

This is the result of the text effect applied to our Photoshop action.

Partial result

5. How to Create and Style the Jeans Main Layer

Step 1

Select the jeans-base layer in your Layers panel. Right-click on it and select Blending Options. Now add a Stroke with Size of 15 px, change Position to Outside, and hit OK. Then right-click this layer again and select Convert to Smart Object.

Add a stroke

Step 2

Right-click on the jeans-base layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 100%
  • Direction: Up
  • Size: 49 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 180°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Color Dodge with color #ffffff
  • Highlight Mode – Opacity: 30%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 13%
Add a bevel and emboss

Step 3

Add an Inner Shadow with these settings:

  • Blend Mode: Multiply
  • Color: #7a7a7a
  • Uncheck the Use Global Light box
  • Angle: 132°
  • Distance: 0 px
  • Choke: 18%
  • Size: 35 px
  • Check the Anti-aliased box
Add an inner shadow

Step 4

Add an Inner Glow with these settings:

  • Blend Mode: Linear Burn
  • Opacity: 24%
  • Color: #6a6a6a
  • Technique: Softer
  • Source: Edge
  • Choke: 60%
  • Size: 38 px
  • Check the Anti-aliased box
Add an inner glow

Step 5

Add a Satin style with these settings:

  • Blend Mode: Linear Burn
  • Color: #000000
  • Opacity: 13%
  • Angle:
  • Distance: 45 px
  • Size: 46 px
  • Check the Anti-aliased box
  • Check the Invert box
Add a satin

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 36%
  • Uncheck the Use Global Light box
  • Angle: 105°
  • Distance: 9 px
  • Spread: 11%
  • Size: 8 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

And this is the result of the text effect applied to our Photoshop action.

Partial result

6. How to Add and Style the Jeans Stitch

We are almost done with our Photoshop action. The last thing we need to add is a cool stitch to this text effect. So let’s do it.

Step 1

Create a new layer by going to Layer > New > Layer and name it stitch. Then Controlclick the jeans-base layer to make a selection. Go to Select > Modify > Contract, set the value to 24 px, and hit OK. Finally, go to your Paths panel and click the Make work path from selection icon at the bottom.

Create a work path

Step 2

Select your Brush Tool (B) and select jeans-stitch from the tutorial assets as your brush. Then right-click on the Work Path layer in Paths panel and select Stroke Path…, choose Brush as your tool, and hit OK. Lastly, hit Delete to delete the work path layer.

Stroke the path

Step 3

Right-click on the stitch layer and select Blending Options. Then add a Bevel and Emboss with these settings:

  • Style: Pillow Emboss
  • Technique: Smooth
  • Depth: 200%
  • Direction: Up
  • Size: 9 px
  • Soften: 5 px
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Linear Dodge (Add) with color #ffffff
  • Highlight Mode – Opacity: 24%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 18%
Add a bevel and emboss

Step 4

Add a Color Overlay and choose the color #d19f5f. Then hit OK to apply the text effect. Now go back to your Actions panel and hit the Stop button at the bottom to stop recording this Photoshop action.

Add a color overlay

Congratulations! You’re Done!

In this tutorial, you learned how to create a Photoshop action for a jeans text effect and also how to create your own denim texture using Photoshop filters.

We started by creating the main denim texture, and then we recorded an action for the jeans text effect using layer styles and a stitch brush.

Final result

I hope you have enjoyed this Photoshop action tutorial. Please feel free to leave your
comments, suggestions, and outcomes below. The text effect action we just
created is based on Stitched Leather and Jeans Actions.

Leather and jeans actions

Looking for more? I recommend the following tutorials:

How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Post pobrano z: How to Make a Photoshop Action to Create a Stitched Jeans Text Effect

Final product image
What You’ll Be Creating

In this tutorial, I’ll show you how to create your own denim texture using filters in Adobe Photoshop and then how to create an action for the stitched jeans text effect.

This action is based on Stitched Leather and Jeans Actions from Envato Market.
These actions transform any text or shape into a stitched leather or jeans type.

Leather and jeans actions

Tutorial Assets

The following assets were used during this Photoshop action tutorial:

1. How to Create a Denim Texture

First of all, I’ll show you how you can create your own denim texture using Photoshop filters. If you prefer, you can skip these steps and download the denim texture from the tutorial assets.

Step 1

Start Adobe Photoshop and open a new document (Control-N) with 1024 x 1024 px and a resolution of 72 DPI. Then go to Filter > Filter Gallery… and select Halftone Pattern from the Sketch folder and use these settings:

  • Size: 2
  • Contrast: 20
  • Pattern Type: Dot

Hit OK.

Add halftone pattern

Step 2

Go to Filter > Pixelate > Mezzotint…, set Type to Fine Dots, and hit OK. Then go to Filter > Blur > Motion Blur…, and set the Angle to -45° and the Distance to 20 px. Hit OK.

Add mezzotint and blur

Step 3

Go to Filter > Noise > Add Noise, and set the Amount to 10% and Distribution to Gaussian. Check the Monochromatic box and hit OK. Then go to Filter > Blur > Gaussian Blur, set the Radius to 0.5 px, and hit OK.

Add noise and blur

Step 4

Go to Layer > New Adjustment Layer > Levels and set Inputs to 210.52199 and Outputs to 53163. Then select the Background layer and go to Edit > Define Pattern, change the name to denim-texture, and hit OK.

Done. You have just created your own denim texture which we will use in our Photoshop action. We could finish it with a blue color overlay, but I like to leave it in shades of gray, which lets you change the texture to any color later.

Add levels

2. How to Set the Background and Add Text

For this Photoshop action, I chose the wood planks background, which you can get from the tutorial assets, but it is not mandatory for the action to work.

Step 1

Open the wood planks image (Control-O). Then hit Control-Alt-I, change the Resolution to 72 Pixels/Inch and the Width to 850 px, and hit OK.

Set the background

Step 2

Take your Type tool (T), change the font to Varsity Team Bold, and set the Size to 450 pt. Then write „JB” on your artboard.

Type the text

3. How to Start Recording a Photoshop Action

Now we are going to start recording a Photoshop action. It’s important to follow the steps in order and to avoid unnecessary mouse clicks and keystrokes.

Step 1

Hit Alt-F9 to open your Actions panel. At the bottom of this panel, hit the Create new set icon, name it Jeans Action, and hit OK. Then hit the Create new action icon next to it and name it Start. Now hit the Record button and start recording the Photoshop action.

Start recording an action

Step 2

To start off our Photoshop action, right-click on the JB layer in your Layers panel and select Duplicate Layer, name it jeans-base, and hit OK. Then right-click on the jeans-base layer and select Duplicate Layer again, name it jeans-rim, and hit OK.

Duplicate layers

4. How to Create and Style the Jeans Rim

Step 1

Right-click on the jeans-rim layer and select Blending Options. Then set the Fill Opacity to 0%.

Add blending options

Step 2

Add a Stroke with Size of 16 px, set the Position to Outside, and hit OK. Then right-click the jeans-rim layer and select Convert to Smart Object.

Add a stroke

Step 3

Right-click on the jeans-rim layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 888%
  • Direction: Down
  • Size: 2 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 135°
  • Altitude: 30°
  • Highlight Mode: Linear Burn with color #000000
  • Highlight Mode – Opacity: 27%
  • Highlight Mode: Color Dodge with color #ffffff
  • Shadow Mode – Opacity: 44%
Add a bevel and emboss

Step 4

Add a Texture for the Bevel and Emboss with these settings:

  • Pattern: denim-texture (the one you have created before)
  • Scale: 50%
  • Depth: 95%
Add a texture

Step 5

Add an Inner Shadow with these settings:

  • Color: #6b6b6b
  • Uncheck the Use Global Light box
  • Angle: -45°
  • Distance: 6 px
  • Choke: 45%
  • Size: 5 px
  • Check the Anti-aliased box
Add an inner shadow

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 80%
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Distance: 2 px
  • Spread: 0%
  • Size: 3 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

This is the result of the text effect applied to our Photoshop action.

Partial result

5. How to Create and Style the Jeans Main Layer

Step 1

Select the jeans-base layer in your Layers panel. Right-click on it and select Blending Options. Now add a Stroke with Size of 15 px, change Position to Outside, and hit OK. Then right-click this layer again and select Convert to Smart Object.

Add a stroke

Step 2

Right-click on the jeans-base layer and select Blending Options again. Now add a Bevel and Emboss with these settings:

  • Style: Inner Bevel
  • Technique: Smooth
  • Depth: 100%
  • Direction: Up
  • Size: 49 px
  • Soften: 0 px
  • Uncheck the Use Global Light box
  • Angle: 180°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Color Dodge with color #ffffff
  • Highlight Mode – Opacity: 30%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 13%
Add a bevel and emboss

Step 3

Add an Inner Shadow with these settings:

  • Blend Mode: Multiply
  • Color: #7a7a7a
  • Uncheck the Use Global Light box
  • Angle: 132°
  • Distance: 0 px
  • Choke: 18%
  • Size: 35 px
  • Check the Anti-aliased box
Add an inner shadow

Step 4

Add an Inner Glow with these settings:

  • Blend Mode: Linear Burn
  • Opacity: 24%
  • Color: #6a6a6a
  • Technique: Softer
  • Source: Edge
  • Choke: 60%
  • Size: 38 px
  • Check the Anti-aliased box
Add an inner glow

Step 5

Add a Satin style with these settings:

  • Blend Mode: Linear Burn
  • Color: #000000
  • Opacity: 13%
  • Angle:
  • Distance: 45 px
  • Size: 46 px
  • Check the Anti-aliased box
  • Check the Invert box
Add a satin

Step 6

Add a Color Overlay with these settings:

  • Blend Mode: Overlay
  • Color: #224d66
  • Opacity: 80%
Add a color overlay

Step 7

Add a Pattern Overlay with these settings:

  • Blend Mode: Normal
  • Opacity: 100%
  • Pattern: denim-texture
  • Scale: 50%
Add a pattern overlay

Step 8

Finally, add a Drop Shadow to our Photoshop text effect with these settings:

  • Blend Mode: Multiply
  • Color: #000000
  • Opacity: 36%
  • Uncheck the Use Global Light box
  • Angle: 105°
  • Distance: 9 px
  • Spread: 11%
  • Size: 8 px
  • Check the Anti-aliased box

Hit OK to apply the text effect.

Add a drop shadow

And this is the result of the text effect applied to our Photoshop action.

Partial result

6. How to Add and Style the Jeans Stitch

We are almost done with our Photoshop action. The last thing we need to add is a cool stitch to this text effect. So let’s do it.

Step 1

Create a new layer by going to Layer > New > Layer and name it stitch. Then Controlclick the jeans-base layer to make a selection. Go to Select > Modify > Contract, set the value to 24 px, and hit OK. Finally, go to your Paths panel and click the Make work path from selection icon at the bottom.

Create a work path

Step 2

Select your Brush Tool (B) and select jeans-stitch from the tutorial assets as your brush. Then right-click on the Work Path layer in Paths panel and select Stroke Path…, choose Brush as your tool, and hit OK. Lastly, hit Delete to delete the work path layer.

Stroke the path

Step 3

Right-click on the stitch layer and select Blending Options. Then add a Bevel and Emboss with these settings:

  • Style: Pillow Emboss
  • Technique: Smooth
  • Depth: 200%
  • Direction: Up
  • Size: 9 px
  • Soften: 5 px
  • Uncheck the Use Global Light box
  • Angle: 90°
  • Altitude: 30°
  • Check the Anti-aliased box
  • Highlight Mode: Linear Dodge (Add) with color #ffffff
  • Highlight Mode – Opacity: 24%
  • Highlight Mode: Linear Burn with color #000000
  • Shadow Mode – Opacity: 18%
Add a bevel and emboss

Step 4

Add a Color Overlay and choose the color #d19f5f. Then hit OK to apply the text effect. Now go back to your Actions panel and hit the Stop button at the bottom to stop recording this Photoshop action.

Add a color overlay

Congratulations! You’re Done!

In this tutorial, you learned how to create a Photoshop action for a jeans text effect and also how to create your own denim texture using Photoshop filters.

We started by creating the main denim texture, and then we recorded an action for the jeans text effect using layer styles and a stitch brush.

Final result

I hope you have enjoyed this Photoshop action tutorial. Please feel free to leave your
comments, suggestions, and outcomes below. The text effect action we just
created is based on Stitched Leather and Jeans Actions.

Leather and jeans actions

Looking for more? I recommend the following tutorials:

Why CSS Needs its Own Survey

Post pobrano z: Why CSS Needs its Own Survey

2016 was only three years ago, but that’s almost a whole other era in web development terms. The JavaScript landscape was in turmoil, with up-and-comer React — as well as a little-known framework called Vue — fighting to dethrone Angular.

Like many other developers, I felt lost. I needed some clarity, and I figured the best way to get it was simply to ask fellow coders what they used, and more importantly, what they enjoyed using. The result was the first ever edition of the now annual State of JavaScript survey.

The State of JavaScript 2018

Things have stabilized in the JavaScript world since then. Turns out you can’t really go wrong with any one of the big three frameworks, and even less mainstream options, like Ember, have managed to build up passionate communities and show no sign of going anywhere.

But while all our attention was fixated on JavaScript, trouble was brewing in CSS land. For years, my impression of CSS’s evolution was slow, incremental progress. Back then, I was pretty sure border-radius support represented the crowning, final achievement of web browser technology.

But all of a sudden, things started picking up. Flexbox came out, representing the first new and widely adopted layout method in over a decade. And Grid came shortly after that, sweeping away years of hacky grid frameworks into the gutter of bad CSS practices.

Something even crazier happened: now that the JavaScript people had stopped creating a new framework every two weeks, they decided to use all their extra free time trying to make CSS even better! And thus CSS-in-JS was born.

And now it’s 2019, and the Flexbox Cheatsheet tab I’ve kept open for the past two years has now been joined by a Grid Cheatsheet, because no matter how many times I use them, I still need to double-check the syntax. And despite writing a popular introduction to CSS-in-JS, I still lazily default to familiar Sass for new projects, promising myself that I’ll „do things properly” the next time.

All this to say that I feel just as lost and confused about CSS in 2019 as I did about JavaScript in 2016. It’s high time CSS got a survey of its own.

Starting from scratch

Coming up with the idea for a CSS survey was easy, but deciding on the questions themselves was far from straightforward. Like I said, I didn’t feel confident in my own CSS knowledge, and simply asking about Sass vs. Less for the 37th time felt like a missed opportunity…

Thankfully, the CSS Gods decided to smile down upon me: while attending the DotJS conference in France I discovered that, not only did fellow speaker Florian Rivoal live in Kyoto, Japan, just like me; but that he was a member of the CSS Working Group! In other words, one of the people who knows the most about CSS on the planet was living a few train stops away from me!

Florian was a huge help in coming up with the overall structure and content of the survey. And he also helped me realize how little I really knew about CSS.

Kyoto, Japan: a hotbed of CSS activity (Photo by Jisu Han)

You don’t know CSS

I’m not only talking about obscure CSS properties here, or even new up-and-coming ones, but about how CSS itself is developed. For example, did you know that the development of the CSS Grid spec was sponsored by Bloomberg, because they needed a way to port the layout of their famous terminal to the web?

Did you ever stop to wonder what top: 30px is supposed to mean on a circular screen, such as the one on a smartwatch? Or did you know that some people are laying out entire printed books in CSS, effectively replacing software like InDesign?

Talking with Florian really expanded my mind to how broad and interesting CSS truly is, and convinced me doing the survey was worth it.

„What do you mean, ‘Make the <table> circular’?” Photo by Artur Łuczka

About that divide…

The idea of a CSS survey became all the more important as my new-found admiration for CSS seemed to coincide with a general sentiment that HTML and CSS mastery were becoming under-appreciated skills in the face of JavaScript hegemony.

Myself, personally, I’ve always enjoyed being a generalist in the sense that I happily hop from one side of the great divide to another whenever I feel like it. At the same time, I’m also wholly convinced that the world needs specialists like Florian; people who dedicate their lives to championing and improving a single aspect of the web.

Devaluing the work the work of generalists is not only unfair, but it’s also counter-productive — after all, HTML and CSS are the foundation on which all modern JavaScript frameworks are built; and on the other hand, new patterns and approaches pioneered by CSS-in-JS libraries will hopefully find their way back into vanilla CSS sooner or later.

Thankfully, I feel like a minority of developers hold those views, and those who do generally hold them do so out of ignorance for what the „other side” really stands for more than any well-informed opinion.

So that’s where the survey comes in: I’m not saying I can fill up the divide, but maybe I can throw a couple walkways across, or distribute some jetpacks — you know, whatever works. 🚀

If that sounds good, then the first step is — you guessed it — taking the survey!

Take Survey

The post Why CSS Needs its Own Survey appeared first on CSS-Tricks.

Recreating the Facebook Messenger Gradient Effect with CSS

Post pobrano z: Recreating the Facebook Messenger Gradient Effect with CSS

One Sunday morning, I woke up a little earlier than I would’ve liked to, thanks to the persistent buzzing of my phone. I reached out, tapped into Facebook Messenger, and joined the conversation. Pretty soon my attention went from the actual conversations to the funky gradient effect of the message bubbles containing them. Let me show you what I mean:

This is a new feature of Messenger, which allows you to choose a gradient instead of a plain color for the background of the chat messages. It’s currently available on the mobile application as well as Facebook’s site, but not yet on Messenger’s site. The gradient appears “fixed” so that chat bubbles appear to change background color as they scroll vertically.

I thought this looked like something that could be done in CSS, so… challenge accepted!

Let’s walk through my thought process as I attempted to recreate it and explain the CSS features that were used to make it work. Also, we’ll see how Facebook actually implemented it (spoiler alert: not the way I did) and how the two approaches compare.

Getting our hands dirty

First, let’s look at the example again to see what exactly it is that we’re trying to achieve here.

In general, we have a pretty standard messaging layout: messages are divided into bubbles going from top to bottom, ours on the right and the other people in the chat on the left. The ones on the left all have a gray background color, but the ones on the right look like they’re sharing the same fixed background gradient. That’s pretty much it!

Step 1: Set up the layout

This part is pretty simple: let’s arrange the messages in an ordered list and apply some basic CSS to make it look more like an actual messaging application:

<ol class="messages">
  <li class="ours">Hi, babe!</li>
  <li class="ours">I have something for you.</li>
  <li>What is it?</li>
  <li class="ours">Just a little something.</li>
  <li>Johnny, it’s beautiful. Thank you. Can I try it on now?</li>
  <li class="ours">Sure, it’s yours.</li>
  <li>Wait right here.</li>
  <li>I’ll try it on right now.</li>
</ol>

When it comes to dividing the messages to the left and the right, my knee-jerk reaction was to use floats. We could use float: left for messages on the left and float: right for messages on the right to have them stick to different edges. Then, we’d apply clear: both to on each message so they stack. But there’s a much more modern approach — flexbox!

We can use flexbox to stack the list items vertically with flex-direction: column and tell all the children to stick to the left edge (or “align the cross-start margin edges of the flex children with cross-start margin edges of the lines,” if you prefer the technical terms) with align-items: flex-start. Then, we can overwrite the align-items value for individual flex items by setting align-self: flex-end on them.

What, you mean you couldn’t visualize the code based on that? Fine, here’s how that looks:

.messages {
  /* Flexbox-specific styles */
  display: flex;
  flex-direction: column;
  align-items: flex-start;

  /* General styling */
  font: 16px/1.3 sans-serif;
  height: 300px;
  list-style-type: none;
  margin: 0 auto;
  padding: 8px;
  overflow: auto;
  width: 200px;
}

/* Default styles for chat bubbles */
.messages li {
  background: #eee;
  border-radius: 8px;
  padding: 8px;
  margin: 2px 8px 2px 0;
}

/* Styles specific to our chat bubbles */
.messages li.ours {
  align-self: flex-end; /* Stick to the right side, please! */
  margin: 2px 0 2px 8px;
}

Some padding and colors here and there and this already looks similar enough to move on to the fun part.

Step 2: Let’s color things in!

The initial idea for the gradient actually came to me from this tweet by Matthias Ott (that Chris recreated in another post):

This is a nasty hack with a pseudo-element on top of the text and mix-blend-mode doesn't work in IE / Edge, but: Yes, this is possible to do with CSS! 😅https://t.co/FLKGvd1YoI

— Matthias Ott (@m_ott) December 3, 2018

The key clue here is mix-blend-mode, which is a CSS property that allows us to control how the content of an element blends in with what’s behind it. It’s a feature that has been present in Photoshop and other similar tools for a while, but is fairly new to the web. There’s an almanac entry for the property that explains all of its many possible values.

One of the values is screen: it takes the values of the pixels of the background and foreground, inverts them, multiplies them, and inverts them once more. This results in a color that is brighter than the original background color.

The description can seem a little confusing, but what it essentially means is that if the background is monochrome, wherever the background is black, the foreground pixels are shown fully and wherever it is white, white remains.

With mix-blend-mode: screen; on the foreground, we’ll see more of the foreground as the background is darker.

So, for our purposes, the background will be the chat window itself and the foreground will contain an element with the desired gradient set as the background that’s positioned over the background. Then, we apply the appropriate blend mode to the foreground element and restyle the background. We want the background to be black in places where we want the gradient to be shown and white in other places, so we’ll style the bubbles by giving them a plain black background and white text. Oh, and let’s remember to add pointer-events: none to the foreground element so the user can interact with the underlying text.

At this point, I also changed the original HTML a little. The entire chat is a wrapper in an additional container that allows the gradient to stay “fixed” over the scrollable part of the chat:

.messages-container:after {
  content: '';
  background: linear-gradient(rgb(255, 143, 178) 0%, rgb(167, 151, 255) 50%, rgb(0, 229, 255) 100%);
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  mix-blend-mode: screen;
  pointer-events: none;
}

.messages li {
  background: black;
  color: white;
  /* rest of styles */
}

The result looks something like this:

The gradient applied to the chat bubbles

Step 3: Exclude some messages from the gradient

Now the gradient is being shown where the text bubbles are under it! However, we only want it to be shown over our bubbles — the ones along the right edge. A hint to how that can be achieved is hidden in MDN’s description of the mix-blend-mode property:

The mix-blend-mode CSS property sets how an element’s content should blend with the content of the element’s parent and the element’s background.

That’s right! The background. Of course, the effect only takes into account the HTML elements that are behind the current element and have a lower stack order. Fortunately, the stacking order of elements can easily be changed with the z-index property. So all we have to do is to give the chat bubbles on the left a higher z-index than that of the foreground element and they will be raised above it, outside of the influence of mix-blend-mode! Then we can style them however we want.

The gradient applied to the chat bubbles.

Let’s talk browser support

At the time of writing, mix-blend-mode is not supported at all in Internet Explorer and Edge. In those browsers, the gradient is laid over the whole chat and others’ bubbles appear on top of it, which is not an ideal solution.

This browser support data is from Caniuse, which has more detail. A number indicates that browser supports the feature at that version and up.

Desktop

Chrome Opera Firefox IE Edge Safari
41 29 32 No No TP

Mobile / Tablet

iOS Safari Opera Mobile Opera Mini Android Android Chrome Android Firefox
12.2 46 No 67 71 64

So, this is what we get in unsupported browsers:

How browsers that don’t support mix-blend-mode render the chat.

Fortunately, all the browsers that support mix-blend-mode also support CSS Feature Queries. Using them allows us to write fallback styles for unsupported browsers first and include the fancy effects for the browsers that support them. This way, even if a user can’t see the full effect, they can still see the whole chat and interact with it:

A simplified UI for older browsers, falling back to a plain cyan background color.

Here’s the final Pen with the full effect and fallback styles:

See the Pen
Facebook Messenger-like gradient coloring in CSS
by Stepan Bolotnikov (@Stopa)
on CodePen.

Now let’s see how Facebook did it

Turns out that Facebook’s solution is almost the opposite of what we’ve covered here. Instead of laying the gradient over the chat and cutting holes in it, they apply the gradient as a fixed background image to the whole chat. The chat itself is filled with a whole bunch of empty elements with white backgrounds and borders, except where the gradient should be visible.

The final HTML rendered by the Facebook Messenger React app is pretty verbose and hard to navigate, so I recreated a minimal example to demonstrate it. A lot of the empty HTML elements can be switched for pseudo-elements instead:

See the Pen
Facebook Messenger-like gradient coloring in CSS: The Facebook Way
by Stepan Bolotnikov (@Stopa)
on CodePen.

As you can see, the end result looks similar to the mix-blend-mode solution, but with a little bit of extra markup. Additionally, their approach provides more flexibility for rich content, like images and emojis . The mix-blend-mode approach doesn’t really work if the background is anything but monochrome and I haven’t been able to come up with a way to “raise” inner content above the gradient or get around this limitation in another way.

Because of this limitation, it’s wiser to use Facebook’s approach in an actual chat application. Still, our solution using mix-blend-mode showcases an interesting way to use one of the most under-appreciated CSS properties in modern web design and hopefully it has given you some ideas on what you could do with it!

The post Recreating the Facebook Messenger Gradient Effect with CSS appeared first on CSS-Tricks.

Agregator najlepszych postów o designie, webdesignie, cssie i Internecie