-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(text-editor): add support for new validation designs
- Loading branch information
Showing
15 changed files
with
387 additions
and
298 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
// component preview locators | ||
export const TEXT_EDITOR_COUNTER = '[data-component="text-editor-counter"]'; | ||
export const TEXT_EDITOR_INPUT = '[role="textbox"]'; | ||
export const TEXT_EDITOR_TOOLBAR = '[data-component="text-editor-toolbar"]'; | ||
export const TEXT_EDITOR_CONTAINER = '[data-component="text-editor-container"]'; |
40 changes: 0 additions & 40 deletions
40
src/components/text-editor/__internal__/editor-counter/editor-counter.component.tsx
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
src/components/text-editor/__internal__/editor-counter/editor-counter.spec.tsx
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/components/text-editor/__internal__/editor-counter/editor-counter.style.ts
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
src/components/text-editor/__internal__/editor-counter/index.ts
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...ext-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.tsx
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,31 @@ | ||
import React from "react"; | ||
|
||
import StyledValidationWrapper from "./editor-validation-wrapper.style"; | ||
import ValidationIcon from "../../../../__internal__/validations"; | ||
|
||
export interface EditorValidationWrapperProps { | ||
/** Message to be displayed when there is an error */ | ||
error?: string; | ||
/** Message to be displayed when there is a warning */ | ||
warning?: string; | ||
/** Message to be displayed when there is an info */ | ||
info?: string; | ||
} | ||
|
||
const ValidationWrapper = ({ | ||
error, | ||
warning, | ||
info, | ||
}: EditorValidationWrapperProps) => ( | ||
<StyledValidationWrapper data-component="text-editor-validation-wrapper"> | ||
<ValidationIcon | ||
error={error} | ||
warning={warning} | ||
info={info} | ||
tooltipPosition="top" | ||
tabIndex={0} | ||
/> | ||
</StyledValidationWrapper> | ||
); | ||
|
||
export default ValidationWrapper; |
42 changes: 42 additions & 0 deletions
42
...nts/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.spec.tsx
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 @@ | ||
import React from "react"; | ||
import { mount } from "enzyme"; | ||
import { assertStyleMatch } from "../../../../__spec_helper__/test-utils"; | ||
import ValidationWrapper, { | ||
EditorValidationWrapperProps, | ||
} from "./editor-validation-wrapper.component"; | ||
import ValidationIcon from "../../../../__internal__/validations"; | ||
|
||
const render = (props: EditorValidationWrapperProps = {}, renderer = mount) => { | ||
return renderer(<ValidationWrapper {...props} />); | ||
}; | ||
|
||
describe("EditorValidationWrapper", () => { | ||
it("has the expected styles", () => { | ||
const wrapper = render(); | ||
assertStyleMatch( | ||
{ | ||
margin: | ||
"var(--spacing200) var(--spacing200) var(--spacing000) var(--spacing050)", | ||
minWidth: "var(--sizing500)", | ||
height: "var(--sizing275)", | ||
float: "right", | ||
alignItems: "center", | ||
}, | ||
wrapper | ||
); | ||
}); | ||
|
||
describe("with validation", () => { | ||
it.each([ | ||
{ error: "error" }, | ||
{ warning: "warning" }, | ||
{ info: "info" }, | ||
] as const)("renders the icon when a message is provided", (msg) => { | ||
expect( | ||
render({ ...msg }) | ||
.find(ValidationIcon) | ||
.exists() | ||
).toEqual(true); | ||
}); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
...nts/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.ts
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,13 @@ | ||
import styled from "styled-components"; | ||
|
||
const StyledValidationWrapper = styled.div` | ||
margin: var(--spacing200) var(--spacing200) var(--spacing000) | ||
var(--spacing050); | ||
min-width: var(--sizing500); | ||
height: var(--sizing275); | ||
display: flex; | ||
float: right; | ||
align-items: center; | ||
`; | ||
|
||
export default StyledValidationWrapper; |
2 changes: 2 additions & 0 deletions
2
src/components/text-editor/__internal__/editor-validation-wrapper/index.ts
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,2 @@ | ||
export { default } from "./editor-validation-wrapper.component"; | ||
export type { EditorValidationWrapperProps } from "./editor-validation-wrapper.component"; |
Oops, something went wrong.