-
Notifications
You must be signed in to change notification settings - Fork 77
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
Component: Tooltips #164
Closed
Closed
Component: Tooltips #164
Changes from 8 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
97645c4
tooltip start
driskull 0aa2c43
tooltip progress
driskull f391f0b
progress
driskull d52c99e
arrow setup
driskull 9b62f48
tests
driskull 96948b8
cleanup
driskull 6aef4f8
ready for styling
driskull 28ef028
update demo
driskull 17c2111
review fix
driskull ac750bc
use slot for image
driskull 746d71c
update readme/test
driskull 3b9b89c
add slot doc
driskull 591e72c
image demo
driskull aa665bb
some styling updates
5e6d9e7
Added dark theme
8f746ec
updated background var
688638d
presentation cleanup
28ef8ea
fit kitty.
driskull 53df32d
get arrow showing
driskull 7066381
arrow variable
driskull 07785ae
fix BG var
driskull 44325a6
margin for pointer.
driskull 999bd34
placement options
driskull ad88e74
fix test.
driskull 0d539f6
popover arrow styles.
driskull abe8004
DRY css
driskull 0e1b1dd
Update readme.md
driskull dd46d07
2px border radius
driskull c794d03
simplify tooltip to just hover
driskull c2b30db
Merge branch 'master' into dris0000/calcite-tooltip
driskull eb6b2a4
remove module
driskull 5d22e3d
Updates css, removes stale classes
macandcheese 20544b7
Removed unused CSS variable
1bd92b6
Removed hover and pressed states
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
import { newE2EPage } from "@stencil/core/testing"; | ||
|
||
import { defaults, hidden, renders } from "../../tests/commonTests"; | ||
|
||
import { CSS } from "./resources"; | ||
|
||
describe("calcite-tooltip", () => { | ||
it("renders", async () => renders("calcite-tooltip")); | ||
|
||
it("honors hidden attribute", async () => hidden("calcite-tooltip")); | ||
|
||
it("has property defaults", async () => | ||
defaults("calcite-tooltip", [ | ||
{ | ||
propertyName: "image", | ||
defaultValue: undefined | ||
}, | ||
{ | ||
propertyName: "imageLabel", | ||
defaultValue: undefined | ||
}, | ||
{ | ||
propertyName: "interaction", | ||
defaultValue: "hover" | ||
}, | ||
{ | ||
propertyName: "open", | ||
defaultValue: false | ||
}, | ||
{ | ||
propertyName: "placement", | ||
defaultValue: "auto" | ||
}, | ||
{ | ||
propertyName: "referenceElement", | ||
defaultValue: undefined | ||
}, | ||
{ | ||
propertyName: "text", | ||
defaultValue: undefined | ||
}, | ||
{ | ||
propertyName: "theme", | ||
defaultValue: "light" | ||
} | ||
])); | ||
|
||
it("popover positions when referenceElement is set", async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent( | ||
`<calcite-tooltip open></calcite-tooltip><div>referenceElement</div>` | ||
); | ||
|
||
const element = await page.find("calcite-tooltip"); | ||
|
||
await page.$eval("calcite-tooltip", (elm: any) => { | ||
const referenceElement = document.createElement("div"); | ||
document.body.appendChild(referenceElement); | ||
elm.referenceElement = referenceElement; | ||
}); | ||
|
||
await page.waitForChanges(); | ||
|
||
const computedStyle = await element.getComputedStyle(); | ||
|
||
expect(computedStyle.transform).not.toBe("none"); | ||
}); | ||
|
||
it("open popover should be visible", async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent( | ||
`<calcite-tooltip></calcite-tooltip><div>referenceElement</div>` | ||
); | ||
|
||
const element = await page.find("calcite-tooltip"); | ||
|
||
await page.$eval("calcite-tooltip", (elm: any) => { | ||
const referenceElement = document.createElement("div"); | ||
document.body.appendChild(referenceElement); | ||
elm.referenceElement = referenceElement; | ||
}); | ||
|
||
await page.waitForChanges(); | ||
|
||
const container = await page.find(`calcite-tooltip >>> .${CSS.container}`); | ||
|
||
expect(await container.isVisible()).toBe(false); | ||
|
||
element.setProperty("open", true); | ||
|
||
await page.waitForChanges(); | ||
|
||
expect(await container.isVisible()).toBe(true); | ||
}); | ||
|
||
it("should accept referenceElement as string id", async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent( | ||
`<calcite-tooltip reference-element="ref" open>content</calcite-tooltip><div id="ref">referenceElement</div>` | ||
); | ||
|
||
await page.waitForChanges(); | ||
|
||
const container = await page.find(`calcite-tooltip >>> .${CSS.container}`); | ||
|
||
await page.waitForChanges(); | ||
|
||
expect(await container.isVisible()).toBe(true); | ||
|
||
const element = await page.find("calcite-tooltip"); | ||
|
||
const computedStyle = await element.getComputedStyle(); | ||
|
||
expect(computedStyle.transform).not.toBe("none"); | ||
}); | ||
|
||
it("should honor hover interaction", async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent( | ||
`<calcite-tooltip reference-element="ref" interaction="hover">content</calcite-tooltip><div id="ref">referenceElement</div>` | ||
); | ||
|
||
await page.waitForChanges(); | ||
|
||
const container = await page.find(`calcite-tooltip >>> .${CSS.container}`); | ||
|
||
expect(await container.isVisible()).toBe(false); | ||
|
||
const ref = await page.find("#ref"); | ||
|
||
await ref.hover(); | ||
|
||
expect(await container.isVisible()).toBe(true); | ||
}); | ||
|
||
it("should honor click interaction", async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent( | ||
`<calcite-tooltip reference-element="ref" interaction="click">content</calcite-tooltip><div id="ref">referenceElement</div>` | ||
); | ||
|
||
await page.waitForChanges(); | ||
|
||
const container = await page.find(`calcite-tooltip >>> .${CSS.container}`); | ||
|
||
expect(await container.isVisible()).toBe(false); | ||
|
||
const ref = await page.find("#ref"); | ||
|
||
await ref.click(); | ||
|
||
expect(await container.isVisible()).toBe(true); | ||
|
||
await ref.click(); | ||
|
||
expect(await container.isVisible()).toBe(false); | ||
}); | ||
|
||
it("should honor image & imageLabel", async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent( | ||
`<calcite-tooltip reference-element="ref" image="http://placekitten.com/200/300" image-label="hi" open>content</calcite-tooltip><div id="ref">referenceElement</div>` | ||
); | ||
|
||
await page.waitForChanges(); | ||
|
||
const image = await page.find(`calcite-tooltip >>> .${CSS.image}`); | ||
|
||
expect(await image.isVisible()).toBe(true); | ||
|
||
expect(image.getAttribute("alt")).toBe("hi"); | ||
}); | ||
|
||
it("should honor text", async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent( | ||
`<calcite-tooltip reference-element="ref" text="hi" open>content</calcite-tooltip><div id="ref">referenceElement</div>` | ||
); | ||
|
||
await page.waitForChanges(); | ||
|
||
const content = await page.find(`calcite-tooltip >>> .${CSS.content}`); | ||
|
||
expect(await content.isVisible()).toBe(true); | ||
|
||
expect(content.textContent).toBe("hi"); | ||
}); | ||
}); |
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,96 @@ | ||
:host { | ||
display: block; | ||
position: absolute; | ||
z-index: 999; | ||
top: -999999px; | ||
left: -999999px; | ||
} | ||
|
||
.container { | ||
visibility: hidden; | ||
background-color: #fff; | ||
padding: 5px 10px; | ||
box-shadow: $shadow-2; | ||
border-radius: 2px; | ||
max-width: 200px; | ||
max-height: 200px; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.container--open { | ||
visibility: visible; | ||
} | ||
|
||
.image { | ||
flex: 1; | ||
overflow: hidden; | ||
} | ||
|
||
.content { | ||
position: relative; | ||
flex: 1; | ||
} | ||
|
||
.close-button { | ||
position: absolute; | ||
top: 0; | ||
z-index: 1; | ||
right: 0; | ||
background: transparent; | ||
padding: 5px; | ||
border: none; | ||
display: block; | ||
} | ||
|
||
.arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="top"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="top-end"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="right"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="right-start"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="right-end"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="bottom-end"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="right-end"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="bottom"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="bottom-start"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="left-end"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="left"]) .arrow { | ||
display: block; | ||
} | ||
|
||
:host([x-placement="left-start"]) .arrow { | ||
display: block; | ||
} |
Oops, something went wrong.
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.
Should use 2px border-radius where this is adjacent to the container top corner / bottom corner (depending on type)