Skip to content

Commit bbe48f4

Browse files
authored
Merge pull request #36 from JBlond/development
Dark Theme Example
2 parents 3167569 + cac11d6 commit bbe48f4

12 files changed

+241
-28
lines changed

example/dark-theme.css

+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
body {
2+
background: #3A3B46;
3+
color: #F8F8F2;
4+
font-family: Arial, serif;
5+
font-size: 12px;
6+
}
7+
8+
pre {
9+
width: 100%;
10+
overflow: auto;
11+
}
12+
13+
a, a:visited {
14+
color: #F8F8F2;
15+
}
16+
17+
/*
18+
* HTML Renderers - General
19+
*/
20+
21+
.Differences {
22+
width: 100%;
23+
border-collapse: collapse;
24+
border-spacing: 0;
25+
empty-cells: show;
26+
}
27+
28+
.Differences thead th {
29+
text-align: left;
30+
border-bottom: 1px solid #000000;
31+
background: #AAAAAA;
32+
color: #000000;
33+
padding: 4px;
34+
}
35+
36+
.Differences tbody th {
37+
text-align: right;
38+
background: #AAAAAA;
39+
color: #272822;
40+
width: 4em;
41+
padding: 1px 2px;
42+
border-right: 1px solid #000000;
43+
vertical-align: top;
44+
font-size: 13px;
45+
}
46+
47+
.Differences td {
48+
padding: 1px 2px;
49+
font-family: Consolas, monospace;
50+
font-size: 13px;
51+
}
52+
53+
.Differences .Skipped {
54+
background: #F7F7F7;
55+
}
56+
57+
/*
58+
* HTML Side by Side Diff
59+
*/
60+
.DifferencesSideBySide .ChangeInsert td.Left {
61+
background: green;
62+
}
63+
64+
.DifferencesSideBySide .ChangeInsert td.Right {
65+
background: green;
66+
}
67+
68+
.DifferencesSideBySide .ChangeDelete td.Left {
69+
background: #FF8888;
70+
color: #272822;
71+
}
72+
73+
.DifferencesSideBySide .ChangeDelete td.Right {
74+
background: #FFAAAA;
75+
color: #272822;
76+
}
77+
78+
.DifferencesSideBySide .ChangeReplace .Left {
79+
background: #FFEE99;
80+
color: #272822;
81+
}
82+
83+
.DifferencesSideBySide .ChangeReplace .Right {
84+
background: #FFDD88;
85+
color: #272822;
86+
}
87+
88+
.Differences ins,
89+
.Differences del {
90+
text-decoration: none;
91+
}
92+
93+
.DifferencesSideBySide .ChangeReplace ins,
94+
.DifferencesSideBySide .ChangeReplace del {
95+
background: #EEBB00;
96+
}
97+
98+
/*
99+
* HTML Inline Diff
100+
*/
101+
102+
.DifferencesInline .ChangeReplace {
103+
color: #272822;
104+
}
105+
106+
.DifferencesInline .ChangeReplace .Left,
107+
.DifferencesInline .ChangeDelete .Left {
108+
background: #FFDDDD;
109+
color: #272822;
110+
}
111+
112+
.DifferencesInline .ChangeReplace .Right,
113+
.DifferencesInline .ChangeInsert .Right {
114+
background: #DDFFDD;
115+
}
116+
117+
.DifferencesInline .ChangeReplace ins {
118+
background: green;
119+
}
120+
121+
.DifferencesInline .ChangeReplace del {
122+
background: #EE9999;
123+
color: #272822;
124+
}
125+
126+
/*
127+
* HTML Unified Diff
128+
*/
129+
130+
/* Line removed in new */
131+
.DifferencesUnified .ChangeDelete .Left::before {
132+
content: "- \00a0";
133+
}
134+
135+
.DifferencesUnified .ChangeDelete .Left {
136+
background: #EE9999;
137+
color: #272822;
138+
}
139+
140+
/* Line modified in old and new */
141+
.DifferencesUnified .ChangeReplace {
142+
background: #FFEE99;
143+
color: #272822;
144+
display: table;
145+
}
146+
147+
/* Line in old replaced by line in new */
148+
.DifferencesUnified .ChangeReplace .Left:first-child:before {
149+
content: "\250C \00a0";
150+
}
151+
152+
.DifferencesUnified .ChangeReplace .Left:before {
153+
content: "\251C \00a0";
154+
}
155+
156+
.DifferencesUnified .ChangeReplace .Left {
157+
background: #FFEE99;
158+
}
159+
160+
/* Line in new replaced line in old */
161+
.DifferencesUnified .ChangeReplace .Right:last-of-type:before {
162+
content: "\2514 \00a0";
163+
}
164+
165+
.DifferencesUnified .ChangeReplace .Right:before {
166+
content: "\251C \00a0";
167+
}
168+
169+
.DifferencesUnified .ChangeReplace .Right {
170+
background: #FFEE99;
171+
}
172+
173+
/* Line inserted in new */
174+
.DifferencesUnified .ChangeInsert .Right:before {
175+
content: "+ \00A0";
176+
}
177+
178+
/* Character inserted in line of new */
179+
.DifferencesUnified .ChangeReplace ins {
180+
background: #99EE99;
181+
}
182+
183+
/* Character removed from line in old */
184+
.DifferencesUnified .ChangeReplace del {
185+
background: #EE9999;
186+
}

example/example.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,28 @@
3232
<head>
3333
<meta charset="utf-8"/>
3434
<title>PHP LibDiff - Examples</title>
35-
<link rel="stylesheet" href="styles.css" type="text/css" />
35+
<link rel="stylesheet" type="text/css" href="styles.css" />
36+
<script>
37+
function changeCSS(cssFile, cssLinkIndex) {
38+
39+
var oldLink = document.getElementsByTagName("link").item(cssLinkIndex);
40+
41+
var newLink = document.createElement("link");
42+
newLink.setAttribute("rel", "stylesheet");
43+
newLink.setAttribute("type", "text/css");
44+
newLink.setAttribute("href", cssFile);
45+
46+
document.getElementsByTagName("head").item(0).replaceChild(newLink, oldLink);
47+
}
48+
</script>
3649
</head>
3750
<body>
3851
<h1>PHP LibDiff - Examples</h1>
52+
<aside>
53+
<h2>Change Theme</h2>
54+
<a href="#" onclick="changeCSS('styles.css', 0);">Light Theme</a>
55+
<a href="#" onclick="changeCSS('dark-theme.css', 0);">Dark Theme</a>
56+
</aside>
3957
<hr />
4058

4159
<h2>HTML Side by Side Diff</h2>

lib/Autoloader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @author Mario Brandt <[email protected]>
1414
* @copyright (c) 2015 Mario Brandt
1515
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
16-
* @version 1.17
16+
* @version 1.18
1717
* @link https://github.com/JBlond/php-diff
1818
*/
1919
class Autoloader

lib/jblond/Diff.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
*
2424
* @package jblond
2525
* @author Chris Boulton <[email protected]>
26+
* @author Mario Brandt <[email protected]>
2627
* @author Ferry Cools <[email protected]>
2728
* @copyright (c) 2009 Chris Boulton
2829
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
29-
* @version 1.17
30+
* @version 1.18
3031
* @link https://github.com/JBlond/php-diff
3132
*/
3233
class Diff

lib/jblond/Diff/Renderer/Html/HtmlArray.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
*
1414
* @package jblond\Diff\Renderer\Html
1515
* @author Chris Boulton <[email protected]>
16+
* @author Mario Brandt <[email protected]>
1617
* @author Ferry Cools <[email protected]>
1718
* @copyright (c) 2009 Chris Boulton
1819
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
19-
* @version 1.17
20+
* @version 1.18
2021
* @link https://github.com/JBlond/php-diff
2122
*/
2223
class HtmlArray extends RendererAbstract

lib/jblond/Diff/Renderer/Html/Inline.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
*
1212
* @package jblond\Diff\Renderer\Html
1313
* @author Chris Boulton <[email protected]>
14+
* @author Mario Brandt <[email protected]>
1415
* @author Ferry Cools <[email protected]>
1516
* @copyright (c) 2009 Chris Boulton
1617
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
17-
* @version 1.17
18+
* @version 1.18
1819
* @link https://github.com/JBlond/php-diff
1920
*/
2021
class Inline extends HtmlArray

lib/jblond/Diff/Renderer/Html/SideBySide.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
*
1212
* @package jblond\Diff\Renderer\Html
1313
* @author Chris Boulton <[email protected]>
14+
* @author Mario Brandt <[email protected]>
1415
* @author Ferry Cools <[email protected]>
1516
* @copyright (c) 2009 Chris Boulton
1617
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
17-
* @version 1.17
18+
* @version 1.18
1819
* @link https://github.com/JBlond/php-diff
1920
*/
2021
class SideBySide extends HtmlArray

lib/jblond/Diff/Renderer/Html/Unified.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
* PHP version 7.2 or greater
1111
*
1212
* @package jblond\Diff\Renderer\Html
13+
* @author Mario Brandt <[email protected]>
1314
* @author Ferry Cools <[email protected]>
1415
* @copyright (c) 2009 Chris Boulton
1516
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
16-
* @version 1.17
17+
* @version 1.18
1718
* @link https://github.com/JBlond/php-diff
1819
*/
1920
class Unified extends HtmlArray

lib/jblond/Diff/Renderer/RendererAbstract.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
*
1414
* @package jblond\Diff\Renderer
1515
* @author Chris Boulton <[email protected]>
16+
* @author Mario Brandt <[email protected]>
1617
* @author Ferry Cools <[email protected]>
1718
* @copyright (c) 2009 Chris Boulton
1819
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
19-
* @version 1.17
20+
* @version 1.18
2021
* @link https://github.com/JBlond/php-diff
2122
*/
2223
abstract class RendererAbstract

lib/jblond/Diff/Renderer/Text/Context.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
*
1414
* @package jblond\Diff\Renderer\Text
1515
* @author Chris Boulton <[email protected]>
16+
* @author Mario Brandt <[email protected]>
1617
* @author Ferry Cools <[email protected]>
1718
* @copyright (c) 2009 Chris Boulton
1819
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
19-
* @version 1.17
20+
* @version 1.18
2021
* @link https://github.com/JBlond/php-diff
2122
*/
2223
class Context extends RendererAbstract

lib/jblond/Diff/Renderer/Text/Unified.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
*
1414
* @package jblond\Diff\Renderer\Text
1515
* @author Chris Boulton <[email protected]>
16+
* @author Mario Brandt <[email protected]>
1617
* @copyright (c) 2009 Chris Boulton
1718
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
18-
* @version 1.17
19+
* @version 1.18
1920
* @link https://github.com/JBlond/php-diff
2021
*/
2122

0 commit comments

Comments
 (0)