-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(a11y): allow user to pass custom description for screen readers #1111
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2c70752
feat: add custom chart description for a11y
rshen91 9980abf
fix: update chart api
rshen91 19de31a
test: update unit tests
rshen91 e85002b
test: add a unit test
rshen91 a2516f4
Merge remote-tracking branch 'upstream/master' into pass-labels
rshen91 4eca5a8
test: make unit tests better
rshen91 6abaf36
fix: fix the ternary in xy charts
rshen91 3b13cc9
feat: add code review changes
rshen91 c482a3e
Merge remote-tracking branch 'upstream/master' into pass-labels
rshen91 76cc6b3
chore: update charts api
rshen91 75df86b
feat: clean up code
rshen91 2f16536
style: remove playground changes
rshen91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Binary file added
BIN
+27 KB
...all-stories-test-cases-add-custom-description-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,77 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { Store } from 'redux'; | ||
|
||
import { MockGlobalSpec, MockSeriesSpec } from '../../../mocks/specs'; | ||
import { MockStore } from '../../../mocks/store/store'; | ||
import { GlobalChartState } from '../../../state/chart_state'; | ||
import { getSettingsSpecSelector } from '../../../state/selectors/get_settings_specs'; | ||
|
||
describe('custom description for screen readers', () => { | ||
let store: Store<GlobalChartState>; | ||
beforeEach(() => { | ||
store = MockStore.default(); | ||
MockStore.addSpecs( | ||
[ | ||
MockSeriesSpec.bar({ | ||
data: [ | ||
{ x: 1, y: 10 }, | ||
{ x: 2, y: 5 }, | ||
], | ||
}), | ||
], | ||
store, | ||
); | ||
MockStore.addSpecs([MockGlobalSpec.settings()], store); | ||
markov00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
it('should test defaults', () => { | ||
const state = store.getState(); | ||
const descriptionValue = getSettingsSpecSelector(state).description; | ||
const defaultGeneratedSeriesTypes = getSettingsSpecSelector(state).useDefaultSummary; | ||
expect(descriptionValue).toBeUndefined(); | ||
expect(defaultGeneratedSeriesTypes).toBeTrue(); | ||
markov00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
it('should allow user to set a custom description for chart', () => { | ||
MockStore.addSpecs( | ||
[ | ||
MockGlobalSpec.settings({ | ||
description: 'This is sample Kibana data', | ||
}), | ||
], | ||
store, | ||
); | ||
const state = store.getState(); | ||
const descriptionValue = getSettingsSpecSelector(state).description; | ||
expect(descriptionValue).toBe('This is sample Kibana data'); | ||
markov00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
it('should be able to disable generated descriptions', () => { | ||
MockStore.addSpecs( | ||
[ | ||
MockGlobalSpec.settings({ | ||
useDefaultSummary: false, | ||
}), | ||
], | ||
store, | ||
); | ||
const state = store.getState(); | ||
const disableGeneratedSeriesTypes = getSettingsSpecSelector(state).useDefaultSummary; | ||
expect(disableGeneratedSeriesTypes).toBe(false); | ||
markov00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
}); |
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,42 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { boolean, text } from '@storybook/addon-knobs'; | ||
import React from 'react'; | ||
|
||
import { AreaSeries, Chart, ScaleType, Settings } from '../../src'; | ||
import { KIBANA_METRICS } from '../../src/utils/data_samples/test_dataset_kibana'; | ||
|
||
export const Example = () => { | ||
const automatedSeries = boolean('Use the default generated series types of charts for screen readers', true); | ||
const customDescriptionForScreenReaders = text('custom description for screen readers', ''); | ||
return ( | ||
<Chart className="story-chart"> | ||
<Settings description={customDescriptionForScreenReaders} useDefaultSummary={automatedSeries} /> | ||
<AreaSeries | ||
id="area" | ||
xScaleType={ScaleType.Time} | ||
yScaleType={ScaleType.Linear} | ||
xAccessor={0} | ||
yAccessors={[1]} | ||
data={KIBANA_METRICS.metrics.kibana_os_load[0].data} | ||
/> | ||
</Chart> | ||
); | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.