Skip to content

Commit

Permalink
Fix classes
Browse files Browse the repository at this point in the history
  • Loading branch information
nik9000 committed Dec 7, 2023
1 parent 4bfeb05 commit 2746233
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 16 deletions.
3 changes: 3 additions & 0 deletions docs/reference/esql/functions/binary.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ And these mathematical operators are supported:

[.text-center]
image::esql/functions/signature/add.svg[Embedded,opts=inline]

[.text-center]
image::esql/functions/signature/sub.svg[Embedded,opts=inline]
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/div.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/equals.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/greater_than.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/less_than.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/mod.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/mul.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/neg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/not_equals.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/sub.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,18 @@ private static String toSvg(Expression exp) throws IOException {
* on all clients.
*/
private static String tightenStyles(String svg) {
return svg.replace(".c", "#guide .c").replace(".k", "#guide .k").replace(".s", "#guide .s");
for (String c : new String[] { "c", "k", "s", "j", "l" }) {
svg = svg.replace("." + c, "#guide ." + c);
}
return svg;
}

/**
* Like a literal but with light grey text for a more muted appearance for syntax.
*/
private static class Syntax extends Literal {
private static final String LITERAL_CLASS = "l";
private static final String SYNTAX_CLASS = "lsyn";
private static final String LITERAL_TEXT_CLASS = "j";
private static final String SYNTAX_TEXT_CLASS = "syn";
private static final String SYNTAX_GREY = "8D8D8D";
Expand All @@ -133,13 +138,20 @@ private Syntax(String text) {

@Override
protected RRElement toRRElement(GrammarToRRDiagram grammarToRRDiagram) {
// This performs a monumentally rude hack to replace the text color of this element.
/*
* This performs a monumentally rude hack to replace the text color of this element.
* It renders a "literal" element but intercepts the layer that defines it's css class
* and replaces it with our own.
*/
return new RRText(RRText.Type.LITERAL, text, null) {
@Override
protected void toSVG(RRDiagramToSVG rrDiagramToSVG, int xOffset, int yOffset, RRDiagram.SvgContent svgContent) {
super.toSVG(rrDiagramToSVG, xOffset, yOffset, new RRDiagram.SvgContent() {
@Override
public String getDefinedCSSClass(String style) {
if (style.equals(LITERAL_CLASS)) {
return svgContent.getDefinedCSSClass(SYNTAX_CLASS);
}
if (style.equals(LITERAL_TEXT_CLASS)) {
return svgContent.getDefinedCSSClass(SYNTAX_TEXT_CLASS);
}
Expand All @@ -148,11 +160,18 @@ public String getDefinedCSSClass(String style) {

@Override
public String setCSSClass(String cssClass, String definition) {
if (false == cssClass.equals(LITERAL_TEXT_CLASS)) {
return svgContent.setCSSClass(cssClass, definition);
if (cssClass.equals(LITERAL_CLASS)) {
svgContent.setCSSClass(cssClass, definition);
return svgContent.setCSSClass(SYNTAX_CLASS, definition);
}
if (cssClass.equals(LITERAL_TEXT_CLASS)) {
svgContent.setCSSClass(cssClass, definition);
return svgContent.setCSSClass(
SYNTAX_TEXT_CLASS,
definition.replace("fill:#000000", "fill:#" + SYNTAX_GREY)
);
}
svgContent.setCSSClass(cssClass, definition);
return svgContent.setCSSClass(SYNTAX_TEXT_CLASS, definition.replace("fill:#000000", "fill:#" + SYNTAX_GREY));
return svgContent.setCSSClass(cssClass, definition);
}

@Override
Expand Down

0 comments on commit 2746233

Please sign in to comment.