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

🧹 ✨ refactor(library): upgrade build scripts, fix type defs, add support for hideOnOutsideClick #38

Merged
merged 18 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6ad8907
docs(api): update docs and examples with hideOnOutsideClick
dysfunc Dec 28, 2023
dd8cb84
refactor(types): update typescript config and add/updare typescript …
dysfunc Dec 28, 2023
4869be4
chore(tests): update vitest configs and snapshots
dysfunc Dec 28, 2023
0317028
chore(tooling): update scripts and deps for bundling, linting, and fo…
dysfunc Dec 28, 2023
b19fa51
feat(hideOnOutsideClick): update component and action to support hide…
dysfunc Dec 28, 2023
352ead0
ci(actions): update unit tests workflow
dysfunc Dec 28, 2023
4618863
chore(pm): use pnpm instead of npm
dysfunc Dec 28, 2023
a6d5580
chore(pm): use pnpm instead of npm
dysfunc Dec 28, 2023
9a03c6b
chore(copy): update minor copy changes
dysfunc Dec 28, 2023
e639d84
refactor(handler): adjust onclick handler for action and tooltip
dysfunc Dec 28, 2023
9075d6e
fix(show): fix initial positioning of tooltip using show
dysfunc Dec 28, 2023
fb3ceb2
fix(show): fix initial positioning of tooltip using show
dysfunc Dec 29, 2023
49d957f
fix(action): prevent warning from invalid prop on action component
dysfunc Dec 29, 2023
8afe255
docs(examples): add example of using show with timer
dysfunc Dec 29, 2023
2c78635
fix(position): update positioning logic to handle absolute targets co…
dysfunc Dec 29, 2023
2dc36a1
docs(examples): update copy on examples to showcase outside click and…
dysfunc Dec 30, 2023
07354cd
docs(examples): update copy on examples to showcase outside click and…
dysfunc Dec 30, 2023
30d30e1
chore(version): update package to v3.0.0
dysfunc Dec 30, 2023
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
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"extends": ["eslint:recommended", "plugin:vitest/recommended"],
"ignorePatterns": ["**/*.snap.js"],
"overrides": [
{
"files": ["*.ts"],
"parser": "@typescript-eslint/parser"
},
{
"files": ["*.svelte"],
"parser": "svelte-eslint-parser"
Expand Down
37 changes: 21 additions & 16 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
name: Unit Tests (Vitest)

name: Unit Tests
on:
push:
branches:
- main
paths:
- src/**
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
tests:
runs-on: ubuntu-latest
name: Tests
if: |
(
!contains(github.event.head_commit.message, '[skip ci]') &&
!contains(github.event.head_commit.message, 'version bump')
)
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: Checkout repository
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- uses: szenius/[email protected]
version: 8.11
- name: Install Node
uses: actions/setup-node@v3
with:
timezoneLinux: "America/Los_Angeles"
timezoneMacos: "America/Los_Angeles"
timezoneWindows: "Pacific Standard Time"
- run: npm i
- run: npm test

- uses: actions/upload-artifact@v2
node-version: 20
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install
- name: Run tests
run: pnpm test
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: failure()
with:
name: unit-tests
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
!.storybook

# generated
.vercel
/.vercel
/.package-lock.json
/node_modules
/dist

Expand Down
3 changes: 2 additions & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"./src/**/*.{test.js,js,json,svelte}": [
"./src/**/*.{test.js,ts,json,svelte}": [
"svelte-check --tsconfig ./tsconfig.json",
"eslint -c ./.eslintrc.json --fix",
"prettier --write"
]
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"printWidth": 120,
"printWidth": 80,
"trailingComma": "none",
"tabWidth": 2,
"semi": true,
Expand Down
39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ yarn add -D @svelte-plugins/tooltips
# or with NPM

npm i -D @svelte-plugins/tooltips

# or with PNPM

pnpm i -D @svelte-plugins/tooltips
```

## Using the Tooltip component
Expand Down Expand Up @@ -40,25 +44,26 @@ Checkout out my <u use:tooltip={{ content: 'Hello World!' }}>tooltip</u>
## API

### Props
| Prop | Description | Value |
| :----------- | :------------------------------------------------------------------ | :---------------------------------------------- |
| action | The action that triggers the tooltip (hover | click | prop) | `string` (default: `hover`) |
| animation | The animation to apply to the tooltip | `string` (default: ``) |
| delay | The animation delay in milliseconds to apply to the tooltip | `number` (default: `200`) |
| arrow | If `false`, the tooltip arrow will not be shown. | `boolean` (default: `true`) |
| autoPosition | Adjust tooltip position if viewport clipping occurs | `string` (default: `false`) |
| content | The string or object containing componentref and props | `string` | `object` component (default: ``) |
| maxWidth | The max allowable width of the tooltip content | `number` (default: `200`) |
| position | The position where the tooltip should appear relative to its parent | `string` (default: `top`) |
| theme | The CSS theme class name | `string` (default: ``) |
| show | Allows you to manually control the tooltip visibility | `boolean` (default: `false`) |
| style | The object containing theme variable overrides | `object` (default: `null`) |
| Prop | Description | Value |
| :----------------- | :------------------------------------------------------------------ | :---------------------------------------------- |
| action | The action that triggers the tooltip (hover | click | prop) | `string` (default: `hover`) |
| animation | The animation to apply to the tooltip | `string` (default: ``) |
| arrow | If `false`, the tooltip arrow will not be shown. | `boolean` (default: `true`) |
| autoPosition | Adjust tooltip position if viewport clipping occurs | `boolean` (default: `false`) |
| content | The string or object containing componentref and props | `string` | `object` component (default: ``) |
| delay | The animation delay in milliseconds to apply to the tooltip | `number` (default: `200`) |
| hideOnOutsideClick | Hides a tooltip when an outside click occurs | `boolean` (default: `false`) |
| maxWidth | The max allowable width of the tooltip content | `number` (default: `200`) |
| position | The position where the tooltip should appear relative to its parent | `string` (default: `top`) |
| show | Allows you to manually control the tooltip visibility | `boolean` (default: `false`) |
| style | The object containing theme variable overrides | `object` (default: `null`) |
| theme | The CSS theme class name | `string` (default: ``) |

#### Using components as content
| Prop | Description | Value |
| :-----------------| :------------------------------------------------------------- | :---------------------------------- |
| content.component | Svelte component | `component` (default: `null`) |
| content.props | Any component propeties | `object` (default: `null`) |
| Prop | Description | Value |
| :-----------------| :------------------------------------------------------------------- | :---------------------------------------------- |
| content.component | Svelte component | `component` (default: `null`) |
| content.props | Any component propeties | `object` (default: `null`) |


```svelte
Expand Down
7 changes: 0 additions & 7 deletions babel.config.json

This file was deleted.

27 changes: 18 additions & 9 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading