Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ exports[`Switch Switch renders correctly with all options set 1`] = `
<div
className="obojobo-draft--components--switch"
>
<span
contentEditable={false}
<div
className="text-content"
>
mocktitle
</span>
<span
contentEditable={false}
>
mocktitle
</span>
<br />
<small />
</div>
<label
className="switch"
>
Expand All @@ -29,6 +35,12 @@ exports[`Switch Switch renders correctly with no options set 1`] = `
<div
className="obojobo-draft--components--switch"
>
<div
className="text-content"
>
<br />
<small />
</div>
<label
className="switch"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,82 @@ exports[`SimpleDialog SimpleDialog cancelOk 1`] = `
</div>
`;

exports[`SimpleDialog SimpleDialog cancelOrCustomYes 1`] = `
<div
className="obojobo-draft--components--modal--simple-dialog"
>
<div
className="obojobo-draft--components--modal--dialog "
style={null}
>
<div
aria-labelledby="obojobo-draft--components--modal--modal--content"
className="obojobo-draft--components--modal--modal"
role="dialog"
tabIndex="-1"
>
<input
aria-label="Start of dialog"
className="first-tab"
onFocus={[Function]}
type="text"
/>
<div
className="content"
id="obojobo-draft--components--modal--modal--content"
>
<div
className="dialog-content"
style={
Object {
"textAlign": "center",
}
}
>
Content
</div>
<div
className="controls"
>
<div
className="obojobo-draft--components--button alt-action is-not-dangerous align-center"
contentEditable={false}
>
<button
className="button"
contentEditable={false}
onClick={[MockFunction]}
type="button"
>
Cancel
</button>
</div>
<div
className="obojobo-draft--components--button is-not-dangerous align-center"
contentEditable={false}
>
<button
className="button"
contentEditable={false}
onClick={[MockFunction]}
type="button"
>
OK
</button>
</div>
</div>
</div>
<input
aria-label="End of dialog"
className="last-tab"
onFocus={[Function]}
type="text"
/>
</div>
</div>
</div>
`;

exports[`SimpleDialog SimpleDialog no type 1`] = `
<div
className="obojobo-draft--components--modal--simple-dialog"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ describe('SimpleDialog', () => {
expect(tree).toMatchSnapshot()
})

test('SimpleDialog cancelOrCustomYes', () => {
const component = renderer.create(
<SimpleDialog cancelOrCustomYes onCancel={jest.fn()} onConfirm={jest.fn()}>
Content
</SimpleDialog>
)
const tree = component.toJSON()

expect(tree).toMatchSnapshot()
})

test('SimpleDialog no type', () => {
const component = renderer.create(
<SimpleDialog onCancel={jest.fn()} onConfirm={jest.fn()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ describe('Switch', () => {
expect(checkbox.children).toEqual(['mocktitle'])
})

test('Switch renders correctly with a description', () => {
const testRenderer = TestRenderer.create(
<Switch title="mocktitle" description="mockDescription" />
)
const testInstance = testRenderer.root
const small = testInstance.findByType('small')
expect(small.children).toEqual(['mockDescription'])
})

test('Switch renders when unchecked', () => {
const testRenderer = TestRenderer.create(<Switch checked={false} />)
const testInstance = testRenderer.root
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ class SimpleDialog extends React.Component {
default: true
}
]
} else if (this.props.cancelOrCustomYes) {
buttons = [
{
value: 'Cancel',
altAction: true,
onClick: this.props.onCancel
},
{
value: this.props.customYes || 'OK',
onClick: this.props.onConfirm,
default: true
}
]
} else {
buttons = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import './switch.scss'
/* istanbul ignore next */
const noOp = () => {}

const SwitchCore = ({ checked = false, onChange = noOp, title, forwardedRef }) => (
const SwitchCore = ({ checked = false, onChange = noOp, title, description, forwardedRef }) => (
<div className="obojobo-draft--components--switch">
{title ? <span contentEditable={false}>{title}</span> : null}
<div className="text-content">
{title ? <span contentEditable={false}>{title}</span> : null}
<br />
<small>{description && description}</small>
</div>
<label className="switch">
<input
className="switch-slider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

.obojobo-draft--components--switch {
position: relative;
height: 1.3em;

//@HACK: Fixes the .info dialog being blurry sometimes in CHROME
transform: translate3d(0, 0, 0);
z-index: 1;

.text-content {
width: 85%;
}

> span {
padding-right: 0.5em;
Expand All @@ -11,6 +18,7 @@

.switch {
position: absolute;
right: 0;
display: inline-block;
width: 2.6em;
height: 1em;
Expand Down Expand Up @@ -86,4 +94,10 @@
left: 37%;
}
}

small {
font-size: 0.8em;
color: $color-neutral-text;
margin-top: 0;
}
}
2 changes: 2 additions & 0 deletions packages/app/obojobo-document-engine/src/scss/_includes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ $color-reward: #ffe65d;
$color-reward-text: #947d00;
$color-obojobo-blue: #0d4fa7;
$color-preview: #af1b5c;
$color-neutral: #f3f3f3;
$color-neutral-text: #b4b3b4;

$box-shadow-focus: 0 0 3px 3px $color-browser-focus;
$box-shadow-overlay: 0 2px 2px $color-shadow;
Expand Down
Loading