Skip to content

Commit

Permalink
showBorder attribute for graph (Doenet#1981)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp authored Mar 7, 2023
1 parent 6b9db14 commit bb084b3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/DoenetML/tagSpecific/answer.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ describe('Answer Tag Tests', function () {


cy.log("Pressing enter does not submit")
cy.get(textinputAnchor).type(`{enter}`);
cy.get(textinputAnchor).type(`{enter}`).blur();

cy.log('Test value displayed in browser')
cy.get(textinputAnchor).should('have.value', ' hello there \n');
Expand Down
29 changes: 29 additions & 0 deletions cypress/e2e/DoenetML/tagSpecific/graph.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1979,4 +1979,33 @@ describe('Graph Tag Tests', function () {

});

it('show border', () => {
cy.window().then(async (win) => {
win.postMessage({
doenetML: `
<text>a</text>
<graph>
</graph>
<graph showBorder>
</graph>
<graph showBorder="false">
</graph>
`}, "*");
});

cy.get('#\\/_text1').should('have.text', 'a') //wait for page to load

// not sure what to test as don't know how to check renderer...
cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
expect(stateVariables["/_graph1"].stateValues.showBorder).eq(true);
expect(stateVariables["/_graph2"].stateValues.showBorder).eq(true);
expect(stateVariables["/_graph3"].stateValues.showBorder).eq(false);
})

});

});
8 changes: 8 additions & 0 deletions src/Core/components/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ export default class Graph extends BlockComponent {
defaultValue: false,
public: true,
};

attributes.showBorder = {
createComponentOfType: "boolean",
createStateVariable: "showBorder",
defaultValue: true,
public: true,
forRenderer: true,
};
return attributes;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Viewer/core.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/Viewer/renderers/graph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ export default React.memo(function Graph(props) {
outerStyle = { display: "flex", justifyContent: SVs.horizontalAlign };
}

divStyle.border = "2px solid var(--canvastext)";
if (SVs.showBorder) {
divStyle.border = "2px solid var(--canvastext)";
} else {
divStyle.border = "none";
}
divStyle.marginBottom = "12px";
divStyle.marginTop = "12px";
divStyle.backgroundColor = "var(--canvas)";
Expand Down

0 comments on commit bb084b3

Please sign in to comment.