Skip to content

Commit c165f1d

Browse files
authored
[0.3] Add background attachment utilities (tailwindlabs#243)
* Create backgroundAttachment.js generator * Updated background-attachment utility * Integrate background attachment utilities * Add basic background attachment documentation
1 parent cbe89ea commit c165f1d

File tree

6 files changed

+105
-0
lines changed

6 files changed

+105
-0
lines changed

__tests__/fixtures/tailwind-output.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,18 @@ button,
615615
appearance: none;
616616
}
617617

618+
.bg-fixed {
619+
background-attachment: fixed;
620+
}
621+
622+
.bg-local {
623+
background-attachment: local;
624+
}
625+
626+
.bg-scroll {
627+
background-attachment: scroll;
628+
}
629+
618630
.bg-transparent {
619631
background-color: transparent;
620632
}
@@ -4458,6 +4470,18 @@ button,
44584470
appearance: none;
44594471
}
44604472

4473+
.sm\:bg-fixed {
4474+
background-attachment: fixed;
4475+
}
4476+
4477+
.sm\:bg-local {
4478+
background-attachment: local;
4479+
}
4480+
4481+
.sm\:bg-scroll {
4482+
background-attachment: scroll;
4483+
}
4484+
44614485
.sm\:bg-transparent {
44624486
background-color: transparent;
44634487
}
@@ -8302,6 +8326,18 @@ button,
83028326
appearance: none;
83038327
}
83048328

8329+
.md\:bg-fixed {
8330+
background-attachment: fixed;
8331+
}
8332+
8333+
.md\:bg-local {
8334+
background-attachment: local;
8335+
}
8336+
8337+
.md\:bg-scroll {
8338+
background-attachment: scroll;
8339+
}
8340+
83058341
.md\:bg-transparent {
83068342
background-color: transparent;
83078343
}
@@ -12146,6 +12182,18 @@ button,
1214612182
appearance: none;
1214712183
}
1214812184

12185+
.lg\:bg-fixed {
12186+
background-attachment: fixed;
12187+
}
12188+
12189+
.lg\:bg-local {
12190+
background-attachment: local;
12191+
}
12192+
12193+
.lg\:bg-scroll {
12194+
background-attachment: scroll;
12195+
}
12196+
1214912197
.lg\:bg-transparent {
1215012198
background-color: transparent;
1215112199
}
@@ -15990,6 +16038,18 @@ button,
1599016038
appearance: none;
1599116039
}
1599216040

16041+
.xl\:bg-fixed {
16042+
background-attachment: fixed;
16043+
}
16044+
16045+
.xl\:bg-local {
16046+
background-attachment: local;
16047+
}
16048+
16049+
.xl\:bg-scroll {
16050+
background-attachment: scroll;
16051+
}
16052+
1599316053
.xl\:bg-transparent {
1599416054
background-color: transparent;
1599516055
}

defaultConfig.stub.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ module.exports = {
773773

774774
modules: {
775775
appearance: ['responsive'],
776+
backgroundAttachment: ['responsive'],
776777
backgroundColors: ['responsive', 'hover'],
777778
backgroundPosition: ['responsive'],
778779
backgroundSize: ['responsive'],

docs/navigation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'Color' => 'background-color',
1919
'Position' => 'background-position',
2020
'Size' => 'background-size',
21+
'Attachment' => 'background-attachment',
2122
],
2223
'Borders' => [
2324
'Width' => 'border-width',
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
extends: _layouts.documentation
3+
title: "Background Attachment"
4+
description: "Utilities for controlling how a background image behaves when scrolling."
5+
features:
6+
responsive: true
7+
customizable: false
8+
hover: false
9+
focus: false
10+
---
11+
12+
@include('_partials.work-in-progress')
13+
14+
@include('_partials.class-table', [
15+
'rows' => [
16+
[
17+
'.bg-fixed',
18+
'background-attachment: fixed;',
19+
'Fix the background image relative to the viewport.',
20+
],
21+
[
22+
'.bg-local',
23+
'background-attachment: local;',
24+
'Scroll the background image with the container and the viewport.',
25+
],
26+
[
27+
'.bg-scroll',
28+
'background-attachment: scroll;',
29+
'Scroll the background image with the viewport but not with the container.',
30+
],
31+
]
32+
])
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import defineClasses from '../util/defineClasses'
2+
3+
export default function() {
4+
return defineClasses({
5+
'bg-fixed': { 'background-attachment': 'fixed' },
6+
'bg-local': { 'background-attachment': 'local' },
7+
'bg-scroll': { 'background-attachment': 'scroll' },
8+
})
9+
}

src/utilityModules.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import lists from './generators/lists'
22
import appearance from './generators/appearance'
3+
import backgroundAttachment from './generators/backgroundAttachment'
34
import backgroundColors from './generators/backgroundColors'
45
import backgroundPosition from './generators/backgroundPosition'
56
import backgroundSize from './generators/backgroundSize'
@@ -43,6 +44,7 @@ import zIndex from './generators/zIndex'
4344
export default [
4445
{ name: 'lists', generator: lists },
4546
{ name: 'appearance', generator: appearance },
47+
{ name: 'backgroundAttachment', generator: backgroundAttachment },
4648
{ name: 'backgroundColors', generator: backgroundColors },
4749
{ name: 'backgroundPosition', generator: backgroundPosition },
4850
{ name: 'backgroundSize', generator: backgroundSize },

0 commit comments

Comments
 (0)