-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix isDecorated not working, added nicer scrollbar
- Loading branch information
1 parent
41bb1a0
commit 37d6f4a
Showing
7 changed files
with
107 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.osiris.desku.ui.css; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CSS { | ||
/** | ||
* https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | ||
*/ | ||
public String selector; | ||
public List<Theme.Attribute> attributes = new ArrayList<>(); | ||
|
||
public CSS(String selector) { | ||
this.selector = selector; | ||
} | ||
|
||
/** | ||
* Replaces all hyphens by their uppercase version | ||
* of their next char. | ||
*/ | ||
public static String getJSCompatibleCSSKey(String s){ | ||
int indexOfHyphen = 0; | ||
while(true){ | ||
indexOfHyphen = s.indexOf("-"); | ||
if(indexOfHyphen == -1) break; | ||
String c = String.valueOf(s.charAt(indexOfHyphen + 1)); | ||
s = s.replaceAll("-"+c, c.toUpperCase()); | ||
} | ||
return s; | ||
} | ||
|
||
public String toCSS() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(selector+"{\n"); | ||
for (Attribute attr : attributes) { | ||
sb.append(" ").append(attr.getKey()).append(": ").append(attr.getValue()).append(";\n"); | ||
} | ||
sb.append("}\n"); | ||
return sb.toString(); | ||
} | ||
|
||
public class Attribute extends org.jsoup.nodes.Attribute { | ||
public Attribute(String key, String value) { | ||
super(key, value); | ||
attributes.add(this); | ||
} | ||
|
||
public String toCSS() { | ||
return getKey() + ": " + getValue() + "; "; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.osiris.desku.ui.css; | ||
|
||
public class Scrollbar extends CSS{ | ||
|
||
public Attribute width = new Attribute("width", "0.5rem"); | ||
public Attribute height = new Attribute("height", "0.5rem"); | ||
public Attribute backgroundClip = new Attribute("background-clip", "padding-box"); | ||
public Attribute border = new Attribute("border", "0.1rem solid transparent"); | ||
public Attribute color = new Attribute("color", "rgba(0, 0, 0, 0.3)"); | ||
public Thumb thumb = new Thumb(); | ||
|
||
public Scrollbar() { | ||
super("*::-webkit-scrollbar,\n" + | ||
"*::-webkit-scrollbar-thumb"); | ||
} | ||
|
||
@Override | ||
public String toCSS() { | ||
return super.toCSS() + thumb.toCSS(); | ||
} | ||
|
||
public class Thumb extends CSS{ | ||
|
||
public Attribute boxShadow = new Attribute("box-shadow", "inset 0 0 0 10px"); | ||
|
||
public Thumb() { | ||
super("*::-webkit-scrollbar-thumb"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters