Skip to content
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(OnyxTooltip): auto align tooltip #1821

Merged
merged 41 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
797c5b9
test
Chrisiboiii Aug 30, 2024
3ecd118
test
ChristianBusshoff Sep 2, 2024
a955742
Fix float behavior
MajaZarkova Sep 2, 2024
3784894
fix: made tooltip-classes computed
Chrisiboiii Sep 2, 2024
680ad65
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Sep 2, 2024
00f336b
remove paddings in stories.ts
ChristianBusshoff Sep 3, 2024
aa50aa0
resolve comments
ChristianBusshoff Sep 3, 2024
8c3595b
change trigger type to object
ChristianBusshoff Sep 5, 2024
8d361b4
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Sep 5, 2024
4addc2f
fix: spacing
ChristianBusshoff Sep 5, 2024
0171679
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Sep 6, 2024
97c929d
chore: update Playwright screenshots (#1838)
github-actions[bot] Sep 6, 2024
acdf3c7
fix screeshottests: Checkbox (invalid), CheckboxGroup, Switch (invalid)
ChristianBusshoff Sep 8, 2024
dff028c
chore: update Playwright screenshots (#1840)
github-actions[bot] Sep 8, 2024
db05563
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 1, 2024
88bf240
resolve comments
ChristianBusshoff Oct 1, 2024
89962e1
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 2, 2024
bc52d98
fix: tooltip screenshot-test
ChristianBusshoff Oct 2, 2024
8f2cb08
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 3, 2024
f8f4683
chore: update Playwright screenshots (#1919)
github-actions[bot] Oct 4, 2024
f415585
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 9, 2024
803ad8b
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 9, 2024
e20fe2a
resolved comments
ChristianBusshoff Oct 10, 2024
eeb30cf
fix WedgePosition import
ChristianBusshoff Oct 10, 2024
2aeef57
change tooltip type
ChristianBusshoff Oct 10, 2024
e48da24
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 10, 2024
c0b9e54
change trigger type
ChristianBusshoff Oct 10, 2024
6e4b54c
chore: update Playwright screenshots (#1944)
github-actions[bot] Oct 10, 2024
5f39ca9
fix prettier issue
ChristianBusshoff Oct 10, 2024
6cf0a8a
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 11, 2024
e23de9c
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 14, 2024
a5b0326
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 15, 2024
d671221
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 15, 2024
bc6d8b4
remove tooltip error css
ChristianBusshoff Oct 16, 2024
a1452fd
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 18, 2024
4725cbd
chore: update Playwright screenshots (#1975)
github-actions[bot] Oct 18, 2024
e5de85e
changed type declaration
ChristianBusshoff Oct 18, 2024
f1d710a
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 21, 2024
e8be29b
Merge branch 'main' into feat/730-auto-alignment-Tooltip
ChristianBusshoff Oct 24, 2024
57ca2bb
fix: eslint error
ChristianBusshoff Oct 24, 2024
aa3f7a1
docs(changeset): Implement autoalignment feature for OnyxTooltip
ChristianBusshoff Oct 25, 2024
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
5 changes: 5 additions & 0 deletions .changeset/happy-carrots-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sit-onyx": patch
---

Implement autoalignment feature for OnyxTooltip
32 changes: 29 additions & 3 deletions apps/demo-app/src/views/HomeView.vue
larsrickert marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,30 @@ const currentPage = ref(1);
label="Show toast"
@click="toast.show({ headline: 'Example toast', color: 'success' })"
/>
<OnyxHeadline is="h2">Tooltip (auto alignment)</OnyxHeadline>

<OnyxTooltip v-if="show('OnyxTooltip')" text="Example tooltip text">
Hover me to show tooltip
</OnyxTooltip>
<div v-if="show('OnyxTooltip')" class="tooltip-container">
<OnyxTooltip text="Example tooltip text">
<template #default="{ trigger }">
<OnyxButton label="Left" v-bind="trigger" />
</template>
</OnyxTooltip>
<OnyxTooltip text="Example tooltip text">
<template #default="{ trigger }">
<OnyxButton label="Center" v-bind="trigger" />
</template>
</OnyxTooltip>
<OnyxTooltip text="Example tooltip text">
<template #default="{ trigger }">
<OnyxButton label="Center" v-bind="trigger" />
</template>
</OnyxTooltip>
<OnyxTooltip text="Example tooltip text">
<template #default="{ trigger }">
<OnyxButton label="Right" v-bind="trigger" />
</template>
</OnyxTooltip>
</div>

<!-- Add new components alphabetically. -->
</div>
Expand Down Expand Up @@ -311,4 +331,10 @@ const currentPage = ref(1);
.state-info {
color: var(--onyx-color-text-icons-neutral-soft);
}
.tooltip-container {
display: flex;
justify-content: space-between;
width: 101%;
margin-top: 2rem;
}
</style>
1 change: 1 addition & 0 deletions packages/headless/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./composables/comboBox/createComboBox";
export * from "./composables/helpers/useGlobalListener";
export * from "./composables/listbox/createListbox";
export * from "./composables/menuButton/createMenuButton";
export * from "./composables/navigationMenu/createMenu";
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ test.describe("Screenshot tests", () => {
: "Test error";
return (
<OnyxCheckbox
style={row !== "default" ? "padding-top: 3rem;" : ""}
style={{
...(row !== "default" && { paddingBottom: "3rem" }),
...(column === "hideLabel" && { paddingRight: "3rem" }),
}}
label="Test label"
modelValue={column === "checked"}
indeterminate={column === "indeterminate"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ export const Required = {
...Default.args,
required: true,
},
decorators: [
(story) => ({
components: { story },
template: `
<div style="padding: 2rem 0 0 2.5rem;">
<story />
</div>`,
}),
],
} satisfies Story;

/**
Expand Down Expand Up @@ -108,13 +99,4 @@ export const CustomError = {
longMessage: "Further explanation.",
},
},
decorators: [
(story) => ({
components: { story },
template: `
<div style="padding: 2rem 0 0 5rem;">
<story />
</div>`,
}),
],
} satisfies Story;
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,6 @@ const title = computed(() => {
max-width: var(--onyx-checkbox-input-size);
height: var(--onyx-checkbox-input-size);
}

// hide error tooltip before a user interaction happened
.onyx-error-tooltip:has(&__input):not(:has(&__input:user-invalid)) .onyx-tooltip {
display: none;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ test.describe("Screenshot tests", () => {
name: "CheckboxGroup",
columns: ["default", "checked", "indeterminate"],
rows: ["default", "interacted"],
component: (column) => {
component: (column, row) => {
const options = [...mockOptions, { label: "Invalid", value: 4, customError: "Invalid" }];
const modelValue: number[] = [];
if (column === "checked") {
Expand All @@ -128,7 +128,10 @@ test.describe("Screenshot tests", () => {
label="Checkbox group headline"
withCheckAll
modelValue={modelValue}
style={{ maxWidth: "16rem" }}
style={{
maxWidth: "16rem",
...(row === "interacted" && { paddingBottom: "3rem" }),
}}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ const meta: Meta<typeof OnyxCheckboxGroup> = {
argTypes: {
withCheckAll: { control: { type: "boolean" } },
},
decorators: [
(story) => ({
components: { story },
template: `
<div style="padding-left: 1rem;">
<story />
</div>`,
}),
],
};

export default meta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import OnyxFormElement from "./OnyxFormElement.vue";
*/
const meta: Meta<typeof OnyxFormElement> = {
title: "Support/FormElement",

component: OnyxFormElement,
argTypes: {
default: { control: { disable: true } },
},
decorators: [
(story) => ({
components: { story },
template: `<div style="max-width: 12rem; padding: 2rem 1rem">
template: `<div style="max-width: 12rem">
<story />
</div>`,
}),
Expand Down
18 changes: 0 additions & 18 deletions packages/sit-onyx/src/components/OnyxInput/OnyxInput.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ export const Maxlength: Story = {
minlength: 5,
withCounter: true,
},
decorators: [
(story) => ({
components: { story },
template: `<div style="padding: 0 0 4rem 4rem"> <story /> </div>`,
}),
],
};

/**
Expand Down Expand Up @@ -160,12 +154,6 @@ export const CustomError: Story = {
},
placeholder: "Interact with me to show error",
},
decorators: [
(story) => ({
components: { story },
template: `<div style="padding-bottom: 2rem"> <story /> </div>`,
}),
],
};

/**
Expand All @@ -176,12 +164,6 @@ export const WithLabelTooltip: Story = {
label: "Label",
labelTooltip: "More information",
},
decorators: [
(story) => ({
components: { story },
template: `<div style="padding-top: 2rem"> <story /> </div>`,
}),
],
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ test.describe("Screenshot tests", () => {
component.getByRole("tooltip"),
`should show error tooltip for ${row} and ${column}`,
).toBeVisible();

const tooltipSize = await component
.getByRole("tooltip")
.evaluate((element) => [element.clientHeight, element.clientWidth]);

// set paddings to fit the full tooltip in the screenshot
await component.evaluate(
(element, { tooltipSize: [height] }) => {
const verticalPadding = `${height + 12}px`;
element.style.paddingBottom = verticalPadding;
},
{ tooltipSize },
);
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,4 @@ export const Required = {
name: "radio-required",
required: true,
},
decorators: [
(story) => ({
components: { story },
template: `
<div style="padding: 2rem 0 0 2.5rem;">
<story />
</div>`,
}),
],
} satisfies Story;
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,6 @@ const skeleton = useSkeletonContext(props);
--onyx-radio-button-selector-background-color: var(--onyx-color-base-primary-400);
}

/**
* hide error tooltip if the radio button is valid.
* this happens when a radio group is required and one of the radio buttons is
* checked, the other ones will not update their validityState but will be
* recognized as "valid" by CSS
*/
.onyx-error-tooltip:has(&__selector:valid) .onyx-tooltip {
display: none;
}

&:has(&__selector:invalid) {
--onyx-radio-button-selector-border-color: var(--onyx-color-base-danger-500);
--onyx-radio-button-selector-outline-color: var(--onyx-color-base-danger-200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,6 @@ export const Required = {
modelValue: undefined,
required: true,
},
decorators: [
(story) => ({
components: { story },
template: `
<div style="padding-left: 2rem;">
<story />
</div>`,
}),
],
} satisfies Story;

/**
Expand All @@ -119,13 +110,4 @@ export const CustomError = {
longMessage: "Further explanation.",
},
},
decorators: [
(story) => ({
components: { story },
template: `
<div style="padding-left: 2rem;">
<story />
</div>`,
}),
],
} satisfies Story;
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ export const WithMessage: Story = {
message: "Example message",
messageTooltip: "Additional info message",
},
decorators: [
(story) => ({
components: { story },
template: `<div style="padding-bottom: 2rem"> <story /> </div>`,
}),
],
};

/**
Expand All @@ -134,12 +128,6 @@ export const WithLabelTooltip: Story = {
...Default.args,
labelTooltip: "More information",
},
decorators: [
(story) => ({
components: { story },
template: `<div style="padding-top: 2rem"> <story /> </div>`,
}),
],
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test.describe("Screenshot tests", () => {
: "Test error";
return (
<OnyxSwitch
style={row !== "default" ? "padding-top: 3rem;" : ""}
style={row !== "default" ? "padding-bottom: 3rem;" : ""}
label="Test label"
modelValue={column === "checked"}
customError={customError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ export const Required = {
...Default.args,
required: true,
},
decorators: [
(story) => ({
components: { story },
template: `
<div style="padding: 2rem 0 0 1rem;">
<story />
</div>`,
}),
],
} satisfies Story;

/**
Expand Down Expand Up @@ -107,13 +98,4 @@ export const CustomError = {
longMessage: "Further explanation.",
},
},
decorators: [
(story) => ({
components: { story },
template: `
<div style="padding: 2rem 0 0 4rem;">
<story />
</div>`,
}),
],
} satisfies Story;
5 changes: 0 additions & 5 deletions packages/sit-onyx/src/components/OnyxSwitch/OnyxSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,6 @@ $input-width: calc(2 * var(--onyx-switch-icon-size) - 2 * var(--onyx-switch-cont
color: var(--onyx-color-text-icons-neutral-soft);
}
}

// hide error tooltip before a user interaction happened
.onyx-error-tooltip:has(&__input):not(:has(&__input:user-invalid)) .onyx-tooltip {
display: none;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ export const CustomError: Story = {
},
placeholder: "Interact with me to show error",
},
decorators: [
(story) => ({
components: { story },
template: `<div style="padding-bottom: 2rem"> <story /> </div>`,
}),
],
};

/**
Expand All @@ -156,12 +150,6 @@ export const WithLabelTooltip: Story = {
label: "Label",
labelTooltip: "More Information",
},
decorators: [
(story) => ({
components: { story },
template: `<div style="padding-top: 2rem"> <story /> </div>`,
}),
],
};

/**
Expand Down
Loading
Loading