forked from Mirrors/elk
Compare commits
2 commits
main
...
userquin/f
Author | SHA1 | Date | |
---|---|---|---|
|
d8960ff691 | ||
|
082fbecebc |
445 changed files with 13309 additions and 32724 deletions
|
@ -11,6 +11,7 @@ dist
|
||||||
.netlify/
|
.netlify/
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
|
||||||
|
public/shiki
|
||||||
public/emojis
|
public/emojis
|
||||||
|
|
||||||
*~
|
*~
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
NUXT_PUBLIC_TRANSLATE_API=
|
NUXT_PUBLIC_TRANSLATE_API=
|
||||||
NUXT_PUBLIC_DEFAULT_SERVER=
|
NUXT_PUBLIC_DEFAULT_SERVER=
|
||||||
NUXT_PUBLIC_SINGLE_INSTANCE=
|
|
||||||
NUXT_PUBLIC_PRIVACY_POLICY_URL=
|
NUXT_PUBLIC_PRIVACY_POLICY_URL=
|
||||||
|
|
||||||
# Production only
|
# Production only
|
||||||
|
@ -8,7 +7,7 @@ NUXT_CLOUDFLARE_ACCOUNT_ID=
|
||||||
NUXT_CLOUDFLARE_NAMESPACE_ID=
|
NUXT_CLOUDFLARE_NAMESPACE_ID=
|
||||||
NUXT_CLOUDFLARE_API_TOKEN=
|
NUXT_CLOUDFLARE_API_TOKEN=
|
||||||
|
|
||||||
# 'cloudflare' | 'vercel' | 'fs'
|
# 'cloudflare' | 'fs'
|
||||||
NUXT_STORAGE_DRIVER=
|
NUXT_STORAGE_DRIVER=
|
||||||
NUXT_STORAGE_FS_BASE=
|
NUXT_STORAGE_FS_BASE=
|
||||||
|
|
||||||
|
|
11
.eslintignore
Normal file
11
.eslintignore
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
*.css
|
||||||
|
*.png
|
||||||
|
*.ico
|
||||||
|
*.toml
|
||||||
|
*.patch
|
||||||
|
*.txt
|
||||||
|
Dockerfile
|
||||||
|
public/
|
||||||
|
https-dev-config/localhost.crt
|
||||||
|
https-dev-config/localhost.key
|
||||||
|
Dockerfile
|
18
.eslintrc
Normal file
18
.eslintrc
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"extends": "@antfu",
|
||||||
|
"ignorePatterns": ["!pages/public"],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["locales/**.json"],
|
||||||
|
"rules": {
|
||||||
|
"jsonc/sort-keys": "error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"vue/no-restricted-syntax":["error", {
|
||||||
|
"selector": "VElement[name='a']",
|
||||||
|
"message": "Use NuxtLink instead."
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -1 +0,0 @@
|
||||||
* text=auto eol=lf
|
|
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
@ -2,4 +2,4 @@
|
||||||
name: 🚀 New feature proposal
|
name: 🚀 New feature proposal
|
||||||
about: Propose a new feature
|
about: Propose a new feature
|
||||||
labels: 's: pending triage'
|
labels: 's: pending triage'
|
||||||
---
|
---
|
12
.github/renovate.json5
vendored
12
.github/renovate.json5
vendored
|
@ -3,14 +3,6 @@
|
||||||
"extends": ["config:base", "schedule:weekly", "group:allNonMajor"],
|
"extends": ["config:base", "schedule:weekly", "group:allNonMajor"],
|
||||||
"labels": ["c: dependencies"],
|
"labels": ["c: dependencies"],
|
||||||
"rangeStrategy": "bump",
|
"rangeStrategy": "bump",
|
||||||
"ignoreDeps": [
|
|
||||||
"vue",
|
|
||||||
"vue-tsc",
|
|
||||||
"typescript",
|
|
||||||
|
|
||||||
// Intl.Segmenter is not supported in Firefox
|
|
||||||
"string-length"
|
|
||||||
],
|
|
||||||
"packageRules": [
|
"packageRules": [
|
||||||
{
|
{
|
||||||
"groupName": "devDependencies",
|
"groupName": "devDependencies",
|
||||||
|
@ -64,10 +56,6 @@
|
||||||
{
|
{
|
||||||
"groupName": "typescript",
|
"groupName": "typescript",
|
||||||
"matchPackageNames": ["typescript"]
|
"matchPackageNames": ["typescript"]
|
||||||
},
|
|
||||||
{
|
|
||||||
"matchDatasources": ["node-version"],
|
|
||||||
"enabled": false
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"vulnerabilityAlerts": {
|
"vulnerabilityAlerts": {
|
||||||
|
|
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
|
@ -10,18 +10,17 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
merge_group: {}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- run: corepack enable
|
- run: corepack enable
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 18
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
|
|
||||||
- name: 📦 Install dependencies
|
- name: 📦 Install dependencies
|
||||||
|
@ -31,8 +30,7 @@ jobs:
|
||||||
run: pnpm nuxi prepare
|
run: pnpm nuxi prepare
|
||||||
|
|
||||||
- name: 🧪 Test project
|
- name: 🧪 Test project
|
||||||
run: pnpm test:ci
|
run: pnpm test
|
||||||
timeout-minutes: 10
|
|
||||||
|
|
||||||
- name: 📝 Lint
|
- name: 📝 Lint
|
||||||
run: pnpm lint
|
run: pnpm lint
|
||||||
|
|
20
.github/workflows/docker.yml
vendored
20
.github/workflows/docker.yml
vendored
|
@ -16,29 +16,29 @@ jobs:
|
||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: metal
|
id: metal
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
ghcr.io/${{ github.repository }}
|
ghcr.io/elk-zone/elk
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v2
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v2
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ github.token }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.metal.outputs.tags }}
|
tags: ${{ steps.metal.outputs.tags }}
|
||||||
labels: ${{ steps.metal.outputs.labels }}
|
labels: ${{ steps.metal.outputs.labels }}
|
||||||
|
|
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
|
@ -12,12 +12,12 @@ jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set node
|
- name: Set node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
|
|
||||||
|
|
2
.github/workflows/semantic-pull-request.yml
vendored
2
.github/workflows/semantic-pull-request.yml
vendored
|
@ -19,6 +19,6 @@ jobs:
|
||||||
name: Semantic Pull Request
|
name: Semantic Pull Request
|
||||||
steps:
|
steps:
|
||||||
- name: Validate PR title
|
- name: Validate PR title
|
||||||
uses: amannn/action-semantic-pull-request@v5.4.0
|
uses: amannn/action-semantic-pull-request@v5.0.2
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -2,7 +2,6 @@ node_modules
|
||||||
*.log
|
*.log
|
||||||
dist
|
dist
|
||||||
.output
|
.output
|
||||||
.pnpm-store
|
|
||||||
.nuxt
|
.nuxt
|
||||||
.env
|
.env
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
@ -10,8 +9,8 @@ dist
|
||||||
.vite-inspect
|
.vite-inspect
|
||||||
.netlify/
|
.netlify/
|
||||||
.eslintcache
|
.eslintcache
|
||||||
elk-translation-status.json
|
|
||||||
|
|
||||||
|
public/shiki
|
||||||
public/emojis
|
public/emojis
|
||||||
|
|
||||||
*~
|
*~
|
||||||
|
|
1
.npmrc
1
.npmrc
|
@ -1,3 +1,4 @@
|
||||||
shamefully-hoist=true
|
shamefully-hoist=true
|
||||||
|
strict-peer-dependencies=false
|
||||||
shell-emulator=true
|
shell-emulator=true
|
||||||
ignore-workspace-root-check=true
|
ignore-workspace-root-check=true
|
||||||
|
|
1
.nvmrc
1
.nvmrc
|
@ -1 +0,0 @@
|
||||||
20
|
|
47
.vscode/settings.json
vendored
47
.vscode/settings.json
vendored
|
@ -5,6 +5,10 @@
|
||||||
"unmute",
|
"unmute",
|
||||||
"unstorage"
|
"unstorage"
|
||||||
],
|
],
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": true
|
||||||
|
},
|
||||||
|
"editor.formatOnSave": false,
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.css": "postcss"
|
"*.css": "postcss"
|
||||||
},
|
},
|
||||||
|
@ -18,45 +22,8 @@
|
||||||
],
|
],
|
||||||
"i18n-ally.preferredDelimiter": "_",
|
"i18n-ally.preferredDelimiter": "_",
|
||||||
"i18n-ally.sortKeys": true,
|
"i18n-ally.sortKeys": true,
|
||||||
"i18n-ally.sourceLanguage": "en",
|
"i18n-ally.sourceLanguage": "en-US",
|
||||||
|
|
||||||
// Enable the ESlint flat config support
|
|
||||||
"eslint.experimental.useFlatConfig": true,
|
|
||||||
|
|
||||||
// Disable the default formatter, use eslint instead
|
|
||||||
"prettier.enable": false,
|
"prettier.enable": false,
|
||||||
"editor.formatOnSave": false,
|
"volar.completion.preferredTagNameCase": "pascal",
|
||||||
|
"volar.completion.preferredAttrNameCase": "kebab"
|
||||||
// Auto fix
|
|
||||||
"editor.codeActionsOnSave": {
|
|
||||||
"source.fixAll": "explicit",
|
|
||||||
"source.organizeImports": "never"
|
|
||||||
},
|
|
||||||
|
|
||||||
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
||||||
"eslint.rules.customizations": [
|
|
||||||
{ "rule": "style/*", "severity": "off" },
|
|
||||||
{ "rule": "*-indent", "severity": "off" },
|
|
||||||
{ "rule": "*-spacing", "severity": "off" },
|
|
||||||
{ "rule": "*-spaces", "severity": "off" },
|
|
||||||
{ "rule": "*-order", "severity": "off" },
|
|
||||||
{ "rule": "*-dangle", "severity": "off" },
|
|
||||||
{ "rule": "*-newline", "severity": "off" },
|
|
||||||
{ "rule": "*quotes", "severity": "off" },
|
|
||||||
{ "rule": "*semi", "severity": "off" }
|
|
||||||
],
|
|
||||||
|
|
||||||
// Enable eslint for all supported languages
|
|
||||||
"eslint.validate": [
|
|
||||||
"javascript",
|
|
||||||
"javascriptreact",
|
|
||||||
"typescript",
|
|
||||||
"typescriptreact",
|
|
||||||
"vue",
|
|
||||||
"html",
|
|
||||||
"markdown",
|
|
||||||
"json",
|
|
||||||
"jsonc",
|
|
||||||
"yaml"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
steps:
|
|
||||||
- name: build docker
|
|
||||||
image: docker:25-cli
|
|
||||||
secrets: [user, pass]
|
|
||||||
commands:
|
|
||||||
- apk add git
|
|
||||||
- REPO=$(echo "$CI_REPO" | tr '[:upper:]' '[:lower:]')
|
|
||||||
- REGISTRY="dev.cat-enby.club"
|
|
||||||
- MAJOR=$(echo ${CI_COMMIT_TAG} | cut -d '.' -f 1 | tr -d 'v')
|
|
||||||
- MINOR=$(echo ${CI_COMMIT_TAG} | cut -d '.' -f 2)
|
|
||||||
- PATCH=$(echo ${CI_COMMIT_TAG} | cut -d '.' -f 3 | cut -d '-' -f 1)
|
|
||||||
- docker buildx build -t $${REGISTRY}/$${REPO}:v$${MAJOR:-0}.$${MINOR:-0}.$${PATCH-0} -t $${REGISTRY}/$${REPO}:v$${MAJOR:-0}.$${MINOR} -t $${REGISTRY}/$$REPO:v$${MAJOR:-0} -t $${REGISTRY}/$$REPO:latest .
|
|
||||||
- docker login --username $USER --password $PASS $${REGISTRY}
|
|
||||||
- docker push $${REGISTRY}/$${REPO}:v$${MAJOR:-0}.$${MINOR:-0}.$${PATCH-0}
|
|
||||||
- docker push $${REGISTRY}/$${REPO}:v$${MAJOR:-0}.$${MINOR}
|
|
||||||
- docker push $${REGISTRY}/$${REPO}:v$${MAJOR:-0}
|
|
||||||
- docker push $${REGISTRY}/$${REPO}:latest
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
when:
|
|
||||||
- repo: nikurasu:elk-test-ci
|
|
||||||
- event: tag
|
|
|
@ -1,45 +0,0 @@
|
||||||
# Code Of Conduct
|
|
||||||
|
|
||||||
## Our Pledge
|
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, political party, or sexual identity and orientation. Note, however, that religion, political party, or other ideological affiliation provide no exemptions for the behavior we outline as unacceptable in this Code of Conduct.
|
|
||||||
|
|
||||||
## Our Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment include:
|
|
||||||
|
|
||||||
- Using welcoming and inclusive language
|
|
||||||
- Being respectful of differing viewpoints and experiences
|
|
||||||
- Gracefully accepting constructive criticism
|
|
||||||
- Focusing on what is best for the community
|
|
||||||
- Showing empathy towards other community members
|
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
|
||||||
|
|
||||||
- The use of sexualized language or imagery and unwelcome sexual attention or advances
|
|
||||||
- Trolling, insulting/derogatory comments, and personal or political attacks
|
|
||||||
- Public or private harassment
|
|
||||||
- Publishing others' private information, such as a physical or electronic address, without explicit permission
|
|
||||||
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
||||||
|
|
||||||
## Our Responsibilities
|
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team by DM at [the Elk Discord](https://chat.elk.zone). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
||||||
|
|
||||||
[homepage]: https://www.contributor-covenant.org
|
|
|
@ -1,14 +1,12 @@
|
||||||
# Contributing Guide
|
# Contributing Guide
|
||||||
|
|
||||||
Hi! We are excited that you are interested in contributing to Elk. Before submitting your contribution, please make sure to take a moment and read through the following guide.
|
Hi! We are really excited that you are interested in contributing to Elk. Before submitting your contribution, please make sure to take a moment and read through the following guide.
|
||||||
|
|
||||||
Refer also to https://github.com/antfu/contribute.
|
Refer also to https://github.com/antfu/contribute.
|
||||||
|
|
||||||
For guidelines on contributing to the documentation, refer to the [docs README](./docs/README.md).
|
|
||||||
|
|
||||||
### Online
|
### Online
|
||||||
|
|
||||||
You can use [StackBlitz Codeflow](https://stackblitz.com/codeflow) to fix bugs or implement features. You'll also see a Codeflow button on PRs to review them without a local setup. Once the elk repo has been cloned in Codeflow, the dev server will start automatically and print the URL to open the App. You should receive a prompt in the bottom-right suggesting to open it in the Editor or in another Tab. To learn more, check out the [Codeflow docs](https://developer.stackblitz.com/codeflow/what-is-codeflow).
|
You can use [StackBlitz Codeflow](https://stackblitz.com/codeflow) to fix bugs or implement features. You'll also see a Codeflow button on PRs to review them without a local setup. Once the elk repo has been cloned in Codeflow, the dev server will start automatically and print the URL to open the App. You should receive a prompt in the bottom-right suggesting to open it in the Editor or in another Tab. To learn more, check out the [Codeflow docs](https://developer.stackblitz.com/codeflow/what-is-codeflow).
|
||||||
|
|
||||||
[![Open in Codeflow](https://developer.stackblitz.com/img/open_in_codeflow.svg)](https://pr.new/elk-zone/elk)
|
[![Open in Codeflow](https://developer.stackblitz.com/img/open_in_codeflow.svg)](https://pr.new/elk-zone/elk)
|
||||||
|
|
||||||
|
@ -18,8 +16,7 @@ To develop and test the Elk package:
|
||||||
|
|
||||||
1. Fork the Elk repository to your own GitHub account and then clone it to your local device.
|
1. Fork the Elk repository to your own GitHub account and then clone it to your local device.
|
||||||
|
|
||||||
2. Ensure using the latest Node.js (16.x).
|
2. Ensure using the latest Node.js (16.x)
|
||||||
If you have [nvm](https://github.com/nvm-sh/nvm), you can run `nvm i` to install the required version.
|
|
||||||
|
|
||||||
3. The package manager used to install and link dependencies must be [pnpm](https://pnpm.io/) v7. To use it you must first enable [Corepack](https://github.com/nodejs/corepack) by running `corepack enable`. (Note: on Linux in a standard Node 16+ environment, you should follow the instructions to install via Node's `corepack` rather than using the `curl` command)
|
3. The package manager used to install and link dependencies must be [pnpm](https://pnpm.io/) v7. To use it you must first enable [Corepack](https://github.com/nodejs/corepack) by running `corepack enable`. (Note: on Linux in a standard Node 16+ environment, you should follow the instructions to install via Node's `corepack` rather than using the `curl` command)
|
||||||
|
|
||||||
|
@ -53,16 +50,16 @@ nr test
|
||||||
|
|
||||||
In order to run Elk with PWA enabled, run `pnpm dev:pwa` in Elk's root folder to start dev server or `pnpm dev:mocked:pwa` to start dev server with `@elkdev@universeodon.com` user.
|
In order to run Elk with PWA enabled, run `pnpm dev:pwa` in Elk's root folder to start dev server or `pnpm dev:mocked:pwa` to start dev server with `@elkdev@universeodon.com` user.
|
||||||
|
|
||||||
You should test the Elk PWA application on private browsing mode on any Chromium-based browser: will not work on Firefox and Safari.
|
You should test the Elk PWA application on private browsing mode on any Chromium based browser: will not work on Firefox and Safari.
|
||||||
|
|
||||||
If not using private browsing mode, you will need to uninstall the PWA application from your browser once you finish testing:
|
If not using private browsing mode, you will need to uninstall the PWA application from your browser once you finish testing:
|
||||||
- Open `Dev Tools` (`Option + ⌘ + J` on macOS, `Shift + CTRL + J` on Windows/Linux)
|
- Open `Dev Tools` (`Option + ⌘ + J` on macOS, `Shift + CTRL + J` on Windows/Linux)
|
||||||
- Go to `Application > Storage`, you should check the following checkboxes:
|
- Go to `Application > Storage`, you should check following checkboxes:
|
||||||
- Application: [x] Unregister service worker
|
- Application: [x] Unregister service worker
|
||||||
- Storage: [x] IndexedDB and [x] Local and session storage
|
- Storage: [x] IndexedDB and [x] Local and session storage
|
||||||
- Cache: [x] Cache storage and [x] Application cache
|
- Cache: [x] Cache storage and [x] Application cache
|
||||||
- Click on `Clear site data` button
|
- Click on `Clear site data` button
|
||||||
- Go to `Application > Service Workers` and check if the current `service worker` is missing or has the state `deleted` or `redundant`
|
- Go to `Application > Service Workers` and check the current `service worker` is missing or has the state `deleted` or `redundant`
|
||||||
|
|
||||||
## CI errors
|
## CI errors
|
||||||
|
|
||||||
|
@ -81,30 +78,23 @@ Elk supports `right-to-left` languages, we need to make sure that the UI is work
|
||||||
Simple approach used by most websites of relying on direction set in HTML element does not work because direction for various items, such as timeline, does not always match direction set in HTML.
|
Simple approach used by most websites of relying on direction set in HTML element does not work because direction for various items, such as timeline, does not always match direction set in HTML.
|
||||||
|
|
||||||
We've added some `UnoCSS` utilities styles to help you with that:
|
We've added some `UnoCSS` utilities styles to help you with that:
|
||||||
- Do not use `left/right` padding and margin: for example `pl-1`. Use `padding-inline-start/end` instead. So `pl-1` should be `ps-1`, `pr-1` should be `pe-1`. The same rules apply to margin.
|
- Do not use `left/right` padding and margin: for example `pl-1`. Use `padding-inline-start/end` instead. So `pl-1` should be `ps-1`, `pr-1` should be `pe-1`. Same rules applies for margin.
|
||||||
- Do not use `rtl-` classes, such as `rtl-left-0`.
|
- Do not use `rtl-` classes, such as `rtl-left-0`.
|
||||||
- For icons that should be rotated for RTL, add `class="rtl-flip"`. This can only be used for icons outside of elements with `dir="auto"`, such as timeline, and is the only exception to the rule above. For icons inside the timeline, it might not work as expected.
|
- For icons that should be rotated for RTL, add `class="rtl-flip"`. This can only be used for icons outside of elements with `dir="auto"`, such as timeline, and is the only exception from rule above. For icons inside timeline it might not work as expected.
|
||||||
- For absolute positioned elements, don't use `left/right`: for example `left-0`. Use `inset-inline-start/end` instead. `UnoCSS` shortcuts are `inset-is` for `inset-inline-start` and `inset-ie` for `inset-inline-end`. Example: `left-0` should be replaced with `inset-is-0`.
|
- For absolute positioned elements, don't use `left/right`: for example `left-0`. Use `inset-inline-start/end` instead. `UnoCSS` shortcuts are `inset-is` for `inset-inline-start` and `inset-ie` for `inset-inline-end`. Example: `left-0` should be replaced with `inset-is-0`.
|
||||||
- If you need to change the border radius for an entire left or right side, use `border-inline-start/end`. `UnoCSS` shortcuts are `rounded-is` for left side, `rounded-ie` for right side. Example: `rounded-l-5` should be replaced with `rounded-ie-5`.
|
- If you need to change border radius for an entire left or right side, use `border-inline-start/end`. `UnoCSS` shortcuts are `rounded-is` for left side, `rounded-ie` for right side. Example: `rounded-l-5` should be replaced with `rounded-ie-5`.
|
||||||
- If you need to change the border radius for one corner, use `border-start-end-radius` and similar rules. `UnoCSS` shortcuts are `rounded` + top/bottom as either `-bs` (top) or `-be` (bottom) + left/right as either `-is` (left) or `-ie` (right). Example: `rounded-tl-0` should be replaced with `rounded-bs-is-0`.
|
- If you need to change border radius for one corner, use `border-start-end-radius` and similar rules. `UnoCSS` shortcuts are `rounded` + top/bottom as either `-bs` (top) or `-be` (bottom) + left/right as either `-is` (left) or `-ie` (right). Example: `rounded-tl-0` should be replaced with `rounded-bs-is-0`.
|
||||||
|
|
||||||
## Internationalization
|
## Internationalization
|
||||||
|
|
||||||
We are using [vue-i18n](https://vue-i18n.intlify.dev/) via [nuxt-i18n](https://v8.i18n.nuxtjs.org/) to handle internationalization.
|
We are using [vue-i18n](https://vue-i18n.intlify.dev/) via [nuxt-i18n](https://i18n.nuxtjs.org/) to handle internationalization.
|
||||||
|
|
||||||
You can check the current [translation status](https://docs.elk.zone/docs/guide/contributing#translation-status): more instructions on the table caption.
|
|
||||||
|
|
||||||
If you are updating a translation in your local environment, you can run the following commands to check the status:
|
|
||||||
- from root folder: `nr prepare-translation-status`
|
|
||||||
- change to `docs` folder and run docs dev server `nr dev`
|
|
||||||
- open `http://localhost:3000/docs/guide/contributing#translation-status` in your browser
|
|
||||||
|
|
||||||
### Adding a new language
|
### Adding a new language
|
||||||
|
|
||||||
1. Add a new file in [locales](./locales) folder with the language code as the filename.
|
1. Add a new file in [locales](./locales) folder with the language code as the filename.
|
||||||
2. Copy [en](./locales/en.json) and translate the strings.
|
2. Copy [en-US](./locales/en-US.json) and translate the strings.
|
||||||
3. Add the language to the `locales` array in [config/i18n.ts](./config/i18n.ts#L61), below `en` and `ar`:
|
3. Add the language to the `locales` array in [config/i18n.ts](./config/i18n.ts#L61), below `en` and `ar`:
|
||||||
- If your language has multiple country variants, add the generic one for language only (only if there are a lot of common entries, you can always add it as a new one)
|
- If your language have multiple country variants, add the generic one for language only (only if there are a lot of common entries, you can always add it as a new one)
|
||||||
- Add all country variants in [country variants object](./config/i18n.ts#L12)
|
- Add all country variants in [country variants object](./config/i18n.ts#L12)
|
||||||
- Add all country variants files with empty `messages` object: `{}`
|
- Add all country variants files with empty `messages` object: `{}`
|
||||||
- Translate the strings in the generic language file
|
- Translate the strings in the generic language file
|
||||||
|
@ -119,7 +109,7 @@ Check [Pluralization rule callback](https://vue-i18n.intlify.dev/guide/essential
|
||||||
|
|
||||||
### Messages interpolation
|
### Messages interpolation
|
||||||
|
|
||||||
Most of the messages used in Elk do not require any interpolation, however, some messages require interpolation: check [Message Format Syntax](https://vue-i18n.intlify.dev/guide/essentials/syntax.html) for more info.
|
Most of the messages used in Elk do not require any interpolation, however, there are some messages that require interpolation: check [Message Format Syntax](https://vue-i18n.intlify.dev/guide/essentials/syntax.html) for more info.
|
||||||
|
|
||||||
We're using these types of interpolation:
|
We're using these types of interpolation:
|
||||||
- [List interpolation](https://vue-i18n.intlify.dev/guide/essentials/syntax.html#list-interpolation)
|
- [List interpolation](https://vue-i18n.intlify.dev/guide/essentials/syntax.html#list-interpolation)
|
||||||
|
@ -141,7 +131,7 @@ Check [Custom Plural Number Formatting Entries](#custom-plural-number-formatting
|
||||||
|
|
||||||
When using plural number formatting, we'll have always `{n}` available in the message, for example, `You have {n} new notifications|You have {n} new notification|You have {n} new notifications` or `You have no new notifications|You have 1 new notification|You have {n} new notifications`.
|
When using plural number formatting, we'll have always `{n}` available in the message, for example, `You have {n} new notifications|You have {n} new notification|You have {n} new notifications` or `You have no new notifications|You have 1 new notification|You have {n} new notifications`.
|
||||||
|
|
||||||
We've included `v` named parameter, it will be used to pass the formatted number using [Intl.NumberFormat::format](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/format): will be the number with separators symbols. The exception to the previous rule is when we're using `plural` **with** `i18n-t` component, in this case, we'll need to use `{0}` instead `{v}` to access the number.
|
We've included `v` named parameter, it will be used to pass the formatted number using [Intl.NumberFormat::format](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/format): will be the number with separators symbols. The exception to previous rule is when we're using `plural` **with** `i18n-t` component, in this case, we'll need to use `{0}` instead `{v}` to access the number.
|
||||||
|
|
||||||
Additionally, Elk will use [compact notation for numbers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#parameters) for some entries, check `notation` and `compactDisplay` options: for example, `1K` for `1000`, `1M` for `1000000`, `1B` for `1000000000` and so on. That entry will be available in the message using `{v}` named parameter (or `{0}` if using the message **with** `i18n-t` component).
|
Additionally, Elk will use [compact notation for numbers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#parameters) for some entries, check `notation` and `compactDisplay` options: for example, `1K` for `1000`, `1M` for `1000000`, `1B` for `1000000000` and so on. That entry will be available in the message using `{v}` named parameter (or `{0}` if using the message **with** `i18n-t` component).
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ RUN apk add git --no-cache
|
||||||
|
|
||||||
# Prepare build deps ( ignore postinstall scripts for now )
|
# Prepare build deps ( ignore postinstall scripts for now )
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
COPY .npmrc ./
|
|
||||||
COPY pnpm-lock.yaml ./
|
COPY pnpm-lock.yaml ./
|
||||||
COPY patches ./patches
|
COPY patches ./patches
|
||||||
RUN pnpm i --frozen-lockfile --ignore-scripts
|
RUN pnpm i --frozen-lockfile --ignore-scripts
|
||||||
|
@ -35,8 +34,8 @@ ARG GID=911
|
||||||
|
|
||||||
# Create a dedicated user and group
|
# Create a dedicated user and group
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
addgroup -g $GID elk; \
|
addgroup -g $UID elk; \
|
||||||
adduser -u $UID -D -G elk elk;
|
adduser -u $GID -D -G elk elk;
|
||||||
|
|
||||||
USER elk
|
USER elk
|
||||||
|
|
||||||
|
|
37
README.md
37
README.md
|
@ -37,36 +37,13 @@ The Elk team maintains a deployment at:
|
||||||
- 🦌 Production: [elk.zone](https://elk.zone)
|
- 🦌 Production: [elk.zone](https://elk.zone)
|
||||||
- 🐙 Canary: [main.elk.zone](https://main.elk.zone) (deploys on every commit to `main` branch)
|
- 🐙 Canary: [main.elk.zone](https://main.elk.zone) (deploys on every commit to `main` branch)
|
||||||
|
|
||||||
### Self-Host Docker Deployment
|
|
||||||
|
|
||||||
In order to host Elk yourself you can use the provided Dockerfile to build a container with elk. Be aware, that Elk only loads properly if the connection is done via SSL/TLS. The Docker container itself does not provide any SSL/TLS handling. You'll have to add this bit yourself.
|
|
||||||
One could put Elk behind popular reverse proxies with SSL Handling like Traefik, NGINX etc.
|
|
||||||
|
|
||||||
1. checkout source ```git clone https://github.com/elk-zone/elk.git```
|
|
||||||
1. got into new source dir: ```cd elk```
|
|
||||||
1. build Docker image: ```docker build .```
|
|
||||||
1. create local storage directory for settings: ```mkdir elk-storage```
|
|
||||||
1. adjust permissions of storage dir: ```sudo chown 911:911 ./elk-storage```
|
|
||||||
1. start container: ```docker-compose up -d```
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> The provided Dockerfile creates a container which will eventually run Elk as non-root user and create a persistent named Docker volume upon first start (if that volume does not yet exist). This volume is always created with root permission. Failing to change the permissions of ```/elk/data``` inside this volume to UID:GID 911 (as specified for Elk in the Dockerfile) will prevent Elk from storing it's config for user accounts. You either have to fix the permission in the created named volume, or mount a directory with the correct permission to ```/elk/data``` into the container.
|
|
||||||
|
|
||||||
### Ecosystem
|
### Ecosystem
|
||||||
|
|
||||||
These are known deployments using Elk as an alternative Web client for Mastodon servers or as a base for other projects in the fediverse:
|
These are known deployments using Elk as an alternative Web client for Mastodon servers or as a base for other projects in the fediverse:
|
||||||
|
|
||||||
- [elk.fedified.com](https://elk.fedified.com) - Use Elk to log into any compatible instance
|
|
||||||
- [elk.me.uk](https://elk.me.uk) - Use Elk to log into any compatible instance, hosted on Google Cloud Run with no Cloudflare proxy
|
|
||||||
- [elk.h4.io](https://elk.h4.io) - Use Elk for the `h4.io` Server
|
- [elk.h4.io](https://elk.h4.io) - Use Elk for the `h4.io` Server
|
||||||
- [elk.universeodon.com](https://elk.universeodon.com) - Use Elk for the Universeodon Server
|
- [elk.universeodon.com](https://elk.universeodon.com) - Use Elk for the Universeodon Server
|
||||||
- [elk.vmst.io](https://elk.vmst.io) - Use Elk for the `vmst.io` Server
|
- [elk.vmst.io](https://elk.vmst.io) - Use Elk for the `vmst.io` Server
|
||||||
- [elk.hostux.social](https://elk.hostux.social) - Use Elk for the `hostux.social` Server
|
|
||||||
- [elk.cupoftea.social](https://elk.cupoftea.social) - Use Elk for the `cupoftea.social` Server
|
|
||||||
- [elk.aus.social](https://elk.aus.social) - Use Elk for the `aus.social` Server
|
|
||||||
- [elk.mstdn.ca](https://elk.mstdn.ca) - Use Elk for the `mstdn.ca` Server
|
|
||||||
- [elk.mastodonapp.uk](https://elk.mastodonapp.uk) - Use Elk for the `mastodonapp.uk` Server
|
|
||||||
- [elk.bolha.us](https://elk.bolha.us) - Use Elk for the `bolha.us` Server
|
|
||||||
|
|
||||||
> **Note**: Community deployments are **NOT** maintained by the Elk team. It may not be synced with Elk's source code. Please do your own research about the host servers before using them.
|
> **Note**: Community deployments are **NOT** maintained by the Elk team. It may not be synced with Elk's source code. Please do your own research about the host servers before using them.
|
||||||
|
|
||||||
|
@ -106,7 +83,7 @@ We're really excited that you're interested in contributing to Elk! Before submi
|
||||||
|
|
||||||
### Online
|
### Online
|
||||||
|
|
||||||
You can use [StackBlitz Codeflow](https://stackblitz.com/codeflow) to fix bugs or implement features. You'll also see a Codeflow button on PRs to review them without a local setup. Once the elk repo has been cloned in Codeflow, the dev server will start automatically and print the URL to open the App. You should receive a prompt in the bottom-right suggesting to open it in the Editor or in another Tab. To learn more, check out the [Codeflow docs](https://developer.stackblitz.com/codeflow/what-is-codeflow).
|
You can use [StackBlitz Codeflow](https://stackblitz.com/codeflow) to fix bugs or implement features. You'll also see a Codeflow button on PRs to review them without a local setup. Once the elk repo has been cloned in Codeflow, the dev server will start automatically and print the URL to open the App. You should receive a prompt in the bottom-right suggesting to open it in the Editor or in another Tab. To learn more, check out the [Codeflow docs](https://developer.stackblitz.com/codeflow/what-is-codeflow).
|
||||||
|
|
||||||
[![Open in Codeflow](https://developer.stackblitz.com/img/open_in_codeflow.svg)](https://pr.new/elk-zone/elk)
|
[![Open in Codeflow](https://developer.stackblitz.com/img/open_in_codeflow.svg)](https://pr.new/elk-zone/elk)
|
||||||
|
|
||||||
|
@ -136,10 +113,6 @@ Elk uses [Vitest](https://vitest.dev). You can run the test suite with:
|
||||||
nr test
|
nr test
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📲 PWA
|
|
||||||
|
|
||||||
You can consult the [PWA documentation](https://docs.elk.zone/pwa) to learn more about the PWA capabilities on Elk, how to install Elk PWA in your desktop or mobile device and some hints about PWA stuff on Elk.
|
|
||||||
|
|
||||||
## 🦄 Stack
|
## 🦄 Stack
|
||||||
|
|
||||||
- [Vite](https://vitejs.dev/) - Next Generation Frontend Tooling
|
- [Vite](https://vitejs.dev/) - Next Generation Frontend Tooling
|
||||||
|
@ -151,14 +124,14 @@ You can consult the [PWA documentation](https://docs.elk.zone/pwa) to learn more
|
||||||
- [UnoCSS](https://uno.antfu.me/) - The instant on-demand atomic CSS engine
|
- [UnoCSS](https://uno.antfu.me/) - The instant on-demand atomic CSS engine
|
||||||
- [Iconify](https://github.com/iconify/icon-sets#iconify-icon-sets-in-json-format) - Iconify icon sets in JSON format
|
- [Iconify](https://github.com/iconify/icon-sets#iconify-icon-sets-in-json-format) - Iconify icon sets in JSON format
|
||||||
- [Masto.js](https://neet.github.io/masto.js) - Mastodon API client in TypeScript
|
- [Masto.js](https://neet.github.io/masto.js) - Mastodon API client in TypeScript
|
||||||
- [shiki](https://shiki.style/) - A beautiful yet powerful syntax highlighter
|
- [shiki](https://shiki.matsu.io/) - A beautiful Syntax Highlighter
|
||||||
- [vite-plugin-pwa](https://github.com/vite-pwa/vite-plugin-pwa) - Prompt for update, Web Push Notifications and Web Share Target API
|
- [vite-plugin-pwa](https://github.com/vite-pwa/vite-plugin-pwa) - Prompt for update and push notifications
|
||||||
|
|
||||||
## 👨💻 Contributors
|
## 👨💻 Contributors
|
||||||
|
|
||||||
<a href="https://github.com/elk-zone/elk/graphs/contributors">
|
<a href="https://github.com/elk-zone/elk/graphs/contributors">
|
||||||
<img src="https://contrib.rocks/image?repo=elk-zone/elk" />
|
<img src="https://contrib.rocks/image?repo=elk-zone/elk" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
|
|
||||||
|
|
6
app.vue
6
app.vue
|
@ -4,12 +4,10 @@ provideGlobalCommands()
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
if (import.meta.server && !route.path.startsWith('/settings')) {
|
if (process.server && !route.path.startsWith('/settings')) {
|
||||||
const url = useRequestURL()
|
|
||||||
|
|
||||||
useHead({
|
useHead({
|
||||||
meta: [
|
meta: [
|
||||||
{ property: 'og:url', content: `${url.origin}${route.path}` },
|
{ property: 'og:url', content: `https://elk.zone${route.path}` },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ defineProps<{
|
||||||
square?: boolean
|
square?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const loaded = ref(false)
|
const loaded = $ref(false)
|
||||||
const error = ref(false)
|
const error = $ref(false)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { mastodon } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
defineOptions({
|
const { account, as = 'div' } = $defineProps<{
|
||||||
inheritAttrs: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const { account, as = 'div' } = defineProps<{
|
|
||||||
account: mastodon.v1.Account
|
account: mastodon.v1.Account
|
||||||
as?: string
|
as?: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
cacheAccount(account)
|
cacheAccount(account)
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
inheritAttrs: false,
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -11,8 +11,8 @@ defineProps<{
|
||||||
text-secondary-light
|
text-secondary-light
|
||||||
>
|
>
|
||||||
<slot name="prepend" />
|
<slot name="prepend" />
|
||||||
<CommonTooltip no-auto-focus :content="$t('account.bot')" :disabled="showLabel">
|
<CommonTooltip :content="$t('account.bot')" :disabled="showLabel">
|
||||||
<div i-mdi:robot-outline />
|
<div i-ri:robot-line />
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
<div v-if="showLabel">
|
<div v-if="showLabel">
|
||||||
{{ $t('account.bot') }}
|
{{ $t('account.bot') }}
|
||||||
|
|
|
@ -19,10 +19,8 @@ cacheAccount(account)
|
||||||
overflow-hidden
|
overflow-hidden
|
||||||
:to="getAccountRoute(account)"
|
:to="getAccountRoute(account)"
|
||||||
/>
|
/>
|
||||||
<slot>
|
<div h-full p1 shrink-0>
|
||||||
<div h-full p1 shrink-0>
|
<AccountFollowButton :account="account" :context="relationshipContext" />
|
||||||
<AccountFollowButton :account="account" :context="relationshipContext" />
|
</div>
|
||||||
</div>
|
|
||||||
</slot>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { mastodon } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account, hideEmojis = false } = defineProps<{
|
defineProps<{
|
||||||
account: mastodon.v1.Account
|
account: mastodon.v1.Account
|
||||||
hideEmojis?: boolean
|
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -11,7 +10,6 @@ const { account, hideEmojis = false } = defineProps<{
|
||||||
<ContentRich
|
<ContentRich
|
||||||
:content="getDisplayName(account, { rich: true })"
|
:content="getDisplayName(account, { rich: true })"
|
||||||
:emojis="account.emojis"
|
:emojis="account.emojis"
|
||||||
:hide-emojis="hideEmojis"
|
|
||||||
:markdown="false"
|
:markdown="false"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { mastodon } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import { toggleFollowAccount, useRelationship } from '~~/composables/masto/relationship'
|
|
||||||
|
|
||||||
const { account, command, context, ...props } = defineProps<{
|
const { account, command, context, ...props } = defineProps<{
|
||||||
account: mastodon.v1.Account
|
account: mastodon.v1.Account
|
||||||
|
@ -10,36 +9,55 @@ const { account, command, context, ...props } = defineProps<{
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const isSelf = useSelfAccount(() => account)
|
const isSelf = $(useSelfAccount(() => account))
|
||||||
const enable = computed(() => !isSelf.value && currentUser.value)
|
const enable = $computed(() => !isSelf && currentUser.value)
|
||||||
const relationship = computed(() => props.relationship || useRelationship(account).value)
|
const relationship = $computed(() => props.relationship || useRelationship(account).value)
|
||||||
const isLoading = computed(() => relationship.value === undefined)
|
|
||||||
|
|
||||||
const { client } = useMasto()
|
const { client } = $(useMasto())
|
||||||
|
async function toggleFollow() {
|
||||||
async function unblock() {
|
if (relationship!.following) {
|
||||||
relationship.value!.blocking = false
|
if (await openConfirmDialog({
|
||||||
|
title: t('confirm.unfollow.title'),
|
||||||
|
confirm: t('confirm.unfollow.confirm'),
|
||||||
|
cancel: t('confirm.unfollow.cancel'),
|
||||||
|
}) !== 'confirm')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
relationship!.following = !relationship!.following
|
||||||
try {
|
try {
|
||||||
const newRel = await client.value.v1.accounts.$select(account.id).unblock()
|
const newRel = await client.v1.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
|
||||||
Object.assign(relationship!, newRel)
|
Object.assign(relationship!, newRel)
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
// TODO error handling
|
// TODO error handling
|
||||||
relationship.value!.blocking = true
|
relationship!.following = !relationship!.following
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function unblock() {
|
||||||
|
relationship!.blocking = false
|
||||||
|
try {
|
||||||
|
const newRel = await client.v1.accounts.unblock(account.id)
|
||||||
|
Object.assign(relationship!, newRel)
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
// TODO error handling
|
||||||
|
relationship!.blocking = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unmute() {
|
async function unmute() {
|
||||||
relationship.value!.muting = false
|
relationship!.muting = false
|
||||||
try {
|
try {
|
||||||
const newRel = await client.value.v1.accounts.$select(account.id).unmute()
|
const newRel = await client.v1.accounts.unmute(account.id)
|
||||||
Object.assign(relationship!, newRel)
|
Object.assign(relationship!, newRel)
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
// TODO error handling
|
// TODO error handling
|
||||||
relationship.value!.muting = true
|
relationship!.muting = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,25 +65,21 @@ useCommand({
|
||||||
scope: 'Actions',
|
scope: 'Actions',
|
||||||
order: -2,
|
order: -2,
|
||||||
visible: () => command && enable,
|
visible: () => command && enable,
|
||||||
name: () => `${relationship.value?.following ? t('account.unfollow') : t('account.follow')} ${getShortHandle(account)}`,
|
name: () => `${relationship?.following ? t('account.unfollow') : t('account.follow')} ${getShortHandle(account)}`,
|
||||||
icon: 'i-ri:star-line',
|
icon: 'i-ri:star-line',
|
||||||
onActivate: () => toggleFollowAccount(relationship.value!, account),
|
onActivate: () => toggleFollow(),
|
||||||
})
|
})
|
||||||
|
|
||||||
const buttonStyle = computed(() => {
|
const buttonStyle = $computed(() => {
|
||||||
if (relationship.value?.blocking)
|
if (relationship?.blocking)
|
||||||
return 'text-inverted bg-red border-red'
|
return 'text-inverted bg-red border-red'
|
||||||
|
|
||||||
if (relationship.value?.muting)
|
if (relationship?.muting)
|
||||||
return 'text-base bg-card border-base'
|
return 'text-base bg-card border-base'
|
||||||
|
|
||||||
// If following, use a label style with a strong border for Mutuals
|
// If following, use a label style with a strong border for Mutuals
|
||||||
if (relationship.value ? relationship.value.following : context === 'following')
|
if (relationship ? relationship.following : context === 'following')
|
||||||
return `text-base ${relationship.value?.followedBy ? 'border-strong' : 'border-base'}`
|
return `text-base ${relationship?.followedBy ? 'border-strong' : 'border-base'}`
|
||||||
|
|
||||||
// If loading, use a plain style
|
|
||||||
if (isLoading.value)
|
|
||||||
return 'text-base border-base'
|
|
||||||
|
|
||||||
// If not following, use a button style
|
// If not following, use a button style
|
||||||
return 'text-inverted bg-primary border-primary'
|
return 'text-inverted bg-primary border-primary'
|
||||||
|
@ -76,39 +90,34 @@ const buttonStyle = computed(() => {
|
||||||
<button
|
<button
|
||||||
v-if="enable"
|
v-if="enable"
|
||||||
gap-1 items-center group
|
gap-1 items-center group
|
||||||
|
:disabled="relationship?.requested"
|
||||||
border-1
|
border-1
|
||||||
rounded-full flex="~ gap2 center" font-500 min-w-30 h-fit px3 py1
|
rounded-full flex="~ gap2 center" font-500 min-w-30 h-fit px3 py1
|
||||||
:class="buttonStyle"
|
:class="buttonStyle"
|
||||||
:hover="!relationship?.blocking && !relationship?.muting && relationship?.following ? 'border-red text-red' : 'bg-base border-primary text-primary'"
|
:hover="!relationship?.blocking && !relationship?.muting && relationship?.following ? 'border-red text-red' : 'bg-base border-primary text-primary'"
|
||||||
@click="relationship?.blocking ? unblock() : relationship?.muting ? unmute() : toggleFollowAccount(relationship!, account)"
|
@click="relationship?.blocking ? unblock() : relationship?.muting ? unmute() : toggleFollow()"
|
||||||
>
|
>
|
||||||
<template v-if="isLoading">
|
<template v-if="relationship?.blocking">
|
||||||
<span i-svg-spinners-180-ring-with-bg />
|
<span group-hover="hidden">{{ $t('account.blocking') }}</span>
|
||||||
|
<span hidden group-hover="inline">{{ $t('account.unblock') }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-if="relationship?.muting">
|
||||||
|
<span group-hover="hidden">{{ $t('account.muting') }}</span>
|
||||||
|
<span hidden group-hover="inline">{{ $t('account.unmute') }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="relationship ? relationship.following : context === 'following'">
|
||||||
|
<span group-hover="hidden">{{ relationship?.followedBy ? $t('account.mutuals') : $t('account.following') }}</span>
|
||||||
|
<span hidden group-hover="inline">{{ $t('account.unfollow') }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="relationship?.requested">
|
||||||
|
<span>{{ $t('account.follow_requested') }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="relationship ? relationship.followedBy : context === 'followedBy'">
|
||||||
|
<span group-hover="hidden">{{ $t('account.follows_you') }}</span>
|
||||||
|
<span hidden group-hover="inline">{{ $t('account.follow_back') }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<template v-if="relationship?.blocking">
|
<span>{{ $t('account.follow') }}</span>
|
||||||
<span elk-group-hover="hidden">{{ $t('account.blocking') }}</span>
|
|
||||||
<span hidden elk-group-hover="inline">{{ $t('account.unblock') }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-if="relationship?.muting">
|
|
||||||
<span elk-group-hover="hidden">{{ $t('account.muting') }}</span>
|
|
||||||
<span hidden elk-group-hover="inline">{{ $t('account.unmute') }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="relationship ? relationship.following : context === 'following'">
|
|
||||||
<span elk-group-hover="hidden">{{ relationship?.followedBy ? $t('account.mutuals') : $t('account.following') }}</span>
|
|
||||||
<span hidden elk-group-hover="inline">{{ $t('account.unfollow') }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="relationship?.requested">
|
|
||||||
<span elk-group-hover="hidden">{{ $t('account.follow_requested') }}</span>
|
|
||||||
<span hidden elk-group-hover="inline">{{ $t('account.withdraw_follow_request') }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="relationship ? relationship.followedBy : context === 'followedBy'">
|
|
||||||
<span elk-group-hover="hidden">{{ $t('account.follows_you') }}</span>
|
|
||||||
<span hidden elk-group-hover="inline">{{ account.locked ? $t('account.request_follow') : $t('account.follow_back') }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span>{{ account.locked ? $t('account.request_follow') : $t('account.follow') }}</span>
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import type { mastodon } from 'masto'
|
|
||||||
|
|
||||||
const { account, ...props } = defineProps<{
|
|
||||||
account: mastodon.v1.Account
|
|
||||||
relationship?: mastodon.v1.Relationship
|
|
||||||
}>()
|
|
||||||
const relationship = computed(() => props.relationship || useRelationship(account).value)
|
|
||||||
const { client } = useMasto()
|
|
||||||
|
|
||||||
async function authorizeFollowRequest() {
|
|
||||||
relationship.value!.requestedBy = false
|
|
||||||
relationship.value!.followedBy = true
|
|
||||||
try {
|
|
||||||
const newRel = await client.value.v1.followRequests.$select(account.id).authorize()
|
|
||||||
Object.assign(relationship!, newRel)
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
relationship.value!.requestedBy = true
|
|
||||||
relationship.value!.followedBy = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function rejectFollowRequest() {
|
|
||||||
relationship.value!.requestedBy = false
|
|
||||||
try {
|
|
||||||
const newRel = await client.value.v1.followRequests.$select(account.id).reject()
|
|
||||||
Object.assign(relationship!, newRel)
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
relationship.value!.requestedBy = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div flex gap-4>
|
|
||||||
<template v-if="relationship?.requestedBy">
|
|
||||||
<CommonTooltip :content="$t('account.authorize')" no-auto-focus>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
rounded-full text-sm p2 border-1
|
|
||||||
hover:text-green transition-colors
|
|
||||||
@click="authorizeFollowRequest"
|
|
||||||
>
|
|
||||||
<span block text-current i-ri:check-fill />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
<CommonTooltip :content="$t('account.reject')" no-auto-focus>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
rounded-full text-sm p2 border-1
|
|
||||||
hover:text-red transition-colors
|
|
||||||
@click="rejectFollowRequest"
|
|
||||||
>
|
|
||||||
<span block text-current i-ri:close-fill />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span text-secondary>
|
|
||||||
{{ relationship?.followedBy ? $t('account.authorized') : $t('account.rejected') }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -5,7 +5,7 @@ const { account } = defineProps<{
|
||||||
account: mastodon.v1.Account
|
account: mastodon.v1.Account
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const serverName = computed(() => getServerName(account))
|
const serverName = $computed(() => getServerName(account))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -6,30 +6,28 @@ const { account } = defineProps<{
|
||||||
command?: boolean
|
command?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { client } = useMasto()
|
const { client } = $(useMasto())
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const createdAt = useFormattedDateTime(() => account.createdAt, {
|
const createdAt = $(useFormattedDateTime(() => account.createdAt, {
|
||||||
month: 'long',
|
month: 'long',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
})
|
}))
|
||||||
|
|
||||||
const relationship = useRelationship(account)
|
const relationship = $(useRelationship(account))
|
||||||
|
|
||||||
const namedFields = ref<mastodon.v1.AccountField[]>([])
|
const namedFields = ref<mastodon.v1.AccountField[]>([])
|
||||||
const iconFields = ref<mastodon.v1.AccountField[]>([])
|
const iconFields = ref<mastodon.v1.AccountField[]>([])
|
||||||
const isEditingPersonalNote = ref<boolean>(false)
|
const hasHeader = $computed(() => !account.header.endsWith('/original/missing.png'))
|
||||||
const hasHeader = computed(() => !account.header.endsWith('/original/missing.png'))
|
|
||||||
const isCopied = ref<boolean>(false)
|
|
||||||
|
|
||||||
function getFieldIconTitle(fieldName: string) {
|
function getFieldIconTitle(fieldName: string) {
|
||||||
return fieldName === 'Joined' ? t('account.joined') : fieldName
|
return fieldName === 'Joined' ? t('account.joined') : fieldName
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotificationIconTitle() {
|
function getNotificationIconTitle() {
|
||||||
return relationship.value?.notifying ? t('account.notifications_on_post_disable', { username: `@${account.username}` }) : t('account.notifications_on_post_enable', { username: `@${account.username}` })
|
return relationship?.notifying ? t('account.notifications_on_post_disable', { username: `@${account.username}` }) : t('account.notifications_on_post_enable', { username: `@${account.username}` })
|
||||||
}
|
}
|
||||||
|
|
||||||
function previewHeader() {
|
function previewHeader() {
|
||||||
|
@ -51,14 +49,14 @@ function previewAvatar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleNotifications() {
|
async function toggleNotifications() {
|
||||||
relationship.value!.notifying = !relationship.value?.notifying
|
relationship!.notifying = !relationship?.notifying
|
||||||
try {
|
try {
|
||||||
const newRel = await client.value.v1.accounts.$select(account.id).follow({ notify: relationship.value?.notifying })
|
const newRel = await client.v1.accounts.follow(account.id, { notify: relationship?.notifying })
|
||||||
Object.assign(relationship!, newRel)
|
Object.assign(relationship!, newRel)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
// TODO error handling
|
// TODO error handling
|
||||||
relationship.value!.notifying = !relationship.value?.notifying
|
relationship!.notifying = !relationship?.notifying
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,200 +73,96 @@ watchEffect(() => {
|
||||||
})
|
})
|
||||||
icons.push({
|
icons.push({
|
||||||
name: 'Joined',
|
name: 'Joined',
|
||||||
value: createdAt.value,
|
value: createdAt,
|
||||||
})
|
})
|
||||||
|
|
||||||
namedFields.value = named
|
namedFields.value = named
|
||||||
iconFields.value = icons
|
iconFields.value = icons
|
||||||
})
|
})
|
||||||
|
|
||||||
const personalNoteDraft = ref(relationship.value?.note ?? '')
|
const isSelf = $(useSelfAccount(() => account))
|
||||||
watch(relationship, (relationship, oldValue) => {
|
const isNotifiedOnPost = $computed(() => !!relationship?.notifying)
|
||||||
if (!oldValue && relationship)
|
|
||||||
personalNoteDraft.value = relationship.note ?? ''
|
|
||||||
})
|
|
||||||
|
|
||||||
async function editNote(event: Event) {
|
|
||||||
if (!event.target || !('value' in event.target) || !relationship.value)
|
|
||||||
return
|
|
||||||
|
|
||||||
const newNote = event.target?.value as string
|
|
||||||
|
|
||||||
if (relationship.value.note?.trim() === newNote.trim())
|
|
||||||
return
|
|
||||||
|
|
||||||
const newNoteApiResult = await client.value.v1.accounts.$select(account.id).note.create({ comment: newNote })
|
|
||||||
relationship.value.note = newNoteApiResult.note
|
|
||||||
personalNoteDraft.value = relationship.value.note ?? ''
|
|
||||||
}
|
|
||||||
|
|
||||||
const isSelf = useSelfAccount(() => account)
|
|
||||||
const isNotifiedOnPost = computed(() => !!relationship.value?.notifying)
|
|
||||||
|
|
||||||
const personalNoteMaxLength = 2000
|
|
||||||
|
|
||||||
async function copyAccountName() {
|
|
||||||
try {
|
|
||||||
const shortHandle = getShortHandle(account)
|
|
||||||
const serverName = getServerName(account)
|
|
||||||
const accountName = `${shortHandle}@${serverName}`
|
|
||||||
await navigator.clipboard.writeText(accountName)
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error('Failed to copy account name:', err)
|
|
||||||
}
|
|
||||||
|
|
||||||
isCopied.value = true
|
|
||||||
setTimeout(() => {
|
|
||||||
isCopied.value = false
|
|
||||||
}, 2000)
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div flex flex-col>
|
<div flex flex-col>
|
||||||
<div v-if="relationship?.requestedBy" p-4 flex justify-between items-center bg-card>
|
|
||||||
<span text-primary font-bold>{{ $t('account.requested', [account.displayName]) }}</span>
|
|
||||||
<AccountFollowRequestButton :account="account" :relationship="relationship" />
|
|
||||||
</div>
|
|
||||||
<component :is="hasHeader ? 'button' : 'div'" border="b base" z-1 @click="hasHeader ? previewHeader() : undefined">
|
<component :is="hasHeader ? 'button' : 'div'" border="b base" z-1 @click="hasHeader ? previewHeader() : undefined">
|
||||||
<img h-50 height="200" w-full object-cover :src="account.header" :alt="t('account.profile_description', [account.username])">
|
<img h-50 height="200" w-full object-cover :src="account.header" :alt="t('account.profile_description', [account.username])">
|
||||||
</component>
|
</component>
|
||||||
<div p4 mt--18 flex flex-col gap-4>
|
<div p4 mt--18 flex flex-col gap-4>
|
||||||
<div relative>
|
<div relative>
|
||||||
<div flex justify-between>
|
<div flex="~ col gap-2 1">
|
||||||
<button shrink-0 h-full :class="{ 'rounded-full': !isSelf, 'squircle': isSelf }" p1 bg-base border-bg-base z-2 @click="previewAvatar">
|
<button :class="{ 'rounded-full': !isSelf, 'squircle': isSelf }" w-30 h-30 p1 bg-base border-bg-base z-2 @click="previewAvatar">
|
||||||
<AccountAvatar :square="isSelf" :account="account" hover:opacity-90 transition-opacity w-28 h-28 />
|
<AccountAvatar :square="isSelf" :account="account" hover:opacity-90 transition-opacity />
|
||||||
</button>
|
</button>
|
||||||
<div inset-ie-0 flex="~ wrap row-reverse" gap-2 items-center pt18 justify-start>
|
<div flex="~ col gap1">
|
||||||
<!-- Edit profile -->
|
<div flex justify-between>
|
||||||
<NuxtLink
|
<AccountDisplayName :account="account" font-bold sm:text-2xl text-xl />
|
||||||
v-if="isSelf"
|
<AccountBotIndicator v-if="account.bot" show-label />
|
||||||
to="/settings/profile/appearance"
|
</div>
|
||||||
gap-1 items-center border="1" rounded-full flex="~ gap2 center" font-500 min-w-30 h-fit px3 py1
|
<AccountHandle :account="account" />
|
||||||
hover="border-primary text-primary bg-active"
|
|
||||||
>
|
|
||||||
{{ $t('settings.profile.appearance.title') }}
|
|
||||||
</NuxtLink>
|
|
||||||
<AccountFollowButton :account="account" :command="command" />
|
|
||||||
<span inset-ie-0 flex gap-2 items-center>
|
|
||||||
<AccountMoreButton
|
|
||||||
:account="account" :command="command"
|
|
||||||
@add-note="isEditingPersonalNote = true"
|
|
||||||
@remove-note="() => { isEditingPersonalNote = false; personalNoteDraft = '' }"
|
|
||||||
/>
|
|
||||||
<CommonTooltip v-if="!isSelf && relationship?.following" :content="getNotificationIconTitle()">
|
|
||||||
<button
|
|
||||||
:aria-pressed="isNotifiedOnPost"
|
|
||||||
:aria-label="t('account.notifications_on_post_enable', { username: `@${account.username}` })"
|
|
||||||
rounded-full text-sm p2 border-1 transition-colors
|
|
||||||
:class="isNotifiedOnPost ? 'text-primary border-primary hover:bg-red/20 hover:text-red hover:border-red' : 'border-base hover:text-primary'"
|
|
||||||
@click="toggleNotifications"
|
|
||||||
>
|
|
||||||
<span v-if="isNotifiedOnPost" i-ri:notification-4-fill block text-current />
|
|
||||||
<span v-else i-ri-notification-4-line block text-current />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
<CommonTooltip :content="$t('list.modify_account')">
|
|
||||||
<VDropdown v-if="!isSelf && relationship?.following">
|
|
||||||
<button
|
|
||||||
:aria-label="$t('list.modify_account')"
|
|
||||||
rounded-full text-sm p2 border-1 transition-colors
|
|
||||||
border-base hover:text-primary
|
|
||||||
>
|
|
||||||
<span i-ri:play-list-add-fill block text-current />
|
|
||||||
</button>
|
|
||||||
<template #popper>
|
|
||||||
<ListLists :user-id="account.id" />
|
|
||||||
</template>
|
|
||||||
</VDropdown>
|
|
||||||
</CommonTooltip>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div flex="~ col gap1" pt2>
|
<div absolute top-18 inset-ie-0 flex gap-2 items-center>
|
||||||
<div flex gap2 items-center flex-wrap>
|
<AccountMoreButton :account="account" :command="command" />
|
||||||
<AccountDisplayName :account="account" font-bold sm:text-2xl text-xl />
|
<CommonTooltip v-if="!isSelf && relationship?.following" :content="getNotificationIconTitle()">
|
||||||
<AccountRolesIndicator v-if="account.roles?.length" :account="account" />
|
<button
|
||||||
<AccountLockIndicator v-if="account.locked" show-label />
|
:aria-pressed="isNotifiedOnPost"
|
||||||
<AccountBotIndicator v-if="account.bot" show-label />
|
:aria-label="t('account.notifications_on_post_enable', { username: `@${account.username}` })"
|
||||||
</div>
|
rounded-full text-sm p2 border-1 transition-colors
|
||||||
|
:class="isNotifiedOnPost ? 'text-primary border-primary hover:bg-red/20 hover:text-red hover:border-red' : 'border-base hover:text-primary'"
|
||||||
<div flex items-center gap-1>
|
@click="toggleNotifications"
|
||||||
<AccountHandle :account="account" overflow-unset line-clamp-unset />
|
>
|
||||||
<CommonTooltip placement="bottom" :content="$t('account.copy_account_name')" no-auto-focus flex>
|
<span v-if="isNotifiedOnPost" i-ri:notification-4-fill block text-current />
|
||||||
<button text-secondary-light text-sm :class="isCopied ? 'i-ri:check-fill text-green' : 'i-ri:file-copy-line'" @click="copyAccountName">
|
<span v-else i-ri-notification-4-line block text-current />
|
||||||
<span sr-only>{{ $t('account.copy_account_name') }}</span>
|
</button>
|
||||||
|
</CommonTooltip>
|
||||||
|
<CommonTooltip :content="$t('list.modify_account')">
|
||||||
|
<VDropdown v-if="!isSelf && relationship?.following">
|
||||||
|
<button
|
||||||
|
:aria-label="$t('list.modify_account')"
|
||||||
|
rounded-full text-sm p2 border-1 transition-colors
|
||||||
|
border-base hover:text-primary
|
||||||
|
>
|
||||||
|
<span i-ri:play-list-add-fill block text-current />
|
||||||
</button>
|
</button>
|
||||||
</CommonTooltip>
|
<template #popper>
|
||||||
</div>
|
<ListLists :user-id="account.id" />
|
||||||
|
</template>
|
||||||
|
</VDropdown>
|
||||||
|
</CommonTooltip>
|
||||||
|
<AccountFollowButton :account="account" :command="command" />
|
||||||
|
<!-- Edit profile -->
|
||||||
|
<NuxtLink
|
||||||
|
v-if="isSelf"
|
||||||
|
to="/settings/profile/appearance"
|
||||||
|
gap-1 items-center border="1" rounded-full flex="~ gap2 center" font-500 min-w-30 h-fit px3 py1
|
||||||
|
hover="border-primary text-primary bg-active"
|
||||||
|
>
|
||||||
|
{{ $t('settings.profile.appearance.title') }}
|
||||||
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<label
|
|
||||||
v-if="isEditingPersonalNote || (relationship?.note && relationship.note.length > 0)"
|
|
||||||
space-y-2
|
|
||||||
pb-4
|
|
||||||
block
|
|
||||||
border="b base"
|
|
||||||
>
|
|
||||||
<div flex flex-row space-x-2 flex-v-center>
|
|
||||||
<div i-ri-edit-2-line />
|
|
||||||
<p font-medium>
|
|
||||||
{{ $t('account.profile_personal_note') }}
|
|
||||||
</p>
|
|
||||||
<p text-secondary text-sm :class="{ 'text-orange': personalNoteDraft.length > (personalNoteMaxLength - 100) }">
|
|
||||||
{{ personalNoteDraft.length }} / {{ personalNoteMaxLength }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div position-relative>
|
|
||||||
<div
|
|
||||||
input-base
|
|
||||||
min-h-10ex
|
|
||||||
whitespace-pre-wrap
|
|
||||||
opacity-0
|
|
||||||
:class="{ 'trailing-newline': personalNoteDraft.endsWith('\n') }"
|
|
||||||
>
|
|
||||||
{{ personalNoteDraft }}
|
|
||||||
</div>
|
|
||||||
<textarea
|
|
||||||
v-model="personalNoteDraft"
|
|
||||||
input-base
|
|
||||||
position-absolute
|
|
||||||
style="height: 100%"
|
|
||||||
top-0
|
|
||||||
resize-none
|
|
||||||
:maxlength="personalNoteMaxLength"
|
|
||||||
@change="editNote"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</label>
|
|
||||||
<div v-if="account.note" max-h-100 overflow-y-auto>
|
<div v-if="account.note" max-h-100 overflow-y-auto>
|
||||||
<ContentRich text-4 text-base :content="account.note" :emojis="account.emojis" />
|
<ContentRich text-4 text-base :content="account.note" :emojis="account.emojis" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="namedFields.length" flex="~ col wrap gap1">
|
<div v-if="namedFields.length" flex="~ col wrap gap1">
|
||||||
<div v-for="field in namedFields" :key="field.name" flex="~ gap-1" items-center>
|
<div v-for="field in namedFields" :key="field.name" flex="~ gap-1" items-center>
|
||||||
<div mt="0.5" text-secondary uppercase text-xs font-bold>
|
<div text-secondary uppercase text-xs font-bold>
|
||||||
<ContentRich :content="field.name" :emojis="account.emojis" />
|
{{ field.name }} |
|
||||||
</div>
|
</div>
|
||||||
<span text-secondary text-xs font-bold>|</span>
|
|
||||||
<ContentRich :content="field.value" :emojis="account.emojis" />
|
<ContentRich :content="field.value" :emojis="account.emojis" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="iconFields.length" flex="~ wrap gap-2">
|
<div v-if="iconFields.length" flex="~ wrap gap-4">
|
||||||
<div v-for="field in iconFields" :key="field.name" flex="~ gap-1" px1 items-center :class="`${field.verifiedAt ? 'border-1 rounded-full border-dark' : ''}`">
|
<div v-for="field in iconFields" :key="field.name" flex="~ gap-1" items-center>
|
||||||
<CommonTooltip :content="getFieldIconTitle(field.name)">
|
<CommonTooltip :content="getFieldIconTitle(field.name)">
|
||||||
<div text-secondary :class="getAccountFieldIcon(field.name)" :title="getFieldIconTitle(field.name)" />
|
<div text-secondary :class="getAccountFieldIcon(field.name)" :title="getFieldIconTitle(field.name)" />
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
<ContentRich text-sm :content="field.value" :emojis="account.emojis" />
|
<ContentRich text-sm filter-saturate-0 :content="field.value" :emojis="account.emojis" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<AccountPostsFollowers :account="account" />
|
<AccountPostsFollowers :account="account" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
|
||||||
.trailing-newline::after {
|
|
||||||
content: '\a';
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const { account } = defineProps<{
|
||||||
account: mastodon.v1.Account
|
account: mastodon.v1.Account
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const relationship = useRelationship(account)
|
const relationship = $(useRelationship(account))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -19,6 +19,6 @@ const relationship = useRelationship(account)
|
||||||
<div v-if="account.note" max-h-100 overflow-y-auto>
|
<div v-if="account.note" max-h-100 overflow-y-auto>
|
||||||
<ContentRich text-4 text-secondary :content="account.note" :emojis="account.emojis" />
|
<ContentRich text-4 text-secondary :content="account.note" :emojis="account.emojis" />
|
||||||
</div>
|
</div>
|
||||||
<AccountPostsFollowers text-sm :account="account" :is-hover-card="true" />
|
<AccountPostsFollowers text-sm :account="account" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,69 +1,26 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { mastodon } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import { fetchAccountByHandle } from '~/composables/cache'
|
|
||||||
|
|
||||||
type WatcherType = [acc?: mastodon.v1.Account | null, h?: string, v?: boolean]
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
inheritAttrs: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
account?: mastodon.v1.Account | null
|
account?: mastodon.v1.Account
|
||||||
handle?: string
|
handle?: string
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const accountHover = ref()
|
const account = props.account || (props.handle ? useAccountByHandle(props.handle!) : undefined)
|
||||||
const hovered = useElementHover(accountHover)
|
|
||||||
const account = ref<mastodon.v1.Account | null | undefined>(props.account)
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [props.account, props.handle, hovered.value] satisfies WatcherType,
|
|
||||||
([newAccount, newHandle, newVisible], oldProps) => {
|
|
||||||
if (!newVisible || process.test)
|
|
||||||
return
|
|
||||||
|
|
||||||
if (newAccount) {
|
|
||||||
account.value = newAccount
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newHandle) {
|
|
||||||
const [_oldAccount, oldHandle, _oldVisible] = oldProps ?? [undefined, undefined, false]
|
|
||||||
if (!oldHandle || newHandle !== oldHandle || !account.value) {
|
|
||||||
// new handle can be wrong: using server instead of webDomain
|
|
||||||
fetchAccountByHandle(newHandle).then((acc) => {
|
|
||||||
if (newHandle === props.handle)
|
|
||||||
account.value = acc
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
account.value = undefined
|
|
||||||
},
|
|
||||||
{ immediate: true, flush: 'post' },
|
|
||||||
)
|
|
||||||
|
|
||||||
const userSettings = useUserSettings()
|
const userSettings = useUserSettings()
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
inheritAttrs: false,
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<span ref="accountHover">
|
<VMenu v-if="!disabled && account && !getPreferences(userSettings, 'hideAccountHoverCard')" placement="bottom-start" :delay="{ show: 500, hide: 100 }" v-bind="$attrs" :close-on-content-click="false">
|
||||||
<VMenu
|
<slot />
|
||||||
v-if="!disabled && account && !getPreferences(userSettings, 'hideAccountHoverCard')"
|
<template #popper>
|
||||||
placement="bottom-start"
|
<AccountHoverCard v-if="account" :account="account" />
|
||||||
:delay="{ show: 500, hide: 100 }"
|
</template>
|
||||||
v-bind="$attrs"
|
</VMenu>
|
||||||
:close-on-content-click="false"
|
<slot v-else />
|
||||||
>
|
|
||||||
<slot />
|
|
||||||
<template #popper>
|
|
||||||
<AccountHoverCard v-if="account" :account="account" />
|
|
||||||
</template>
|
|
||||||
</VMenu>
|
|
||||||
<slot v-else />
|
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { mastodon } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
inheritAttrs: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const { account, as = 'div' } = defineProps<{
|
const { account, as = 'div' } = defineProps<{
|
||||||
account: mastodon.v1.Account
|
account: mastodon.v1.Account
|
||||||
as?: string
|
as?: string
|
||||||
hoverCard?: boolean
|
hoverCard?: boolean
|
||||||
square?: boolean
|
square?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
inheritAttrs: false,
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- TODO: Make this work for both buttons and links -->
|
<!-- TODO: Make this work for both buttons and links -->
|
||||||
|
@ -23,8 +23,6 @@ const { account, as = 'div' } = defineProps<{
|
||||||
<div flex="~ col" shrink pt-1 h-full overflow-hidden justify-center leading-none select-none>
|
<div flex="~ col" shrink pt-1 h-full overflow-hidden justify-center leading-none select-none>
|
||||||
<div flex="~" gap-2>
|
<div flex="~" gap-2>
|
||||||
<AccountDisplayName :account="account" font-bold line-clamp-1 ws-pre-wrap break-all text-lg />
|
<AccountDisplayName :account="account" font-bold line-clamp-1 ws-pre-wrap break-all text-lg />
|
||||||
<AccountRolesIndicator v-if="account.roles?.length" :account="account" :limit="1" />
|
|
||||||
<AccountLockIndicator v-if="account.locked" text-xs />
|
|
||||||
<AccountBotIndicator v-if="account.bot" text-xs />
|
<AccountBotIndicator v-if="account.bot" text-xs />
|
||||||
</div>
|
</div>
|
||||||
<AccountHandle :account="account" text-secondary-light />
|
<AccountHandle :account="account" text-secondary-light />
|
||||||
|
|
|
@ -6,26 +6,17 @@ const { link = true, avatar = true } = defineProps<{
|
||||||
link?: boolean
|
link?: boolean
|
||||||
avatar?: boolean
|
avatar?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const userSettings = useUserSettings()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
export default {
|
|
||||||
inheritAttrs: false,
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AccountHoverWrapper :account="account">
|
<AccountHoverWrapper :account="account">
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
:to="link ? getAccountRoute(account) : undefined"
|
:to="link ? getAccountRoute(account) : undefined"
|
||||||
:class="link ? 'text-link-rounded -ml-1.5rem pl-1.5rem rtl-(ml0 pl-0.5rem -mr-1.5rem pr-1.5rem)' : ''"
|
:class="link ? 'text-link-rounded -ml-1.8rem pl-1.8rem rtl-(ml0 pl-0.5rem -mr-1.8rem pr-1.8rem)' : ''"
|
||||||
v-bind="$attrs"
|
|
||||||
min-w-0 flex gap-2 items-center
|
min-w-0 flex gap-2 items-center
|
||||||
>
|
>
|
||||||
<AccountAvatar v-if="avatar" :account="account" w-5 h-5 />
|
<AccountAvatar v-if="avatar" :account="account" w-5 h-5 />
|
||||||
<AccountDisplayName :account="account" :hide-emojis="getPreferences(userSettings, 'hideUsernameEmojis')" line-clamp-1 ws-pre-wrap break-all />
|
<AccountDisplayName :account="account" line-clamp-1 ws-pre-wrap break-all />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</AccountHoverWrapper>
|
</AccountHoverWrapper>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
defineProps<{
|
|
||||||
showLabel?: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div
|
|
||||||
flex="~ gap1" items-center
|
|
||||||
:class="{ 'border border-base rounded-md px-1': showLabel }"
|
|
||||||
text-secondary-light
|
|
||||||
>
|
|
||||||
<slot name="prepend" />
|
|
||||||
<CommonTooltip no-auto-focus content="Lock" :disabled="showLabel">
|
|
||||||
<div i-ri:lock-line />
|
|
||||||
</CommonTooltip>
|
|
||||||
<div v-if="showLabel">
|
|
||||||
{{ t('account.lock') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -1,63 +1,74 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { mastodon } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import { toggleBlockAccount, toggleBlockDomain, toggleMuteAccount } from '~~/composables/masto/relationship'
|
|
||||||
|
|
||||||
const { account } = defineProps<{
|
const { account } = defineProps<{
|
||||||
account: mastodon.v1.Account
|
account: mastodon.v1.Account
|
||||||
command?: boolean
|
command?: boolean
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits<{
|
let relationship = $(useRelationship(account))
|
||||||
(evt: 'addNote'): void
|
|
||||||
(evt: 'removeNote'): void
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const relationship = useRelationship(account)
|
const isSelf = $(useSelfAccount(() => account))
|
||||||
|
|
||||||
const isSelf = useSelfAccount(() => account)
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const { client } = useMasto()
|
const { client } = $(useMasto())
|
||||||
const useStarFavoriteIcon = usePreferences('useStarFavoriteIcon')
|
|
||||||
const { share, isSupported: isShareSupported } = useShare()
|
|
||||||
|
|
||||||
function shareAccount() {
|
const toggleMute = async () => {
|
||||||
share({ url: location.href })
|
if (!relationship!.muting && await openConfirmDialog({
|
||||||
}
|
title: t('confirm.mute_account.title', [account.acct]),
|
||||||
|
confirm: t('confirm.mute_account.confirm'),
|
||||||
async function toggleReblogs() {
|
cancel: t('confirm.mute_account.cancel'),
|
||||||
if (!relationship.value!.showingReblogs) {
|
}) !== 'confirm')
|
||||||
const dialogChoice = await openConfirmDialog({
|
|
||||||
title: t('confirm.show_reblogs.title'),
|
|
||||||
description: t('confirm.show_reblogs.description', [account.acct]),
|
|
||||||
confirm: t('confirm.show_reblogs.confirm'),
|
|
||||||
cancel: t('confirm.show_reblogs.cancel'),
|
|
||||||
})
|
|
||||||
if (dialogChoice.choice !== 'confirm')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const showingReblogs = !relationship.value?.showingReblogs
|
|
||||||
relationship.value = await client.value.v1.accounts.$select(account.id).follow({ reblogs: showingReblogs })
|
|
||||||
}
|
|
||||||
|
|
||||||
async function addUserNote() {
|
|
||||||
emit('addNote')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeUserNote() {
|
|
||||||
if (!relationship.value!.note || relationship.value!.note.length === 0)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
const newNote = await client.value.v1.accounts.$select(account.id).note.create({ comment: '' })
|
relationship!.muting = !relationship!.muting
|
||||||
relationship.value!.note = newNote.note
|
relationship = relationship!.muting
|
||||||
emit('removeNote')
|
? await client.v1.accounts.mute(account.id, {
|
||||||
|
// TODO support more options
|
||||||
|
})
|
||||||
|
: await client.v1.accounts.unmute(account.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleBlockUser = async () => {
|
||||||
|
if (!relationship!.blocking && await openConfirmDialog({
|
||||||
|
title: t('confirm.block_account.title', [account.acct]),
|
||||||
|
confirm: t('confirm.block_account.confirm'),
|
||||||
|
cancel: t('confirm.block_account.cancel'),
|
||||||
|
}) !== 'confirm')
|
||||||
|
return
|
||||||
|
|
||||||
|
relationship!.blocking = !relationship!.blocking
|
||||||
|
relationship = await client.v1.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleBlockDomain = async () => {
|
||||||
|
if (!relationship!.domainBlocking && await openConfirmDialog({
|
||||||
|
title: t('confirm.block_domain.title', [getServerName(account)]),
|
||||||
|
confirm: t('confirm.block_domain.confirm'),
|
||||||
|
cancel: t('confirm.block_domain.cancel'),
|
||||||
|
}) !== 'confirm')
|
||||||
|
return
|
||||||
|
|
||||||
|
relationship!.domainBlocking = !relationship!.domainBlocking
|
||||||
|
await client.v1.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleReblogs = async () => {
|
||||||
|
if (!relationship!.showingReblogs && await openConfirmDialog({
|
||||||
|
title: t('confirm.show_reblogs.title', [account.acct]),
|
||||||
|
confirm: t('confirm.show_reblogs.confirm'),
|
||||||
|
cancel: t('confirm.show_reblogs.cancel'),
|
||||||
|
}) !== 'confirm')
|
||||||
|
return
|
||||||
|
|
||||||
|
const showingReblogs = !relationship?.showingReblogs
|
||||||
|
relationship = await client.v1.accounts.follow(account.id, { reblogs: showingReblogs })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CommonDropdown :eager-mount="command">
|
<CommonDropdown :eager-mount="command">
|
||||||
<button flex gap-1 items-center w-full rounded op75 hover="op100 text-purple" group aria-label="More actions">
|
<button flex gap-1 items-center w-full rounded op75 hover="op100 text-purple" group aria-label="More actions">
|
||||||
<div rounded-5 p2 elk-group-hover="bg-purple/10">
|
<div rounded-5 p2 group-hover="bg-purple/10">
|
||||||
<div i-ri:more-2-fill />
|
<div i-ri:more-2-fill />
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
@ -70,13 +81,6 @@ async function removeUserNote() {
|
||||||
:command="command"
|
:command="command"
|
||||||
/>
|
/>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<CommonDropdownItem
|
|
||||||
v-if="isShareSupported"
|
|
||||||
:text="$t('menu.share_account', [`@${account.acct}`])"
|
|
||||||
icon="i-ri:share-line"
|
|
||||||
:command="command"
|
|
||||||
@click="shareAccount()"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<template v-if="currentUser">
|
<template v-if="currentUser">
|
||||||
<template v-if="!isSelf">
|
<template v-if="!isSelf">
|
||||||
|
@ -108,34 +112,19 @@ async function removeUserNote() {
|
||||||
@click="toggleReblogs()"
|
@click="toggleReblogs()"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CommonDropdownItem
|
|
||||||
v-if="!relationship?.note || relationship?.note?.length === 0"
|
|
||||||
:text="$t('menu.add_personal_note', [`@${account.acct}`])"
|
|
||||||
icon="i-ri-edit-2-line"
|
|
||||||
:command="command"
|
|
||||||
@click="addUserNote()"
|
|
||||||
/>
|
|
||||||
<CommonDropdownItem
|
|
||||||
v-else
|
|
||||||
:text="$t('menu.remove_personal_note', [`@${account.acct}`])"
|
|
||||||
icon="i-ri-edit-2-line"
|
|
||||||
:command="command"
|
|
||||||
@click="removeUserNote()"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<CommonDropdownItem
|
<CommonDropdownItem
|
||||||
v-if="!relationship?.muting"
|
v-if="!relationship?.muting"
|
||||||
:text="$t('menu.mute_account', [`@${account.acct}`])"
|
:text="$t('menu.mute_account', [`@${account.acct}`])"
|
||||||
icon="i-ri:volume-mute-line"
|
icon="i-ri:volume-up-fill"
|
||||||
:command="command"
|
:command="command"
|
||||||
@click="toggleMuteAccount (relationship!, account)"
|
@click="toggleMute()"
|
||||||
/>
|
/>
|
||||||
<CommonDropdownItem
|
<CommonDropdownItem
|
||||||
v-else
|
v-else
|
||||||
:text="$t('menu.unmute_account', [`@${account.acct}`])"
|
:text="$t('menu.unmute_account', [`@${account.acct}`])"
|
||||||
icon="i-ri:volume-up-fill"
|
icon="i-ri:volume-mute-line"
|
||||||
:command="command"
|
:command="command"
|
||||||
@click="toggleMuteAccount (relationship!, account)"
|
@click="toggleMute()"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CommonDropdownItem
|
<CommonDropdownItem
|
||||||
|
@ -143,14 +132,14 @@ async function removeUserNote() {
|
||||||
:text="$t('menu.block_account', [`@${account.acct}`])"
|
:text="$t('menu.block_account', [`@${account.acct}`])"
|
||||||
icon="i-ri:forbid-2-line"
|
icon="i-ri:forbid-2-line"
|
||||||
:command="command"
|
:command="command"
|
||||||
@click="toggleBlockAccount (relationship!, account)"
|
@click="toggleBlockUser()"
|
||||||
/>
|
/>
|
||||||
<CommonDropdownItem
|
<CommonDropdownItem
|
||||||
v-else
|
v-else
|
||||||
:text="$t('menu.unblock_account', [`@${account.acct}`])"
|
:text="$t('menu.unblock_account', [`@${account.acct}`])"
|
||||||
icon="i-ri:checkbox-circle-line"
|
icon="i-ri:checkbox-circle-line"
|
||||||
:command="command"
|
:command="command"
|
||||||
@click="toggleBlockAccount (relationship!, account)"
|
@click="toggleBlockUser()"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<template v-if="getServerName(account) !== currentServer">
|
<template v-if="getServerName(account) !== currentServer">
|
||||||
|
@ -159,23 +148,16 @@ async function removeUserNote() {
|
||||||
:text="$t('menu.block_domain', [getServerName(account)])"
|
:text="$t('menu.block_domain', [getServerName(account)])"
|
||||||
icon="i-ri:shut-down-line"
|
icon="i-ri:shut-down-line"
|
||||||
:command="command"
|
:command="command"
|
||||||
@click="toggleBlockDomain(relationship!, account)"
|
@click="toggleBlockDomain()"
|
||||||
/>
|
/>
|
||||||
<CommonDropdownItem
|
<CommonDropdownItem
|
||||||
v-else
|
v-else
|
||||||
:text="$t('menu.unblock_domain', [getServerName(account)])"
|
:text="$t('menu.unblock_domain', [getServerName(account)])"
|
||||||
icon="i-ri:restart-line"
|
icon="i-ri:restart-line"
|
||||||
:command="command"
|
:command="command"
|
||||||
@click="toggleBlockDomain(relationship!, account)"
|
@click="toggleBlockDomain()"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<CommonDropdownItem
|
|
||||||
:text="$t('menu.report_account', [`@${account.acct}`])"
|
|
||||||
icon="i-ri:flag-2-line"
|
|
||||||
:command="command"
|
|
||||||
@click="openReportDialog(account)"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
@ -183,7 +165,7 @@ async function removeUserNote() {
|
||||||
<CommonDropdownItem :text="$t('account.pinned')" icon="i-ri:pushpin-line" :command="command" />
|
<CommonDropdownItem :text="$t('account.pinned')" icon="i-ri:pushpin-line" :command="command" />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink to="/favourites">
|
<NuxtLink to="/favourites">
|
||||||
<CommonDropdownItem :text="$t('account.favourites')" :icon="useStarFavoriteIcon ? 'i-ri:star-line' : 'i-ri:heart-3-line'" :command="command" />
|
<CommonDropdownItem :text="$t('account.favourites')" icon="i-ri:heart-3-line" :command="command" />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink to="/mutes">
|
<NuxtLink to="/mutes">
|
||||||
<CommonDropdownItem :text="$t('account.muted_users')" icon="i-ri:volume-mute-line" :command="command" />
|
<CommonDropdownItem :text="$t('account.muted_users')" icon="i-ri:volume-mute-line" :command="command" />
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { mastodon } from 'masto'
|
import type { Paginator, mastodon } from 'masto'
|
||||||
|
|
||||||
const { paginator, account, context } = defineProps<{
|
const { paginator, account, context } = defineProps<{
|
||||||
paginator: mastodon.Paginator<mastodon.v1.Account[], mastodon.DefaultPaginationParams | undefined>
|
paginator: Paginator<mastodon.v1.Account[], mastodon.DefaultPaginationParams>
|
||||||
context?: 'following' | 'followers'
|
context?: 'following' | 'followers'
|
||||||
account?: mastodon.v1.Account
|
account?: mastodon.v1.Account
|
||||||
relationshipContext?: 'followedBy' | 'following'
|
relationshipContext?: 'followedBy' | 'following'
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const fallbackContext = computed(() => {
|
const fallbackContext = $computed(() => {
|
||||||
return ['following', 'followers'].includes(context!)
|
return ['following', 'followers'].includes(context!)
|
||||||
})
|
})
|
||||||
const showOriginSite = computed(() =>
|
const showOriginSite = $computed(() =>
|
||||||
account && account.id !== currentUser.value?.account.id && getServerName(account) !== currentServer.value,
|
account && account.id !== currentUser.value?.account.id && getServerName(account) !== currentServer.value,
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -3,7 +3,6 @@ import type { mastodon } from 'masto'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
account: mastodon.v1.Account
|
account: mastodon.v1.Account
|
||||||
isHoverCard?: boolean
|
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const userSettings = useUserSettings()
|
const userSettings = useUserSettings()
|
||||||
|
@ -27,51 +26,32 @@ const userSettings = useUserSettings()
|
||||||
</template>
|
</template>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
v-if="!(isHoverCard && getPreferences(userSettings, 'hideFollowerCount'))"
|
|
||||||
:to="getAccountFollowingRoute(account)"
|
:to="getAccountFollowingRoute(account)"
|
||||||
replace
|
replace
|
||||||
text-secondary exact-active-class="text-primary"
|
text-secondary exact-active-class="text-primary"
|
||||||
>
|
>
|
||||||
<template #default="{ isExactActive }">
|
<template #default="{ isExactActive }">
|
||||||
<template
|
<CommonLocalizedNumber
|
||||||
v-if="!getPreferences(userSettings, 'hideFollowerCount')"
|
keypath="account.following_count"
|
||||||
>
|
:count="account.followingCount"
|
||||||
<CommonLocalizedNumber
|
font-bold
|
||||||
v-if="account.followingCount >= 0"
|
:class="isExactActive ? 'text-primary' : 'text-base'"
|
||||||
keypath="account.following_count"
|
/>
|
||||||
:count="account.followingCount"
|
|
||||||
font-bold
|
|
||||||
:class="isExactActive ? 'text-primary' : 'text-base'"
|
|
||||||
/>
|
|
||||||
<div v-else flex gap-x-1>
|
|
||||||
<span font-bold text-base>Hidden</span>
|
|
||||||
<span>{{ $t('account.following') }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<span v-else>{{ $t('account.following') }}</span>
|
|
||||||
</template>
|
</template>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
v-if="!(isHoverCard && getPreferences(userSettings, 'hideFollowerCount'))"
|
v-if="!getPreferences(userSettings, 'hideFollowerCount')"
|
||||||
:to="getAccountFollowersRoute(account)"
|
:to="getAccountFollowersRoute(account)"
|
||||||
replace text-secondary
|
replace text-secondary
|
||||||
exact-active-class="text-primary"
|
exact-active-class="text-primary"
|
||||||
>
|
>
|
||||||
<template #default="{ isExactActive }">
|
<template #default="{ isExactActive }">
|
||||||
<template v-if="!getPreferences(userSettings, 'hideFollowerCount')">
|
<CommonLocalizedNumber
|
||||||
<CommonLocalizedNumber
|
keypath="account.followers_count"
|
||||||
v-if="account.followersCount >= 0"
|
:count="account.followersCount"
|
||||||
keypath="account.followers_count"
|
font-bold
|
||||||
:count="account.followersCount"
|
:class="isExactActive ? 'text-primary' : 'text-base'"
|
||||||
font-bold
|
/>
|
||||||
:class="isExactActive ? 'text-primary' : 'text-base'"
|
|
||||||
/>
|
|
||||||
<div v-else flex gap-x-1>
|
|
||||||
<span font-bold text-base>Hidden</span>
|
|
||||||
<span>{{ $t('account.followers') }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<span v-else>{{ $t('account.followers') }}</span>
|
|
||||||
</template>
|
</template>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import type { mastodon } from 'masto'
|
|
||||||
|
|
||||||
defineProps<{
|
|
||||||
account: mastodon.v1.Account
|
|
||||||
limit?: number
|
|
||||||
}>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div
|
|
||||||
flex="~ gap1" items-center
|
|
||||||
class="border border-base rounded-md px-1"
|
|
||||||
text-secondary-light
|
|
||||||
>
|
|
||||||
<slot name="prepend" />
|
|
||||||
<div v-for="role in account.roles?.slice(0, limit)" :key="role.id" flex>
|
|
||||||
<div :style="`color: ${role.color}; border-color: ${role.color}`">
|
|
||||||
{{ role.name }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="limit && account.roles?.length > limit"
|
|
||||||
flex="~ gap1" items-center
|
|
||||||
class="border border-base rounded-md px-1"
|
|
||||||
text-secondary-light
|
|
||||||
>
|
|
||||||
+{{ account.roles?.length - limit }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -1,18 +1,18 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { CommonRouteTabOption } from '~/types'
|
import type { CommonRouteTabOption } from '../common/CommonRouteTabs.vue'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const server = computed(() => route.params.server as string)
|
const server = $(computedEager(() => route.params.server as string))
|
||||||
const account = computed(() => route.params.account as string)
|
const account = $(computedEager(() => route.params.account as string))
|
||||||
|
|
||||||
const tabs = computed<CommonRouteTabOption[]>(() => [
|
const tabs = $computed<CommonRouteTabOption[]>(() => [
|
||||||
{
|
{
|
||||||
name: 'account-index',
|
name: 'account-index',
|
||||||
to: {
|
to: {
|
||||||
name: 'account-index',
|
name: 'account-index',
|
||||||
params: { server: server.value, account: account.value },
|
params: { server, account },
|
||||||
},
|
},
|
||||||
display: t('tab.posts'),
|
display: t('tab.posts'),
|
||||||
icon: 'i-ri:file-list-2-line',
|
icon: 'i-ri:file-list-2-line',
|
||||||
|
@ -21,7 +21,7 @@ const tabs = computed<CommonRouteTabOption[]>(() => [
|
||||||
name: 'account-replies',
|
name: 'account-replies',
|
||||||
to: {
|
to: {
|
||||||
name: 'account-replies',
|
name: 'account-replies',
|
||||||
params: { server: server.value, account: account.value },
|
params: { server, account },
|
||||||
},
|
},
|
||||||
display: t('tab.posts_with_replies'),
|
display: t('tab.posts_with_replies'),
|
||||||
icon: 'i-ri:chat-1-line',
|
icon: 'i-ri:chat-1-line',
|
||||||
|
@ -30,7 +30,7 @@ const tabs = computed<CommonRouteTabOption[]>(() => [
|
||||||
name: 'account-media',
|
name: 'account-media',
|
||||||
to: {
|
to: {
|
||||||
name: 'account-media',
|
name: 'account-media',
|
||||||
params: { server: server.value, account: account.value },
|
params: { server, account },
|
||||||
},
|
},
|
||||||
display: t('tab.media'),
|
display: t('tab.media'),
|
||||||
icon: 'i-ri:camera-2-line',
|
icon: 'i-ri:camera-2-line',
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import type { mastodon } from 'masto'
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
inheritAttrs: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const { tagName, disabled } = defineProps<{
|
|
||||||
tagName?: string
|
|
||||||
disabled?: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const tag = ref<mastodon.v1.Tag>()
|
|
||||||
const tagHover = ref()
|
|
||||||
const hovered = useElementHover(tagHover)
|
|
||||||
|
|
||||||
watch(hovered, (newHovered) => {
|
|
||||||
if (newHovered && tagName) {
|
|
||||||
fetchTag(tagName).then((t) => {
|
|
||||||
tag.value = t
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const userSettings = useUserSettings()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<span ref="tagHover">
|
|
||||||
<VMenu
|
|
||||||
v-if="!disabled && !getPreferences(userSettings, 'hideTagHoverCard')"
|
|
||||||
placement="bottom-start"
|
|
||||||
:delay="{ show: 500, hide: 100 }"
|
|
||||||
v-bind="$attrs"
|
|
||||||
:close-on-content-click="false"
|
|
||||||
>
|
|
||||||
<slot />
|
|
||||||
<template #popper>
|
|
||||||
<TagCardSkeleton v-if="!tag" />
|
|
||||||
<TagCard v-else :tag="tag" />
|
|
||||||
</template>
|
|
||||||
</VMenu>
|
|
||||||
<slot v-else />
|
|
||||||
</span>
|
|
||||||
</template>
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { LocaleObject } from '@nuxtjs/i18n'
|
|
||||||
import type { AriaAnnounceType, AriaLive } from '~/composables/aria'
|
import type { AriaAnnounceType, AriaLive } from '~/composables/aria'
|
||||||
|
import type { LocaleObject } from '#i18n'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { t, locale, locales } = useI18n()
|
const { t, locale, locales } = useI18n()
|
||||||
|
@ -11,16 +11,16 @@ const localeMap = (locales.value as LocaleObject[]).reduce((acc, l) => {
|
||||||
return acc
|
return acc
|
||||||
}, {} as Record<string, string>)
|
}, {} as Record<string, string>)
|
||||||
|
|
||||||
const ariaLive = ref<AriaLive>('polite')
|
let ariaLive = $ref<AriaLive>('polite')
|
||||||
const ariaMessage = ref<string>('')
|
let ariaMessage = $ref<string>('')
|
||||||
|
|
||||||
function onMessage(event: AriaAnnounceType, message?: string) {
|
const onMessage = (event: AriaAnnounceType, message?: string) => {
|
||||||
if (event === 'announce')
|
if (event === 'announce')
|
||||||
ariaMessage.value = message!
|
ariaMessage = message!
|
||||||
else if (event === 'mute')
|
else if (event === 'mute')
|
||||||
ariaLive.value = 'off'
|
ariaLive = 'off'
|
||||||
else
|
else
|
||||||
ariaLive.value = 'polite'
|
ariaLive = 'polite'
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(locale, (l, ol) => {
|
watch(locale, (l, ol) => {
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ResolvedCommand } from '~/composables/command'
|
import type { ResolvedCommand } from '~/composables/command'
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(event: 'activate'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
cmd,
|
cmd,
|
||||||
index,
|
index,
|
||||||
active = false,
|
active = false,
|
||||||
} = defineProps<{
|
} = $defineProps<{
|
||||||
cmd: ResolvedCommand
|
cmd: ResolvedCommand
|
||||||
index: number
|
index: number
|
||||||
active?: boolean
|
active?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(event: 'activate'): void
|
|
||||||
}>()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -5,7 +5,7 @@ const props = defineProps<{
|
||||||
|
|
||||||
const isMac = useIsMac()
|
const isMac = useIsMac()
|
||||||
|
|
||||||
const keys = computed(() => props.name.toLowerCase().split('+'))
|
const keys = $computed(() => props.name.toLowerCase().split('+'))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -10,33 +10,31 @@ const registry = useCommandRegistry()
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const inputEl = ref<HTMLInputElement>()
|
const inputEl = $ref<HTMLInputElement>()
|
||||||
const resultEl = ref<HTMLDivElement>()
|
const resultEl = $ref<HTMLDivElement>()
|
||||||
|
|
||||||
const scopes = ref<CommandScope[]>([])
|
const scopes = $ref<CommandScope[]>([])
|
||||||
const input = commandPanelInput
|
let input = $(commandPanelInput)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
inputEl.value?.focus()
|
inputEl?.focus()
|
||||||
})
|
})
|
||||||
|
|
||||||
const commandMode = computed(() => input.value.startsWith('>'))
|
const commandMode = $computed(() => input.startsWith('>'))
|
||||||
|
|
||||||
const query = computed(() => commandMode.value ? '' : input.value.trim())
|
const query = $computed(() => commandMode ? '' : input.trim())
|
||||||
|
|
||||||
const { accounts, hashtags, loading } = useSearch(query)
|
const { accounts, hashtags, loading } = useSearch($$(query))
|
||||||
|
|
||||||
function toSearchQueryResultItem(search: SearchResultType): QueryResultItem {
|
const toSearchQueryResultItem = (search: SearchResultType): QueryResultItem => ({
|
||||||
return {
|
index: 0,
|
||||||
index: 0,
|
type: 'search',
|
||||||
type: 'search',
|
search,
|
||||||
search,
|
onActivate: () => router.push(search.to),
|
||||||
onActivate: () => router.push(search.to),
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const searchResult = computed<QueryResult>(() => {
|
const searchResult = $computed<QueryResult>(() => {
|
||||||
if (query.value.length === 0 || loading.value)
|
if (query.length === 0 || loading.value)
|
||||||
return { length: 0, items: [], grouped: {} as any }
|
return { length: 0, items: [], grouped: {} as any }
|
||||||
|
|
||||||
// TODO extract this scope
|
// TODO extract this scope
|
||||||
|
@ -61,56 +59,55 @@ const searchResult = computed<QueryResult>(() => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = computed<QueryResult>(() => commandMode.value
|
const result = $computed<QueryResult>(() => commandMode
|
||||||
? registry.query(scopes.value.map(s => s.id).join('.'), input.value.slice(1).trim())
|
? registry.query(scopes.map(s => s.id).join('.'), input.slice(1).trim())
|
||||||
: searchResult.value,
|
: searchResult,
|
||||||
)
|
)
|
||||||
|
|
||||||
const isMac = useIsMac()
|
const isMac = useIsMac()
|
||||||
const modifierKeyName = computed(() => isMac.value ? '⌘' : 'Ctrl')
|
const modifierKeyName = $computed(() => isMac.value ? '⌘' : 'Ctrl')
|
||||||
|
|
||||||
const active = ref(0)
|
let active = $ref(0)
|
||||||
watch(result, (n, o) => {
|
watch($$(result), (n, o) => {
|
||||||
if (n.length !== o.length || !n.items.every((i, idx) => i === o.items[idx]))
|
if (n.length !== o.length || !n.items.every((i, idx) => i === o.items[idx]))
|
||||||
active.value = 0
|
active = 0
|
||||||
})
|
})
|
||||||
|
|
||||||
function findItemEl(index: number) {
|
const findItemEl = (index: number) =>
|
||||||
return resultEl.value?.querySelector(`[data-index="${index}"]`) as HTMLDivElement | null
|
resultEl?.querySelector(`[data-index="${index}"]`) as HTMLDivElement | null
|
||||||
}
|
const onCommandActivate = (item: QueryResultItem) => {
|
||||||
function onCommandActivate(item: QueryResultItem) {
|
|
||||||
if (item.onActivate) {
|
if (item.onActivate) {
|
||||||
item.onActivate()
|
item.onActivate()
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
else if (item.onComplete) {
|
else if (item.onComplete) {
|
||||||
scopes.value.push(item.onComplete())
|
scopes.push(item.onComplete())
|
||||||
input.value = '> '
|
input = '> '
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onCommandComplete(item: QueryResultItem) {
|
const onCommandComplete = (item: QueryResultItem) => {
|
||||||
if (item.onComplete) {
|
if (item.onComplete) {
|
||||||
scopes.value.push(item.onComplete())
|
scopes.push(item.onComplete())
|
||||||
input.value = '> '
|
input = '> '
|
||||||
}
|
}
|
||||||
else if (item.onActivate) {
|
else if (item.onActivate) {
|
||||||
item.onActivate()
|
item.onActivate()
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function intoView(index: number) {
|
const intoView = (index: number) => {
|
||||||
const el = findItemEl(index)
|
const el = findItemEl(index)
|
||||||
if (el)
|
if (el)
|
||||||
el.scrollIntoView({ block: 'nearest' })
|
el.scrollIntoView({ block: 'nearest' })
|
||||||
}
|
}
|
||||||
|
|
||||||
function setActive(index: number) {
|
function setActive(index: number) {
|
||||||
const len = result.value.length
|
const len = result.length
|
||||||
active.value = (index + len) % len
|
active = (index + len) % len
|
||||||
intoView(active.value)
|
intoView(active)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyDown(e: KeyboardEvent) {
|
const onKeyDown = (e: KeyboardEvent) => {
|
||||||
switch (e.key) {
|
switch (e.key) {
|
||||||
case 'p':
|
case 'p':
|
||||||
case 'ArrowUp': {
|
case 'ArrowUp': {
|
||||||
|
@ -118,7 +115,7 @@ function onKeyDown(e: KeyboardEvent) {
|
||||||
break
|
break
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
setActive(active.value - 1)
|
setActive(active - 1)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -128,7 +125,7 @@ function onKeyDown(e: KeyboardEvent) {
|
||||||
break
|
break
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
setActive(active.value + 1)
|
setActive(active + 1)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -136,9 +133,9 @@ function onKeyDown(e: KeyboardEvent) {
|
||||||
case 'Home': {
|
case 'Home': {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
active.value = 0
|
active = 0
|
||||||
|
|
||||||
intoView(active.value)
|
intoView(active)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -146,7 +143,7 @@ function onKeyDown(e: KeyboardEvent) {
|
||||||
case 'End': {
|
case 'End': {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
setActive(result.value.length - 1)
|
setActive(result.length - 1)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -154,7 +151,7 @@ function onKeyDown(e: KeyboardEvent) {
|
||||||
case 'Enter': {
|
case 'Enter': {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
const cmd = result.value.items[active.value]
|
const cmd = result.items[active]
|
||||||
if (cmd)
|
if (cmd)
|
||||||
onCommandActivate(cmd)
|
onCommandActivate(cmd)
|
||||||
|
|
||||||
|
@ -164,7 +161,7 @@ function onKeyDown(e: KeyboardEvent) {
|
||||||
case 'Tab': {
|
case 'Tab': {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
const cmd = result.value.items[active.value]
|
const cmd = result.items[active]
|
||||||
if (cmd)
|
if (cmd)
|
||||||
onCommandComplete(cmd)
|
onCommandComplete(cmd)
|
||||||
|
|
||||||
|
@ -172,9 +169,9 @@ function onKeyDown(e: KeyboardEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'Backspace': {
|
case 'Backspace': {
|
||||||
if (input.value === '>' && scopes.value.length) {
|
if (input === '>' && scopes.length) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
scopes.value.pop()
|
scopes.pop()
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'close'): void
|
(event: 'close'): void
|
||||||
}>()
|
}>()
|
||||||
const visible = defineModel<boolean>()
|
const { modelValue: visible } = defineModel<{
|
||||||
|
modelValue?: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
emit('close')
|
emit('close')
|
||||||
|
|
|
@ -1,16 +1,43 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { decode } from 'blurhash'
|
||||||
|
|
||||||
|
const { blurhash, src, srcset } = defineProps<{
|
||||||
|
blurhash?: string | null | undefined
|
||||||
|
src: string
|
||||||
|
srcset?: string
|
||||||
|
}>()
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const { blurhash = '', src, srcset, shouldLoadImage = true } = defineProps<{
|
const isLoaded = ref(false)
|
||||||
blurhash?: string
|
const placeholderSrc = $computed(() => {
|
||||||
src: string
|
if (!blurhash)
|
||||||
srcset?: string
|
return ''
|
||||||
shouldLoadImage?: boolean
|
const pixels = decode(blurhash, 32, 32)
|
||||||
}>()
|
return getDataUrlFromArr(pixels, 32, 32)
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const img = document.createElement('img')
|
||||||
|
|
||||||
|
img.onload = () => {
|
||||||
|
isLoaded.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
img.src = src
|
||||||
|
|
||||||
|
if (srcset)
|
||||||
|
img.srcset = srcset
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
isLoaded.value = true
|
||||||
|
}, 3_000)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UnLazyImage v-bind="$attrs" :blurhash="blurhash" :src="src" :src-set="srcset" :lazy-load="shouldLoadImage" auto-sizes />
|
<img v-if="isLoaded || !placeholderSrc" v-bind="$attrs" :src="src" :srcset="srcset">
|
||||||
|
<img v-else v-bind="$attrs" :src="placeholderSrc">
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,28 +1,22 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
defineProps<{
|
defineProps<{
|
||||||
label?: string
|
label: string
|
||||||
hover?: boolean
|
hover?: boolean
|
||||||
iconChecked?: string
|
|
||||||
iconUnchecked?: string
|
|
||||||
checkedIconColor?: string
|
|
||||||
prependCheckbox?: boolean
|
|
||||||
}>()
|
}>()
|
||||||
const modelValue = defineModel<boolean | null>()
|
const { modelValue } = defineModel<{
|
||||||
|
modelValue: boolean
|
||||||
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<label
|
<label
|
||||||
class="common-checkbox flex items-center cursor-pointer py-1 text-md w-full gap-y-1"
|
class="common-checkbox flex items-center cursor-pointer py-1 text-md w-full gap-y-1"
|
||||||
:class="hover ? 'hover:bg-active ms--2 px-4 py-2' : null"
|
:class="hover ? 'hover:bg-active ms--2 px-4 py-2' : null"
|
||||||
v-bind="$attrs"
|
|
||||||
@click.prevent="modelValue = !modelValue"
|
@click.prevent="modelValue = !modelValue"
|
||||||
>
|
>
|
||||||
<span v-if="label && !prependCheckbox" flex-1 ms-2 pointer-events-none>{{ label }}</span>
|
<span flex-1 ms-2 pointer-events-none>{{ label }}</span>
|
||||||
<span
|
<span
|
||||||
:class="[
|
:class="modelValue ? 'i-ri:checkbox-line' : 'i-ri:checkbox-blank-line'"
|
||||||
modelValue ? (iconChecked ?? 'i-ri:checkbox-line') : (iconUnchecked ?? 'i-ri:checkbox-blank-line'),
|
|
||||||
modelValue && checkedIconColor,
|
|
||||||
]"
|
|
||||||
text-lg
|
text-lg
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
|
@ -31,7 +25,6 @@ const modelValue = defineModel<boolean | null>()
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
sr-only
|
sr-only
|
||||||
>
|
>
|
||||||
<span v-if="label && prependCheckbox" flex-1 ms-2 pointer-events-none>{{ label }}</span>
|
|
||||||
</label>
|
</label>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,10 @@ const props = withDefaults(defineProps<Props>(), {
|
||||||
stencilSizePercentage: 0.9,
|
stencilSizePercentage: 0.9,
|
||||||
})
|
})
|
||||||
|
|
||||||
const file = defineModel<File | null>()
|
const { modelValue: file } = defineModel<{
|
||||||
|
/** Images to be cropped */
|
||||||
|
modelValue: File | null
|
||||||
|
}>()
|
||||||
|
|
||||||
const cropperDialog = ref(false)
|
const cropperDialog = ref(false)
|
||||||
|
|
||||||
|
@ -27,7 +30,7 @@ const cropperImage = reactive({
|
||||||
type: 'image/jpg',
|
type: 'image/jpg',
|
||||||
})
|
})
|
||||||
|
|
||||||
function stencilSize({ boundaries }: { boundaries: Boundaries }) {
|
const stencilSize = ({ boundaries }: { boundaries: Boundaries }) => {
|
||||||
return {
|
return {
|
||||||
width: boundaries.width * props.stencilSizePercentage,
|
width: boundaries.width * props.stencilSizePercentage,
|
||||||
height: boundaries.height * props.stencilSizePercentage,
|
height: boundaries.height * props.stencilSizePercentage,
|
||||||
|
@ -52,7 +55,7 @@ watch(file, (file, _, onCleanup) => {
|
||||||
cropperFlag.value = false
|
cropperFlag.value = false
|
||||||
})
|
})
|
||||||
|
|
||||||
function cropImage() {
|
const cropImage = () => {
|
||||||
if (cropper.value && file.value) {
|
if (cropper.value && file.value) {
|
||||||
cropperFlag.value = true
|
cropperFlag.value = true
|
||||||
cropperDialog.value = false
|
cropperDialog.value = false
|
||||||
|
|
|
@ -22,7 +22,9 @@ const emit = defineEmits<{
|
||||||
(event: 'error', code: number, message: string): void
|
(event: 'error', code: number, message: string): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const file = defineModel<FileWithHandle | null>()
|
const { modelValue: file } = defineModel<{
|
||||||
|
modelValue: FileWithHandle | null
|
||||||
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
@ -32,9 +34,7 @@ const previewImage = ref('')
|
||||||
/** The current images on display */
|
/** The current images on display */
|
||||||
const imageSrc = computed<string>(() => previewImage.value || defaultImage.value)
|
const imageSrc = computed<string>(() => previewImage.value || defaultImage.value)
|
||||||
|
|
||||||
async function pickImage() {
|
const pickImage = async () => {
|
||||||
if (import.meta.server)
|
|
||||||
return
|
|
||||||
const image = await fileOpen({
|
const image = await fileOpen({
|
||||||
description: 'Image',
|
description: 'Image',
|
||||||
mimeTypes: props.allowedFileTypes,
|
mimeTypes: props.allowedFileTypes,
|
||||||
|
|
|
@ -2,73 +2,49 @@
|
||||||
// @ts-expect-error missing types
|
// @ts-expect-error missing types
|
||||||
import { DynamicScroller } from 'vue-virtual-scroller'
|
import { DynamicScroller } from 'vue-virtual-scroller'
|
||||||
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
|
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
|
||||||
import type { mastodon } from 'masto'
|
import type { Paginator, WsEvents } from 'masto'
|
||||||
import type { UnwrapRef } from 'vue'
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
paginator,
|
paginator,
|
||||||
stream,
|
stream,
|
||||||
eventType,
|
|
||||||
keyProp = 'id',
|
keyProp = 'id',
|
||||||
virtualScroller = false,
|
virtualScroller = false,
|
||||||
|
eventType = 'update',
|
||||||
preprocess,
|
preprocess,
|
||||||
endMessage = true,
|
noEndMessage = false,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
paginator: mastodon.Paginator<T[], O>
|
paginator: Paginator<T[], O>
|
||||||
keyProp?: keyof T
|
keyProp?: keyof T
|
||||||
virtualScroller?: boolean
|
virtualScroller?: boolean
|
||||||
stream?: mastodon.streaming.Subscription
|
stream?: Promise<WsEvents>
|
||||||
eventType?: 'update' | 'notification'
|
eventType?: 'notification' | 'update'
|
||||||
preprocess?: (items: (U | T)[]) => U[]
|
preprocess?: (items: (U | T)[]) => U[]
|
||||||
endMessage?: boolean | string
|
noEndMessage?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
defineSlots<{
|
defineSlots<{
|
||||||
default: (props: {
|
default: {
|
||||||
items: U[]
|
items: U[]
|
||||||
item: U
|
item: U
|
||||||
index: number
|
index: number
|
||||||
active?: boolean
|
active?: boolean
|
||||||
older: U
|
older?: U
|
||||||
newer: U // newer is undefined when index === 0
|
newer?: U // newer is undefined when index === 0
|
||||||
}) => void
|
}
|
||||||
items: (props: {
|
items: {
|
||||||
items: UnwrapRef<U[]>
|
items: U[]
|
||||||
}) => void
|
}
|
||||||
updater: (props: {
|
updater: {
|
||||||
number: number
|
number: number
|
||||||
update: () => void
|
update: () => void
|
||||||
}) => void
|
}
|
||||||
loading: (props: object) => void
|
loading: {}
|
||||||
done: (props: { items: U[] }) => void
|
done: {}
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const nuxtApp = useNuxtApp()
|
|
||||||
|
|
||||||
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, toRef(() => stream), eventType, preprocess)
|
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, $$(stream), eventType, preprocess)
|
||||||
|
|
||||||
nuxtApp.hook('elk-logo:click', () => {
|
|
||||||
update()
|
|
||||||
nuxtApp.$scrollToTop()
|
|
||||||
})
|
|
||||||
|
|
||||||
function createEntry(item: any) {
|
|
||||||
items.value = [...items.value, preprocess?.([item]) ?? item]
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateEntry(item: any) {
|
|
||||||
const id = item[keyProp]
|
|
||||||
const index = items.value.findIndex(i => (i as any)[keyProp] === id)
|
|
||||||
if (index > -1)
|
|
||||||
items.value = [...items.value.slice(0, index), preprocess?.([item]) ?? item, ...items.value.slice(index + 1)]
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeEntry(entryId: any) {
|
|
||||||
items.value = items.value.filter(i => (i as any)[keyProp] !== entryId)
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({ createEntry, removeEntry, updateEntry })
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -84,25 +60,25 @@ defineExpose({ createEntry, removeEntry, updateEntry })
|
||||||
page-mode
|
page-mode
|
||||||
>
|
>
|
||||||
<slot
|
<slot
|
||||||
v-bind="{ key: item[keyProp] }"
|
:key="item[keyProp]"
|
||||||
:item="item"
|
:item="item"
|
||||||
:active="active"
|
:active="active"
|
||||||
:older="items[index + 1] as U"
|
:older="items[index + 1]"
|
||||||
:newer="items[index - 1] as U"
|
:newer="items[index - 1]"
|
||||||
:index="index"
|
:index="index"
|
||||||
:items="items as U[]"
|
:items="items"
|
||||||
/>
|
/>
|
||||||
</DynamicScroller>
|
</DynamicScroller>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<slot
|
<slot
|
||||||
v-for="(item, index) of items"
|
v-for="item, index of items"
|
||||||
v-bind="{ key: (item as U)[keyProp as keyof U] }"
|
:key="(item as any)[keyProp]"
|
||||||
:item="item as U"
|
:item="item"
|
||||||
:older="items[index + 1] as U"
|
:older="items[index + 1]"
|
||||||
:newer="items[index - 1] as U"
|
:newer="items[index - 1]"
|
||||||
:index="index"
|
:index="index"
|
||||||
:items="items as U[]"
|
:items="items"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</slot>
|
</slot>
|
||||||
|
@ -110,9 +86,9 @@ defineExpose({ createEntry, removeEntry, updateEntry })
|
||||||
<slot v-if="state === 'loading'" name="loading">
|
<slot v-if="state === 'loading'" name="loading">
|
||||||
<TimelineSkeleton />
|
<TimelineSkeleton />
|
||||||
</slot>
|
</slot>
|
||||||
<slot v-else-if="state === 'done' && endMessage !== false" name="done" :items="items as U[]">
|
<slot v-else-if="state === 'done' && !noEndMessage" name="done">
|
||||||
<div p5 text-secondary italic text-center>
|
<div p5 text-secondary italic text-center>
|
||||||
{{ t(typeof endMessage === 'string' && items.length <= 0 ? endMessage : 'common.end_of_list') }}
|
{{ t('common.end_of_list') }}
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
</slot>
|
||||||
<div v-else-if="state === 'error'" p5 text-secondary>
|
<div v-else-if="state === 'error'" p5 text-secondary>
|
||||||
|
|
|
@ -14,7 +14,7 @@ const build = useBuildInfo()
|
||||||
<p>
|
<p>
|
||||||
<i18n-t keypath="help.build_preview.desc1">
|
<i18n-t keypath="help.build_preview.desc1">
|
||||||
<NuxtLink :href="`https://github.com/elk-zone/elk/commit/${build.commit}`" target="_blank" text-rose hover:underline>
|
<NuxtLink :href="`https://github.com/elk-zone/elk/commit/${build.commit}`" target="_blank" text-rose hover:underline>
|
||||||
<code>{{ build.shortCommit }}</code>
|
<code>{{ build.commit.slice(0, 7) }}</code>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -4,7 +4,9 @@ defineProps<{
|
||||||
value: any
|
value: any
|
||||||
hover?: boolean
|
hover?: boolean
|
||||||
}>()
|
}>()
|
||||||
const modelValue = defineModel()
|
const { modelValue } = defineModel<{
|
||||||
|
modelValue: any
|
||||||
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,20 +1,26 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { CommonRouteTabMoreOption, CommonRouteTabOption } from '~/types'
|
import type { RouteLocationRaw } from 'vue-router'
|
||||||
|
|
||||||
const { options, command, replace, preventScrollTop = false, moreOptions } = defineProps<{
|
export interface CommonRouteTabOption {
|
||||||
|
to: RouteLocationRaw
|
||||||
|
display: string
|
||||||
|
disabled?: boolean
|
||||||
|
name?: string
|
||||||
|
icon?: string
|
||||||
|
}
|
||||||
|
const { options, command, replace, preventScrollTop = false } = $defineProps<{
|
||||||
options: CommonRouteTabOption[]
|
options: CommonRouteTabOption[]
|
||||||
moreOptions?: CommonRouteTabMoreOption
|
|
||||||
command?: boolean
|
command?: boolean
|
||||||
replace?: boolean
|
replace?: boolean
|
||||||
preventScrollTop?: boolean
|
preventScrollTop?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
useCommands(() => command
|
useCommands(() => command
|
||||||
? options.map(tab => ({
|
? options.map(tab => ({
|
||||||
scope: 'Tabs',
|
scope: 'Tabs',
|
||||||
|
|
||||||
name: tab.display,
|
name: tab.display,
|
||||||
icon: tab.icon ?? 'i-ri:file-list-2-line',
|
icon: tab.icon ?? 'i-ri:file-list-2-line',
|
||||||
onActivate: () => router.replace(tab.to),
|
onActivate: () => router.replace(tab.to),
|
||||||
|
@ -23,9 +29,9 @@ useCommands(() => command
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div flex w-full items-center lg:text-lg of-x-auto scrollbar-hide border="b base">
|
<div flex w-full items-center lg:text-lg of-x-auto scrollbar-hide>
|
||||||
<template
|
<template
|
||||||
v-for="(option, index) in options.filter(item => !item.hide)"
|
v-for="(option, index) in options"
|
||||||
:key="option?.name || index"
|
:key="option?.name || index"
|
||||||
>
|
>
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
|
@ -33,7 +39,7 @@ useCommands(() => command
|
||||||
:to="option.to"
|
:to="option.to"
|
||||||
:replace="replace"
|
:replace="replace"
|
||||||
relative flex flex-auto cursor-pointer sm:px6 px2 rounded transition-all
|
relative flex flex-auto cursor-pointer sm:px6 px2 rounded transition-all
|
||||||
tabindex="0"
|
tabindex="1"
|
||||||
hover:bg-active transition-100
|
hover:bg-active transition-100
|
||||||
exact-active-class="children:(text-secondary !border-primary !op100 !text-base)"
|
exact-active-class="children:(text-secondary !border-primary !op100 !text-base)"
|
||||||
@click="!preventScrollTop && $scrollToTop()"
|
@click="!preventScrollTop && $scrollToTop()"
|
||||||
|
@ -44,43 +50,5 @@ useCommands(() => command
|
||||||
<span ws-nowrap mxa sm:px2 sm:py3 py2 text-center text-secondary-light op50>{{ option.display }}</span>
|
<span ws-nowrap mxa sm:px2 sm:py3 py2 text-center text-secondary-light op50>{{ option.display }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="isHydrated && moreOptions?.options?.length">
|
|
||||||
<CommonDropdown placement="bottom" flex cursor-pointer mx-1.25rem>
|
|
||||||
<CommonTooltip placement="top" no-auto-focus :content="moreOptions.tooltip || t('action.more')">
|
|
||||||
<button
|
|
||||||
cursor-pointer
|
|
||||||
flex
|
|
||||||
gap-1
|
|
||||||
w-12
|
|
||||||
rounded
|
|
||||||
hover:bg-active
|
|
||||||
btn-action-icon
|
|
||||||
op75
|
|
||||||
px4
|
|
||||||
group
|
|
||||||
:aria-label="t('action.more')"
|
|
||||||
:class="moreOptions.match ? 'text-primary' : 'text-secondary'"
|
|
||||||
>
|
|
||||||
<span v-if="moreOptions.icon" :class="moreOptions.icon" text-sm me--1 block />
|
|
||||||
<span i-ri:arrow-down-s-line text-sm me--1 block />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
<template #popper>
|
|
||||||
<NuxtLink
|
|
||||||
v-for="(option, index) in moreOptions.options.filter(item => !item.hide)"
|
|
||||||
:key="option?.name || index"
|
|
||||||
:to="option.to"
|
|
||||||
>
|
|
||||||
<CommonDropdownItem>
|
|
||||||
<span flex="~ row" gap-x-4 items-center :class="option.match ? 'text-primary' : ''">
|
|
||||||
<span v-if="option.icon" :class="[option.icon, option.match ? 'text-primary' : 'text.secondary']" text-md me--1 block />
|
|
||||||
<span v-else block> </span>
|
|
||||||
<span>{{ option.display }}</span>
|
|
||||||
</span>
|
|
||||||
</CommonDropdownItem>
|
|
||||||
</NuxtLink>
|
|
||||||
</template>
|
|
||||||
</commondropdown>
|
|
||||||
</template>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { as = 'div', active } = defineProps<{
|
const { as = 'div', active } = defineProps<{ as: any; active: boolean }>()
|
||||||
as: any
|
|
||||||
active: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const el = ref()
|
const el = ref()
|
||||||
|
|
||||||
watch(() => active, (active) => {
|
watch(() => active, (active) => {
|
||||||
|
|
|
@ -8,9 +8,11 @@ const { options, command } = defineProps<{
|
||||||
command?: boolean
|
command?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const modelValue = defineModel<string>({ required: true })
|
const { modelValue } = defineModel<{
|
||||||
|
modelValue: string
|
||||||
|
}>()
|
||||||
|
|
||||||
const tabs = computed(() => {
|
const tabs = $computed(() => {
|
||||||
return options.map((option) => {
|
return options.map((option) => {
|
||||||
if (typeof option === 'string')
|
if (typeof option === 'string')
|
||||||
return { name: option, display: option }
|
return { name: option, display: option }
|
||||||
|
@ -19,12 +21,12 @@ const tabs = computed(() => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function toValidName(option: string) {
|
function toValidName(otpion: string) {
|
||||||
return option.toLowerCase().replace(/[^a-zA-Z0-9]/g, '-')
|
return otpion.toLowerCase().replace(/[^a-zA-Z0-9]/g, '-')
|
||||||
}
|
}
|
||||||
|
|
||||||
useCommands(() => command
|
useCommands(() => command
|
||||||
? tabs.value.map(tab => ({
|
? tabs.map(tab => ({
|
||||||
scope: 'Tabs',
|
scope: 'Tabs',
|
||||||
|
|
||||||
name: tab.display,
|
name: tab.display,
|
||||||
|
@ -49,7 +51,7 @@ useCommands(() => command
|
||||||
><label
|
><label
|
||||||
flex flex-auto cursor-pointer px3 m1 rounded transition-all
|
flex flex-auto cursor-pointer px3 m1 rounded transition-all
|
||||||
:for="`tab-${toValidName(option.name)}`"
|
:for="`tab-${toValidName(option.name)}`"
|
||||||
tabindex="0"
|
tabindex="1"
|
||||||
hover:bg-active transition-100
|
hover:bg-active transition-100
|
||||||
@keypress.enter="modelValue = option.name"
|
@keypress.enter="modelValue = option.name"
|
||||||
><span
|
><span
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Popper as VTooltipType } from 'floating-vue'
|
import type { Popper as VTooltipType } from 'floating-vue/dist'
|
||||||
|
|
||||||
export interface Props extends Partial<typeof VTooltipType> {
|
defineProps<{
|
||||||
content?: string
|
content?: string
|
||||||
}
|
} & Partial<typeof VTooltipType>>()
|
||||||
|
|
||||||
defineProps<Props>()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VTooltip
|
<VTooltip
|
||||||
v-if="isHydrated"
|
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
auto-hide
|
auto-hide
|
||||||
>
|
>
|
||||||
|
|
|
@ -4,20 +4,20 @@ import type { mastodon } from 'masto'
|
||||||
const {
|
const {
|
||||||
history,
|
history,
|
||||||
maxDay = 2,
|
maxDay = 2,
|
||||||
} = defineProps<{
|
} = $defineProps<{
|
||||||
history: mastodon.v1.TagHistory[]
|
history: mastodon.v1.TagHistory[]
|
||||||
maxDay?: number
|
maxDay?: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const ongoingHot = computed(() => history.slice(0, maxDay))
|
const ongoingHot = $computed(() => history.slice(0, maxDay))
|
||||||
|
|
||||||
const people = computed(() =>
|
const people = $computed(() =>
|
||||||
ongoingHot.value.reduce((total: number, item) => total + (Number(item.accounts) || 0), 0),
|
ongoingHot.reduce((total: number, item) => total + (Number(item.accounts) || 0), 0),
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<p>
|
<p>
|
||||||
{{ $t('command.n_people_in_the_past_n_days', [people, maxDay]) }}
|
{{ $t('command.n-people-in-the-past-n-days', [people, maxDay]) }}
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -6,22 +6,22 @@ const {
|
||||||
history,
|
history,
|
||||||
width = 60,
|
width = 60,
|
||||||
height = 40,
|
height = 40,
|
||||||
} = defineProps<{
|
} = $defineProps<{
|
||||||
history?: mastodon.v1.TagHistory[]
|
history?: mastodon.v1.TagHistory[]
|
||||||
width?: number
|
width?: number
|
||||||
height?: number
|
height?: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const historyNum = computed(() => {
|
const historyNum = $computed(() => {
|
||||||
if (!history)
|
if (!history)
|
||||||
return [1, 1, 1, 1, 1, 1, 1]
|
return [1, 1, 1, 1, 1, 1, 1]
|
||||||
return [...history].reverse().map(item => Number(item.accounts) || 0)
|
return [...history].reverse().map(item => Number(item.accounts) || 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
const sparklineEl = ref<SVGSVGElement>()
|
const sparklineEl = $ref<SVGSVGElement>()
|
||||||
const sparklineFn = typeof sparkline !== 'function' ? (sparkline as any).default : sparkline
|
const sparklineFn = typeof sparkline !== 'function' ? (sparkline as any).default : sparkline
|
||||||
|
|
||||||
watch([historyNum, sparklineEl], ([historyNum, sparklineEl]) => {
|
watch([$$(historyNum), $$(sparklineEl)], ([historyNum, sparklineEl]) => {
|
||||||
if (!sparklineEl)
|
if (!sparklineEl)
|
||||||
return
|
return
|
||||||
sparklineFn(sparklineEl, historyNum)
|
sparklineFn(sparklineEl, historyNum)
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
defineOptions({
|
|
||||||
inheritAttrs: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
count: number
|
count: number
|
||||||
keypath: string
|
keypath: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
inheritAttrs: false,
|
||||||
|
})
|
||||||
|
|
||||||
const { formatHumanReadableNumber, formatNumber, forSR } = useHumanReadableNumber()
|
const { formatHumanReadableNumber, formatNumber, forSR } = useHumanReadableNumber()
|
||||||
|
|
||||||
const useSR = computed(() => forSR(props.count))
|
const useSR = $computed(() => forSR(props.count))
|
||||||
const rawNumber = computed(() => formatNumber(props.count))
|
const rawNumber = $computed(() => formatNumber(props.count))
|
||||||
const humanReadableNumber = computed(() => formatHumanReadableNumber(props.count))
|
const humanReadableNumber = $computed(() => formatHumanReadableNumber(props.count))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -6,12 +6,10 @@ defineProps<{
|
||||||
autoBoundaryMaxSize?: boolean
|
autoBoundaryMaxSize?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const dropdown = ref<any>()
|
const dropdown = $ref<any>()
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
|
|
||||||
function hide() {
|
const hide = () => dropdown.hide()
|
||||||
return dropdown.value.hide()
|
|
||||||
}
|
|
||||||
provide(InjectionKeyDropdownContext, {
|
provide(InjectionKeyDropdownContext, {
|
||||||
hide,
|
hide,
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,7 +15,7 @@ const { hide } = useDropdownContext() || {}
|
||||||
|
|
||||||
const el = ref<HTMLDivElement>()
|
const el = ref<HTMLDivElement>()
|
||||||
|
|
||||||
function handleClick(evt: MouseEvent) {
|
const handleClick = (evt: MouseEvent) => {
|
||||||
hide?.()
|
hide?.()
|
||||||
emit('click', evt)
|
emit('click', evt)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ useCommand({
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:is="is"
|
:is="is"
|
||||||
ref="el"
|
ref="el"
|
||||||
w-full
|
|
||||||
flex gap-3 items-center cursor-pointer px4 py3
|
flex gap-3 items-center cursor-pointer px4 py3
|
||||||
select-none
|
select-none
|
||||||
hover-bg-active
|
hover-bg-active
|
||||||
|
|
|
@ -4,7 +4,7 @@ const props = defineProps<{
|
||||||
lang?: string
|
lang?: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const raw = computed(() => decodeURIComponent(props.code).replace(/'/g, '\''))
|
const raw = $computed(() => decodeURIComponent(props.code).replace(/'/g, '\''))
|
||||||
|
|
||||||
const langMap: Record<string, string> = {
|
const langMap: Record<string, string> = {
|
||||||
js: 'javascript',
|
js: 'javascript',
|
||||||
|
@ -13,7 +13,7 @@ const langMap: Record<string, string> = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const highlighted = computed(() => {
|
const highlighted = computed(() => {
|
||||||
return props.lang ? highlightCode(raw.value, (langMap[props.lang] || props.lang) as any) : raw
|
return props.lang ? highlightCode(raw, (langMap[props.lang] || props.lang) as any) : raw
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,10 @@ defineOptions({
|
||||||
const {
|
const {
|
||||||
content,
|
content,
|
||||||
emojis,
|
emojis,
|
||||||
hideEmojis = false,
|
|
||||||
markdown = true,
|
markdown = true,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
content: string
|
content: string
|
||||||
emojis?: mastodon.v1.CustomEmoji[]
|
emojis?: mastodon.v1.CustomEmoji[]
|
||||||
hideEmojis?: boolean
|
|
||||||
markdown?: boolean
|
markdown?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
@ -23,7 +21,6 @@ export default () => h(
|
||||||
{ class: 'content-rich', dir: 'auto' },
|
{ class: 'content-rich', dir: 'auto' },
|
||||||
contentToVNode(content, {
|
contentToVNode(content, {
|
||||||
emojis: emojisObject.value,
|
emojis: emojisObject.value,
|
||||||
hideEmojis,
|
|
||||||
markdown,
|
markdown,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@ const { conversation } = defineProps<{
|
||||||
conversation: mastodon.v1.Conversation
|
conversation: mastodon.v1.Conversation
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const withAccounts = computed(() =>
|
const withAccounts = $computed(() =>
|
||||||
conversation.accounts.filter(account => account.id !== conversation.lastStatus?.account.id),
|
conversation.accounts.filter(account => account.id !== conversation.lastStatus?.account.id),
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { mastodon } from 'masto'
|
import type { Paginator, mastodon } from 'masto'
|
||||||
|
|
||||||
const { paginator } = defineProps<{
|
const { paginator } = defineProps<{
|
||||||
paginator: mastodon.Paginator<mastodon.v1.Conversation[], mastodon.DefaultPaginationParams>
|
paginator: Paginator<mastodon.v1.Conversation[], mastodon.DefaultPaginationParams>
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
function preprocess(items: mastodon.v1.Conversation[]): mastodon.v1.Conversation[] {
|
function preprocess(items: mastodon.v1.Conversation[]): mastodon.v1.Conversation[] {
|
||||||
const isAuthored = (conversation: mastodon.v1.Conversation) => conversation.lastStatus ? conversation.lastStatus.account.id === currentUser.value?.account.id : false
|
return items.filter(items => !items.lastStatus?.filtered?.find(
|
||||||
return items.filter(item => isAuthored(item) || !item.lastStatus?.filtered?.find(
|
|
||||||
filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('thread'),
|
filter => filter.filter.filterAction === 'hide' && filter.filter.context.includes('thread'),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
const { as, alt, dataEmojiId } = defineProps<{
|
|
||||||
as: string
|
|
||||||
alt?: string
|
|
||||||
dataEmojiId?: string
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const title = ref<string | undefined>()
|
|
||||||
|
|
||||||
if (alt) {
|
|
||||||
if (alt.startsWith(':')) {
|
|
||||||
title.value = alt.replace(/:/g, '')
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
import('node-emoji').then(({ find }) => {
|
|
||||||
title.value = find(alt)?.key.replace(/_/g, ' ')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if it has a data-emoji-id, use that as the title instead
|
|
||||||
if (dataEmojiId)
|
|
||||||
title.value = dataEmojiId
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<component :is="as" v-bind="$attrs" :alt="alt" :data-emoji-id="dataEmojiId" :title="title">
|
|
||||||
<slot />
|
|
||||||
</component>
|
|
||||||
</template>
|
|
|
@ -2,17 +2,15 @@
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'close'): void
|
(event: 'close'): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const vAutoFocus = (el: HTMLElement) => el.focus()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div my-8 px-3 sm:px-8 md:max-w-200 flex="~ col gap-4" relative>
|
<div my-8 px-3 sm:px-8 md:max-w-200 flex="~ col gap-4" relative>
|
||||||
<button v-auto-focus type="button" btn-action-icon absolute top--8 right-0 m1 aria-label="Close" @click="emit('close')">
|
<button btn-action-icon absolute top--8 right-0 m1 aria-label="Close" @click="emit('close')">
|
||||||
<span i-ri:close-line />
|
<div i-ri:close-line />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<img :alt="$t('app_logo')" :src="`/${''}logo.svg`" w-20 h-20 height="80" width="80" mxa class="rtl-flip">
|
<img :alt="$t('app_logo')" src="/logo.svg" w-20 h-20 height="80" width="80" mxa class="rtl-flip">
|
||||||
<h1 mxa text-4xl mb4>
|
<h1 mxa text-4xl mb4>
|
||||||
{{ $t('help.title') }}
|
{{ $t('help.title') }}
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -30,23 +28,21 @@ const vAutoFocus = (el: HTMLElement) => el.focus()
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
{{ $t('help.desc_para6') }}
|
{{ $t('help.desc_para6') }}
|
||||||
</p>
|
</p>
|
||||||
<NuxtLink hover:text-primary href="https://github.com/sponsors/elk-zone" target="_blank">
|
{{ $t('help.desc_para3') }}
|
||||||
{{ $t('help.desc_para3') }}
|
<p flex="~ gap-2 wrap" mxa>
|
||||||
</NuxtLink>
|
|
||||||
<p flex="~ gap-2 wrap justify-center" mxa>
|
|
||||||
<template v-for="team of elkTeamMembers" :key="team.github">
|
<template v-for="team of elkTeamMembers" :key="team.github">
|
||||||
<NuxtLink :href="team.link" target="_blank" external rounded-full transition duration-300 border="~ transparent" hover="scale-105 border-primary">
|
<NuxtLink :href="`https://github.com/sponsors/${team.github}`" target="_blank" external rounded-full transition duration-300 border="~ transparent" hover="scale-105 border-primary">
|
||||||
<img :src="`/avatars/${team.github}-100x100.png`" :alt="team.display" rounded-full w-15 h-15 height="60" width="60">
|
<img :src="`/avatars/${team.github}-100x100.png`" :alt="team.display" rounded-full w-15 h-15 height="60" width="60">
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
<p italic flex justify-center w-full>
|
<p italic flex justify-center w-full>
|
||||||
<NuxtLink href="https://github.com/sponsors/elk-zone" target="_blank">
|
<NuxtLink href="https://github.com/sponsors/elk-zone" target="_blank">
|
||||||
<span text-xl font-script hover:text-primary transition duration-300>{{ $t('help.footer_team') }}</span>
|
<span text-xl font-script hover:text-primary transition duration-300>The Elk Team</span>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<button type="button" btn-solid mxa @click="emit('close')">
|
<button btn-solid mxa tabindex="2" @click="emit('close')">
|
||||||
{{ $t('action.enter_app') }}
|
{{ $t('action.enter_app') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,8 +16,8 @@ const isRemoved = ref(false)
|
||||||
async function edit() {
|
async function edit() {
|
||||||
try {
|
try {
|
||||||
isRemoved.value
|
isRemoved.value
|
||||||
? await client.v1.lists.$select(list).accounts.create({ accountIds: [account.id] })
|
? await client.v1.lists.addAccount(list, { accountIds: [account.id] })
|
||||||
: await client.v1.lists.$select(list).accounts.remove({ accountIds: [account.id] })
|
: await client.v1.lists.removeAccount(list, { accountIds: [account.id] })
|
||||||
isRemoved.value = !isRemoved.value
|
isRemoved.value = !isRemoved.value
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -36,19 +36,8 @@ async function edit() {
|
||||||
:to="getAccountRoute(account)"
|
:to="getAccountRoute(account)"
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<CommonTooltip
|
<CommonTooltip :content="isRemoved ? $t('list.add_account') : $t('list.remove_account')" :hover="isRemoved ? 'text-green' : 'text-red'">
|
||||||
:content="isRemoved ? $t('list.add_account') : $t('list.remove_account')"
|
<button :class="isRemoved ? 'i-ri:user-add-line' : 'i-ri:user-unfollow-line'" text-xl @click="edit" />
|
||||||
:hover="isRemoved ? 'text-green' : 'text-red'"
|
|
||||||
no-auto-focus
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
text-sm p2 border-1 transition-colors
|
|
||||||
border-dark
|
|
||||||
btn-action-icon
|
|
||||||
@click="edit"
|
|
||||||
>
|
|
||||||
<span :class="isRemoved ? 'i-ri:user-add-line' : 'i-ri:user-unfollow-line'" />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,211 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import type { mastodon } from 'masto'
|
|
||||||
import { useForm } from 'slimeform'
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(e: 'listUpdated', list: mastodon.v1.List): void
|
|
||||||
(e: 'listRemoved', id: string): void
|
|
||||||
}>()
|
|
||||||
const list = defineModel<mastodon.v1.List>({ required: true })
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const client = useMastoClient()
|
|
||||||
|
|
||||||
const { form, isDirty, submitter, reset } = useForm({
|
|
||||||
form: () => ({ ...list.value }),
|
|
||||||
})
|
|
||||||
|
|
||||||
const isEditing = ref<boolean>(false)
|
|
||||||
const deleting = ref<boolean>(false)
|
|
||||||
const actionError = ref<string | undefined>(undefined)
|
|
||||||
|
|
||||||
const input = ref<HTMLInputElement>()
|
|
||||||
const editBtn = ref<HTMLButtonElement>()
|
|
||||||
const deleteBtn = ref<HTMLButtonElement>()
|
|
||||||
|
|
||||||
async function prepareEdit() {
|
|
||||||
isEditing.value = true
|
|
||||||
actionError.value = undefined
|
|
||||||
await nextTick()
|
|
||||||
input.value?.focus()
|
|
||||||
}
|
|
||||||
async function cancelEdit() {
|
|
||||||
isEditing.value = false
|
|
||||||
actionError.value = undefined
|
|
||||||
reset()
|
|
||||||
|
|
||||||
await nextTick()
|
|
||||||
editBtn.value?.focus()
|
|
||||||
}
|
|
||||||
|
|
||||||
const { submit, submitting } = submitter(async () => {
|
|
||||||
try {
|
|
||||||
list.value = await client.v1.lists.$select(form.id).update({
|
|
||||||
title: form.title,
|
|
||||||
})
|
|
||||||
cancelEdit()
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
actionError.value = (err as Error).message
|
|
||||||
await nextTick()
|
|
||||||
input.value?.focus()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
async function removeList() {
|
|
||||||
if (deleting.value)
|
|
||||||
return
|
|
||||||
|
|
||||||
const confirmDelete = await openConfirmDialog({
|
|
||||||
title: t('confirm.delete_list.title'),
|
|
||||||
description: t('confirm.delete_list.description', [list.value.title]),
|
|
||||||
confirm: t('confirm.delete_list.confirm'),
|
|
||||||
cancel: t('confirm.delete_list.cancel'),
|
|
||||||
})
|
|
||||||
|
|
||||||
deleting.value = true
|
|
||||||
actionError.value = undefined
|
|
||||||
await nextTick()
|
|
||||||
|
|
||||||
if (confirmDelete.choice === 'confirm') {
|
|
||||||
await nextTick()
|
|
||||||
try {
|
|
||||||
await client.v1.lists.$select(list.value.id).remove()
|
|
||||||
emit('listRemoved', list.value.id)
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
actionError.value = (err as Error).message
|
|
||||||
await nextTick()
|
|
||||||
deleteBtn.value?.focus()
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
deleting.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
deleting.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function clearError() {
|
|
||||||
actionError.value = undefined
|
|
||||||
await nextTick()
|
|
||||||
if (isEditing.value)
|
|
||||||
input.value?.focus()
|
|
||||||
else
|
|
||||||
deleteBtn.value?.focus()
|
|
||||||
}
|
|
||||||
|
|
||||||
onDeactivated(cancelEdit)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<form
|
|
||||||
hover:bg-active flex justify-between items-center gap-x-2
|
|
||||||
:aria-describedby="actionError ? `action-list-error-${list.id}` : undefined"
|
|
||||||
:class="actionError ? 'border border-base border-rounded rounded-be-is-0 rounded-be-ie-0 border-b-unset border-$c-danger-active' : null"
|
|
||||||
@submit.prevent="submit"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
v-if="isEditing"
|
|
||||||
bg-base border="~ base" h10 m2 ps-1 pe-4 rounded-3 w-full flex="~ row"
|
|
||||||
items-center relative focus-within:box-shadow-outline gap-3
|
|
||||||
>
|
|
||||||
<CommonTooltip v-if="isEditing" :content="$t('list.cancel_edit')" no-auto-focus>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
rounded-full text-sm p2 transition-colors
|
|
||||||
hover:text-primary
|
|
||||||
@click="cancelEdit()"
|
|
||||||
>
|
|
||||||
<span block text-current i-ri:close-fill />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
<input
|
|
||||||
ref="input"
|
|
||||||
v-model="form.title"
|
|
||||||
rounded-3 w-full bg-transparent
|
|
||||||
outline="focus:none" pe-4 pb="1px"
|
|
||||||
flex-1 placeholder-text-secondary
|
|
||||||
@keydown.esc="cancelEdit()"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<NuxtLink v-else :to="`list/${list.id}`" block grow p4>
|
|
||||||
{{ form.title }}
|
|
||||||
</NuxtLink>
|
|
||||||
<div mr4 flex gap2>
|
|
||||||
<CommonTooltip v-if="isEditing" :content="$t('list.save')" no-auto-focus>
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
text-sm p2 border-1 transition-colors
|
|
||||||
border-dark hover:text-primary
|
|
||||||
btn-action-icon
|
|
||||||
:disabled="deleting || !isDirty || submitting"
|
|
||||||
>
|
|
||||||
<template v-if="isEditing">
|
|
||||||
<span v-if="submitting" aria-hidden="true" block animate animate-spin preserve-3d class="rtl-flip">
|
|
||||||
<span block i-ri:loader-2-fill aria-hidden="true" />
|
|
||||||
</span>
|
|
||||||
<span v-else block text-current i-ri:save-2-fill class="rtl-flip" />
|
|
||||||
</template>
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
<CommonTooltip v-else :content="$t('list.edit')" no-auto-focus>
|
|
||||||
<button
|
|
||||||
ref="editBtn"
|
|
||||||
type="button"
|
|
||||||
text-sm p2 border-1 transition-colors
|
|
||||||
border-dark hover:text-primary
|
|
||||||
btn-action-icon
|
|
||||||
@click.prevent="prepareEdit"
|
|
||||||
>
|
|
||||||
<span block text-current i-ri:edit-2-line class="rtl-flip" />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
<CommonTooltip :content="$t('list.delete')" no-auto-focus>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
text-sm p2 border-1 transition-colors
|
|
||||||
border-dark hover:text-primary
|
|
||||||
btn-action-icon
|
|
||||||
:disabled="isEditing"
|
|
||||||
@click.prevent="removeList"
|
|
||||||
>
|
|
||||||
<span v-if="deleting" aria-hidden="true" block animate animate-spin preserve-3d class="rtl-flip">
|
|
||||||
<span block i-ri:loader-2-fill aria-hidden="true" />
|
|
||||||
</span>
|
|
||||||
<span v-else block text-current i-ri:delete-bin-2-line class="rtl-flip" />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<CommonErrorMessage
|
|
||||||
v-if="actionError"
|
|
||||||
:id="`action-list-error-${list.id}`"
|
|
||||||
:described-by="`action-list-failed-${list.id}`"
|
|
||||||
class="rounded-bs-is-0 rounded-bs-ie-0 border-t-dashed m-b-2"
|
|
||||||
>
|
|
||||||
<header :id="`action-list-failed-${list.id}`" flex justify-between>
|
|
||||||
<div flex items-center gap-x-2 font-bold>
|
|
||||||
<div aria-hidden="true" i-ri:error-warning-fill />
|
|
||||||
<p>{{ $t(`list.${isEditing ? 'edit_error' : 'delete_error'}`) }}</p>
|
|
||||||
</div>
|
|
||||||
<CommonTooltip placement="bottom" :content="$t('list.clear_error')" no-auto-focus>
|
|
||||||
<button
|
|
||||||
flex rounded-4 p1 hover:bg-active cursor-pointer transition-100 :aria-label="$t('list.clear_error')"
|
|
||||||
@click="clearError"
|
|
||||||
>
|
|
||||||
<span aria-hidden="true" w="1.75em" h="1.75em" i-ri:close-line />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
</header>
|
|
||||||
<ol ps-2 sm:ps-1>
|
|
||||||
<li flex="~ col sm:row" gap-y-1 sm:gap-x-2>
|
|
||||||
<strong sr-only>{{ $t('list.error_prefix') }}</strong>
|
|
||||||
<span>{{ actionError }}</span>
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
</CommonErrorMessage>
|
|
||||||
</template>
|
|
|
@ -3,9 +3,9 @@ const { userId } = defineProps<{
|
||||||
userId: string
|
userId: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { client } = useMasto()
|
const { client } = $(useMasto())
|
||||||
const paginator = client.value.v1.lists.list()
|
const paginator = client.v1.lists.list()
|
||||||
const listsWithUser = ref((await client.value.v1.accounts.$select(userId).lists.list()).map(list => list.id))
|
const listsWithUser = ref((await client.v1.accounts.listLists(userId)).map(list => list.id))
|
||||||
|
|
||||||
function indexOfUserInList(listId: string) {
|
function indexOfUserInList(listId: string) {
|
||||||
return listsWithUser.value.indexOf(listId)
|
return listsWithUser.value.indexOf(listId)
|
||||||
|
@ -15,11 +15,11 @@ async function edit(listId: string) {
|
||||||
try {
|
try {
|
||||||
const index = indexOfUserInList(listId)
|
const index = indexOfUserInList(listId)
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
await client.value.v1.lists.$select(listId).accounts.create({ accountIds: [userId] })
|
await client.v1.lists.addAccount(listId, { accountIds: [userId] })
|
||||||
listsWithUser.value.push(listId)
|
listsWithUser.value.push(listId)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await client.value.v1.lists.$select(listId).accounts.remove({ accountIds: [userId] })
|
await client.v1.lists.removeAccount(listId, { accountIds: [userId] })
|
||||||
listsWithUser.value = listsWithUser.value.filter(id => id !== listId)
|
listsWithUser.value = listsWithUser.value.filter(id => id !== listId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ async function edit(listId: string) {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CommonPaginator :end-message="false" :paginator="paginator">
|
<CommonPaginator no-end-message :paginator="paginator">
|
||||||
<template #default="{ item }">
|
<template #default="{ item }">
|
||||||
<div p4 hover:bg-active block w="100%" flex justify-between items-center gap-4>
|
<div p4 hover:bg-active block w="100%" flex justify-between items-center gap-4>
|
||||||
<p>{{ item.title }}</p>
|
<p>{{ item.title }}</p>
|
||||||
|
@ -39,13 +39,9 @@ async function edit(listId: string) {
|
||||||
:hover="indexOfUserInList(item.id) === -1 ? 'text-green' : 'text-red'"
|
:hover="indexOfUserInList(item.id) === -1 ? 'text-green' : 'text-red'"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
text-sm p2 border-1 transition-colors
|
:class="indexOfUserInList(item.id) === -1 ? 'i-ri:user-add-line' : 'i-ri:user-unfollow-line'"
|
||||||
border-dark
|
text-xl @click="() => edit(item.id)"
|
||||||
btn-action-icon
|
/>
|
||||||
@click="() => edit(item.id)"
|
|
||||||
>
|
|
||||||
<span :class="indexOfUserInList(item.id) === -1 ? 'i-ri:user-add-line' : 'i-ri:user-unfollow-line'" />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,166 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
const emit = defineEmits(['close'])
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
/* TODOs:
|
|
||||||
* - I18n
|
|
||||||
*/
|
|
||||||
|
|
||||||
interface ShortcutDef {
|
|
||||||
keys: string[]
|
|
||||||
isSequence: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ShortcutItem {
|
|
||||||
description: string
|
|
||||||
shortcut: ShortcutDef
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ShortcutItemGroup {
|
|
||||||
name: string
|
|
||||||
items: ShortcutItem[]
|
|
||||||
}
|
|
||||||
|
|
||||||
const isMac = useIsMac()
|
|
||||||
const modifierKeyName = computed(() => isMac.value ? '⌘' : 'Ctrl')
|
|
||||||
|
|
||||||
const shortcutItemGroups = computed<ShortcutItemGroup[]>(() => [
|
|
||||||
{
|
|
||||||
name: t('magic_keys.groups.navigation.title'),
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.shortcut_help'),
|
|
||||||
shortcut: { keys: ['?'], isSequence: false },
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// description: t('magic_keys.groups.navigation.next_status'),
|
|
||||||
// shortcut: { keys: ['j'], isSequence: false },
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// description: t('magic_keys.groups.navigation.previous_status'),
|
|
||||||
// shortcut: { keys: ['k'], isSequence: false },
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_search'),
|
|
||||||
shortcut: { keys: ['/'], isSequence: false },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_home'),
|
|
||||||
shortcut: { keys: ['g', 'h'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_notifications'),
|
|
||||||
shortcut: { keys: ['g', 'n'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_conversations'),
|
|
||||||
shortcut: { keys: ['g', 'c'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_favourites'),
|
|
||||||
shortcut: { keys: ['g', 'f'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_bookmarks'),
|
|
||||||
shortcut: { keys: ['g', 'b'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_explore'),
|
|
||||||
shortcut: { keys: ['g', 'e'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_local'),
|
|
||||||
shortcut: { keys: ['g', 'l'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_federated'),
|
|
||||||
shortcut: { keys: ['g', 't'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_lists'),
|
|
||||||
shortcut: { keys: ['g', 'i'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_settings'),
|
|
||||||
shortcut: { keys: ['g', 's'], isSequence: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.navigation.go_to_profile'),
|
|
||||||
shortcut: { keys: ['g', 'p'], isSequence: true },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: t('magic_keys.groups.actions.title'),
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.actions.search'),
|
|
||||||
shortcut: { keys: [modifierKeyName.value, 'k'], isSequence: false },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.actions.command_mode'),
|
|
||||||
shortcut: { keys: [modifierKeyName.value, '/'], isSequence: false },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.actions.compose'),
|
|
||||||
shortcut: { keys: ['c'], isSequence: false },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.actions.show_new_items'),
|
|
||||||
shortcut: { keys: ['.'], isSequence: false },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.actions.favourite'),
|
|
||||||
shortcut: { keys: ['f'], isSequence: false },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: t('magic_keys.groups.actions.boost'),
|
|
||||||
shortcut: { keys: ['b'], isSequence: false },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: t('magic_keys.groups.media.title'),
|
|
||||||
items: [],
|
|
||||||
},
|
|
||||||
])
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div px-3 sm:px-5 py-2 sm:py-4 max-w-220 relative max-h-screen>
|
|
||||||
<button btn-action-icon absolute top-1 sm:top-2 right-1 sm:right-2 m1 :aria-label="$t('modals.aria_label_close')" @click="emit('close')">
|
|
||||||
<div i-ri:close-fill />
|
|
||||||
</button>
|
|
||||||
<h2 text-xl font-700 mb3>
|
|
||||||
{{ $t('magic_keys.dialog_header') }}
|
|
||||||
</h2>
|
|
||||||
<div mb2 grid grid-cols-1 md:grid-cols-3 gap-y- md:gap-x-6 lg:gap-x-8>
|
|
||||||
<div
|
|
||||||
v-for="group in shortcutItemGroups"
|
|
||||||
:key="group.name"
|
|
||||||
>
|
|
||||||
<h3 font-700 my-2 text-lg>
|
|
||||||
{{ group.name }}
|
|
||||||
</h3>
|
|
||||||
<div
|
|
||||||
v-for="item in group.items"
|
|
||||||
:key="item.description"
|
|
||||||
flex my-1 lg:my-2 justify-between place-items-center max-w-full text-base
|
|
||||||
>
|
|
||||||
<div mr-2 break-words overflow-hidden leading-4 h-full inline-block align-middle>
|
|
||||||
{{ item.description }}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<template
|
|
||||||
v-for="(key, idx) in item.shortcut.keys"
|
|
||||||
:key="idx"
|
|
||||||
>
|
|
||||||
<span v-if="idx !== 0" mx1 text-sm op80>{{ item.shortcut.isSequence ? $t('magic_keys.sequence_then') : '+' }}</span>
|
|
||||||
<code class="px2 md:px1.5 lg:px2 lg:px2 py0 lg:py-0.5" rounded bg-code border="px $c-border-code" shadow-sm my1 font-mono font-600>{{ key }}</code>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -4,39 +4,22 @@ defineProps<{
|
||||||
backOnSmallScreen?: boolean
|
backOnSmallScreen?: boolean
|
||||||
/** Show the back button on both small and big screens */
|
/** Show the back button on both small and big screens */
|
||||||
back?: boolean
|
back?: boolean
|
||||||
/** Do not applying overflow hidden to let use floatable components in title */
|
|
||||||
noOverflowHidden?: boolean
|
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const container = ref()
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const userSettings = useUserSettings()
|
|
||||||
const { height: windowHeight } = useWindowSize()
|
|
||||||
const { height: containerHeight } = useElementBounding(container)
|
|
||||||
const wideLayout = computed(() => route.meta.wideLayout ?? false)
|
const wideLayout = computed(() => route.meta.wideLayout ?? false)
|
||||||
const sticky = computed(() => route.path?.startsWith('/settings/'))
|
|
||||||
const containerClass = computed(() => {
|
|
||||||
// we keep original behavior when not in settings page and when the window height is smaller than the container height
|
|
||||||
if (!isHydrated.value || !sticky.value || (windowHeight.value < containerHeight.value))
|
|
||||||
return null
|
|
||||||
|
|
||||||
return 'lg:sticky lg:top-0'
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="container" :class="containerClass">
|
<div>
|
||||||
<div
|
<div
|
||||||
sticky top-0 z10
|
sticky top-0 z10 backdrop-blur
|
||||||
pt="[env(safe-area-inset-top,0)]"
|
pt="[env(safe-area-inset-top,0)]"
|
||||||
bg="[rgba(var(--rgb-bg-base),0.7)]"
|
border="b base" bg="[rgba(var(--rgb-bg-base),0.7)]"
|
||||||
class="native:lg:w-[calc(100vw-5rem)] native:xl:w-[calc(135%+(100vw-1200px)/2)]"
|
class="native:lg:w-[calc(100vw-5rem)] native:xl:w-[calc(135%+(100vw-1200px)/2)]"
|
||||||
:class="{
|
|
||||||
'backdrop-blur': !getPreferences(userSettings, 'optimizeForLowPerformanceDevice'),
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
<div flex justify-between px5 py2 :class="{ 'xl:hidden': $route.name !== 'tag' }" class="native:xl:flex" border="b base">
|
<div flex justify-between px5 py2 :class="{ 'xl:hidden': $route.name !== 'tag' }" data-tauri-drag-region class="native:xl:flex">
|
||||||
<div flex gap-3 items-center :overflow-hidden="!noOverflowHidden ? '' : false" py2 w-full>
|
<div flex gap-3 items-center overflow-hidden py2 class="native-mac:pl-14 native-mac:sm:pl-0">
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
v-if="backOnSmallScreen || back" flex="~ gap1" items-center btn-text p-0 xl:hidden
|
v-if="backOnSmallScreen || back" flex="~ gap1" items-center btn-text p-0 xl:hidden
|
||||||
:aria-label="$t('nav.back')"
|
:aria-label="$t('nav.back')"
|
||||||
|
@ -44,25 +27,23 @@ const containerClass = computed(() => {
|
||||||
>
|
>
|
||||||
<div i-ri:arrow-left-line class="rtl-flip" />
|
<div i-ri:arrow-left-line class="rtl-flip" />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<div :truncate="!noOverflowHidden ? '' : false" flex w-full data-tauri-drag-region class="native-mac:justify-start native-mac:text-center">
|
<div truncate>
|
||||||
<slot name="title" />
|
<slot name="title" />
|
||||||
</div>
|
</div>
|
||||||
<div sm:hidden h-7 w-1px />
|
<div h-7 w-1px />
|
||||||
</div>
|
</div>
|
||||||
<div flex items-center flex-shrink-0 gap-x-2>
|
<div flex items-center flex-shrink-0 gap-x-2>
|
||||||
<slot name="actions" />
|
<slot name="actions" />
|
||||||
<PwaBadge xl:hidden />
|
<PwaBadge lg:hidden />
|
||||||
<NavUser v-if="isHydrated" />
|
<NavUser v-if="isHydrated" />
|
||||||
<NavUserSkeleton v-else />
|
<NavUserSkeleton v-else />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<slot name="header">
|
<slot name="header" />
|
||||||
<div hidden />
|
|
||||||
</slot>
|
|
||||||
</div>
|
</div>
|
||||||
<PwaInstallPrompt xl:hidden />
|
<div :class="{ 'xl:block': $route.name !== 'tag' }" hidden h-6 />
|
||||||
|
<PwaInstallPrompt lg:hidden />
|
||||||
<div :class="isHydrated && wideLayout ? 'xl:w-full sm:max-w-600px' : 'sm:max-w-600px md:shrink-0'" m-auto>
|
<div :class="isHydrated && wideLayout ? 'xl:w-full sm:max-w-600px' : 'sm:max-w-600px md:shrink-0'" m-auto>
|
||||||
<div hidden :class="{ 'xl:block': $route.name !== 'tag' && !$slots.header }" h-6 />
|
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
const model = defineModel<number>()
|
|
||||||
const isValid = defineModel<boolean>('isValid')
|
|
||||||
|
|
||||||
const days = ref<number | ''>(0)
|
|
||||||
const hours = ref<number | ''>(1)
|
|
||||||
const minutes = ref<number | ''>(0)
|
|
||||||
|
|
||||||
watchEffect(() => {
|
|
||||||
if (days.value === '' || hours.value === '' || minutes.value === '') {
|
|
||||||
isValid.value = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const duration
|
|
||||||
= days.value * 24 * 60 * 60
|
|
||||||
+ hours.value * 60 * 60
|
|
||||||
+ minutes.value * 60
|
|
||||||
|
|
||||||
if (duration <= 0) {
|
|
||||||
isValid.value = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
isValid.value = true
|
|
||||||
model.value = duration
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div flex flex-grow-0 gap-2>
|
|
||||||
<label flex items-center gap-2>
|
|
||||||
<input v-model="days" type="number" min="0" max="1999" input-base :class="!isValid ? 'input-error' : null">
|
|
||||||
{{ $t('confirm.mute_account.days', days === '' ? 0 : days) }}
|
|
||||||
</label>
|
|
||||||
<label flex items-center gap-2>
|
|
||||||
<input v-model="hours" type="number" min="0" max="24" input-base :class="!isValid ? 'input-error' : null">
|
|
||||||
{{ $t('confirm.mute_account.hours', hours === '' ? 0 : hours) }}
|
|
||||||
</label>
|
|
||||||
<label flex items-center gap-2>
|
|
||||||
<input v-model="minutes" type="number" min="0" max="59" step="5" input-base :class="!isValid ? 'input-error' : null">
|
|
||||||
{{ $t('confirm.mute_account.minute', minutes === '' ? 0 : minutes) }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -1,55 +1,26 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { ConfirmDialogChoice, ConfirmDialogOptions } from '~/types'
|
import type { ConfirmDialogChoice, ConfirmDialogLabel } from '~/types'
|
||||||
import DurationPicker from '~/components/modal/DurationPicker.vue'
|
|
||||||
|
|
||||||
const props = defineProps<ConfirmDialogOptions>()
|
defineProps<ConfirmDialogLabel>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(evt: 'choice', choice: ConfirmDialogChoice): void
|
(evt: 'choice', choice: ConfirmDialogChoice): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const hasDuration = ref(false)
|
|
||||||
const isValidDuration = ref(true)
|
|
||||||
const duration = ref(60 * 60) // default to 1 hour
|
|
||||||
const shouldMuteNotifications = ref(true)
|
|
||||||
const isMute = computed(() => props.extraOptionType === 'mute')
|
|
||||||
|
|
||||||
function handleChoice(choice: ConfirmDialogChoice['choice']) {
|
|
||||||
const dialogChoice = {
|
|
||||||
choice,
|
|
||||||
...isMute.value && {
|
|
||||||
extraOptions: {
|
|
||||||
mute: {
|
|
||||||
duration: hasDuration.value ? duration.value : 0,
|
|
||||||
notifications: shouldMuteNotifications.value,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
emit('choice', dialogChoice)
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div flex="~ col" gap-6>
|
<div flex="~ col" gap-6>
|
||||||
<div font-bold text-lg>
|
<div font-bold text-lg text-center>
|
||||||
{{ title }}
|
{{ title }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="description">
|
<div v-if="description">
|
||||||
{{ description }}
|
{{ description }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isMute" flex-col flex gap-4>
|
|
||||||
<CommonCheckbox v-model="hasDuration" :label="$t('confirm.mute_account.specify_duration')" prepend-checkbox checked-icon-color="text-primary" />
|
|
||||||
<DurationPicker v-if="hasDuration" v-model="duration" v-model:is-valid="isValidDuration" />
|
|
||||||
<CommonCheckbox v-model="shouldMuteNotifications" :label="$t('confirm.mute_account.notifications')" prepend-checkbox checked-icon-color="text-primary" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div flex justify-end gap-2>
|
<div flex justify-end gap-2>
|
||||||
<button btn-text @click="handleChoice('cancel')">
|
<button btn-text @click="emit('choice', 'cancel')">
|
||||||
{{ cancel || $t('confirm.common.cancel') }}
|
{{ cancel || $t('confirm.common.cancel') }}
|
||||||
</button>
|
</button>
|
||||||
<button btn-solid :disabled="!isValidDuration" @click="handleChoice('confirm')">
|
<button btn-solid @click="emit('choice', 'confirm')">
|
||||||
{{ confirm || $t('confirm.common.confirm') }}
|
{{ confirm || $t('confirm.common.confirm') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,13 +5,10 @@ import {
|
||||||
isCommandPanelOpen,
|
isCommandPanelOpen,
|
||||||
isConfirmDialogOpen,
|
isConfirmDialogOpen,
|
||||||
isEditHistoryDialogOpen,
|
isEditHistoryDialogOpen,
|
||||||
isErrorDialogOpen,
|
|
||||||
isFavouritedBoostedByDialogOpen,
|
isFavouritedBoostedByDialogOpen,
|
||||||
isKeyboardShortcutsDialogOpen,
|
|
||||||
isMediaPreviewOpen,
|
isMediaPreviewOpen,
|
||||||
isPreviewHelpOpen,
|
isPreviewHelpOpen,
|
||||||
isPublishDialogOpen,
|
isPublishDialogOpen,
|
||||||
isReportDialogOpen,
|
|
||||||
isSigninDialogOpen,
|
isSigninDialogOpen,
|
||||||
} from '~/composables/dialog'
|
} from '~/composables/dialog'
|
||||||
|
|
||||||
|
@ -34,21 +31,21 @@ useEventListener('keydown', (e: KeyboardEvent) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function handlePublished(status: mastodon.v1.Status) {
|
const handlePublished = (status: mastodon.v1.Status) => {
|
||||||
lastPublishDialogStatus.value = status
|
lastPublishDialogStatus.value = status
|
||||||
isPublishDialogOpen.value = false
|
isPublishDialogOpen.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePublishClose() {
|
const handlePublishClose = () => {
|
||||||
lastPublishDialogStatus.value = null
|
lastPublishDialogStatus.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleConfirmChoice(choice: ConfirmDialogChoice) {
|
const handleConfirmChoice = (choice: ConfirmDialogChoice) => {
|
||||||
confirmDialogChoice.value = choice
|
confirmDialogChoice.value = choice
|
||||||
isConfirmDialogOpen.value = false
|
isConfirmDialogOpen.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFavouritedBoostedByClose() {
|
const handleFavouritedBoostedByClose = () => {
|
||||||
isFavouritedBoostedByDialogOpen.value = false
|
isFavouritedBoostedByDialogOpen.value = false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -90,9 +87,6 @@ function handleFavouritedBoostedByClose() {
|
||||||
<ModalDialog v-model="isConfirmDialogOpen" py-4 px-8 max-w-125>
|
<ModalDialog v-model="isConfirmDialogOpen" py-4 px-8 max-w-125>
|
||||||
<ModalConfirm v-if="confirmDialogLabel" v-bind="confirmDialogLabel" @choice="handleConfirmChoice" />
|
<ModalConfirm v-if="confirmDialogLabel" v-bind="confirmDialogLabel" @choice="handleConfirmChoice" />
|
||||||
</ModalDialog>
|
</ModalDialog>
|
||||||
<ModalDialog v-model="isErrorDialogOpen" py-4 px-8 max-w-125>
|
|
||||||
<ModalError v-if="errorDialogData" v-bind="errorDialogData" />
|
|
||||||
</ModalDialog>
|
|
||||||
<ModalDialog
|
<ModalDialog
|
||||||
v-model="isFavouritedBoostedByDialogOpen"
|
v-model="isFavouritedBoostedByDialogOpen"
|
||||||
max-w-180
|
max-w-180
|
||||||
|
@ -100,11 +94,5 @@ function handleFavouritedBoostedByClose() {
|
||||||
>
|
>
|
||||||
<StatusFavouritedBoostedBy />
|
<StatusFavouritedBoostedBy />
|
||||||
</ModalDialog>
|
</ModalDialog>
|
||||||
<ModalDialog v-model="isKeyboardShortcutsDialogOpen" max-w-full sm:max-w-140 md:max-w-170 lg:max-w-220 md:min-w-160>
|
|
||||||
<MagickeysKeyboardShortcuts @close="closeKeyboardShortcuts()" />
|
|
||||||
</ModalDialog>
|
|
||||||
<ModalDialog v-model="isReportDialogOpen" keep-alive max-w-175>
|
|
||||||
<ReportModal v-if="reportAccount" :account="reportAccount" :status="reportStatus" @close="closeReportDialog()" />
|
|
||||||
</ModalDialog>
|
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -36,10 +36,6 @@ export interface Props {
|
||||||
dialogLabelledBy?: string
|
dialogLabelledBy?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
inheritAttrs: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
zIndex: 100,
|
zIndex: 100,
|
||||||
closeByMask: true,
|
closeByMask: true,
|
||||||
|
@ -49,14 +45,20 @@ const props = withDefaults(defineProps<Props>(), {
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
/** v-model dialog visibility */
|
/** v-model dialog visibility */
|
||||||
(event: 'close'): void
|
(event: 'close',): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const visible = defineModel<boolean>({ required: true })
|
const { modelValue: visible } = defineModel<{
|
||||||
|
/** v-model dislog visibility */
|
||||||
|
modelValue: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
inheritAttrs: false,
|
||||||
|
})
|
||||||
|
|
||||||
const deactivated = useDeactivated()
|
const deactivated = useDeactivated()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const userSettings = useUserSettings()
|
|
||||||
|
|
||||||
/** scrollable HTML element */
|
/** scrollable HTML element */
|
||||||
const elDialogMain = ref<HTMLDivElement>()
|
const elDialogMain = ref<HTMLDivElement>()
|
||||||
|
@ -78,8 +80,6 @@ defineExpose({
|
||||||
|
|
||||||
/** close the dialog */
|
/** close the dialog */
|
||||||
function close() {
|
function close() {
|
||||||
if (!visible.value)
|
|
||||||
return
|
|
||||||
visible.value = false
|
visible.value = false
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
|
@ -119,11 +119,9 @@ const isVShow = computed(() => {
|
||||||
: true
|
: true
|
||||||
})
|
})
|
||||||
|
|
||||||
function bindTypeToAny($attrs: any) {
|
const bindTypeToAny = ($attrs: any) => $attrs as any
|
||||||
return $attrs as any
|
|
||||||
}
|
|
||||||
|
|
||||||
function trapFocusDialog() {
|
const trapFocusDialog = () => {
|
||||||
if (isVShow.value)
|
if (isVShow.value)
|
||||||
nextTick().then(() => activate())
|
nextTick().then(() => activate())
|
||||||
}
|
}
|
||||||
|
@ -157,13 +155,7 @@ useEventListener('keydown', (e: KeyboardEvent) => {
|
||||||
<!-- corresponding to issue: #106, so please don't remove it. -->
|
<!-- corresponding to issue: #106, so please don't remove it. -->
|
||||||
|
|
||||||
<!-- Mask layer: blur -->
|
<!-- Mask layer: blur -->
|
||||||
<div
|
<div class="dialog-mask" absolute inset-0 z-0 bg-transparent opacity-100 backdrop-filter backdrop-blur-sm touch-none />
|
||||||
class="dialog-mask"
|
|
||||||
:class="{
|
|
||||||
'backdrop-blur-sm': !getPreferences(userSettings, 'optimizeForLowPerformanceDevice'),
|
|
||||||
}"
|
|
||||||
absolute inset-0 z-0 bg-transparent opacity-100 backdrop-filter touch-none
|
|
||||||
/>
|
|
||||||
<!-- Mask layer: dimming -->
|
<!-- Mask layer: dimming -->
|
||||||
<div class="dialog-mask" absolute inset-0 z-0 bg-black opacity-48 touch-none h="[calc(100%+0.5px)]" @click="clickMask" />
|
<div class="dialog-mask" absolute inset-0 z-0 bg-black opacity-48 touch-none h="[calc(100%+0.5px)]" @click="clickMask" />
|
||||||
<!-- Dialog container -->
|
<!-- Dialog container -->
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import type { ErrorDialogData } from '~/types'
|
|
||||||
|
|
||||||
defineProps<ErrorDialogData>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div flex="~ col" gap-6>
|
|
||||||
<div font-bold text-lg text-center>
|
|
||||||
{{ title }}
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
flex="~ col"
|
|
||||||
gap-1 text-sm
|
|
||||||
pt-1 ps-2 pe-1 pb-2
|
|
||||||
text-red-600 dark:text-red-400
|
|
||||||
border="~ base rounded red-600 dark:red-400"
|
|
||||||
>
|
|
||||||
<ol ps-2 sm:ps-1>
|
|
||||||
<li v-for="(message, i) in messages" :key="i" flex="~ col sm:row" gap-y-1 sm:gap-x-2>
|
|
||||||
{{ message }}
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
<div flex justify-end gap-2>
|
|
||||||
<button btn-text @click="closeErrorDialog()">
|
|
||||||
{{ close }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -37,7 +37,7 @@ onUnmounted(() => locked.value = false)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div relative h-full w-full flex pt-12 @click="onClick">
|
<div relative h-full w-full flex pt-12 w-100vh @click="onClick">
|
||||||
<button
|
<button
|
||||||
v-if="hasNext" pointer-events-auto btn-action-icon bg="black/20" :aria-label="$t('action.previous')"
|
v-if="hasNext" pointer-events-auto btn-action-icon bg="black/20" :aria-label="$t('action.previous')"
|
||||||
hover:bg="black/40" dark:bg="white/30" dark-hover:bg="white/20" absolute top="1/2" right-1 z5
|
hover:bg="black/40" dark:bg="white/30" dark-hover:bg="white/20" absolute top="1/2" right-1 z5
|
||||||
|
@ -53,19 +53,21 @@ onUnmounted(() => locked.value = false)
|
||||||
<div i-ri:arrow-left-s-line text-white />
|
<div i-ri:arrow-left-s-line text-white />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div flex="~ col center" h-full w-full>
|
<div flex flex-row items-center mxa>
|
||||||
<ModalMediaPreviewCarousel v-model="index" :media="mediaPreviewList" @close="emit('close')" />
|
<div flex="~ col center" max-h-full max-w-full>
|
||||||
|
<ModalMediaPreviewCarousel v-model="index" :media="mediaPreviewList" @close="emit('close')" />
|
||||||
|
|
||||||
<div bg="black/30" dark:bg="white/10" mb-6 mt-4 text-white rounded-full flex="~ center shrink-0" overflow-hidden>
|
<div bg="black/30" dark:bg="white/10" ms-4 mb-6 mt-4 text-white rounded-full flex="~ center shrink-0" overflow-hidden>
|
||||||
<div v-if="mediaPreviewList.length > 1" p="y-1 x-3" rounded-r-0 shrink-0>
|
<div v-if="mediaPreviewList.length > 1" p="y-1 x-3" rounded-r-0 shrink-0>
|
||||||
{{ index + 1 }} / {{ mediaPreviewList.length }}
|
{{ index + 1 }} / {{ mediaPreviewList.length }}
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
v-if="current.description" bg="dark/30" dark:bg="white/10" p="y-1 x-3" rounded-ie-full line-clamp-1
|
||||||
|
ws-pre-wrap break-all :title="current.description" w-full
|
||||||
|
>
|
||||||
|
{{ current.description }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<p
|
|
||||||
v-if="current.description" bg="dark/30" dark:bg="white/10" p="y-1 x-3" rounded-ie-full line-clamp-1
|
|
||||||
ws-pre-wrap break-all :title="current.description" w-full
|
|
||||||
>
|
|
||||||
{{ current.description }}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,285 +1,70 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Vector2 } from '@vueuse/gesture'
|
import { SwipeDirection } from '@vueuse/core'
|
||||||
import { useGesture } from '@vueuse/gesture'
|
|
||||||
import { useReducedMotion } from '@vueuse/motion'
|
import { useReducedMotion } from '@vueuse/motion'
|
||||||
import type { mastodon } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { media = [] } = defineProps<{
|
const { media = [], threshold = 20 } = defineProps<{
|
||||||
media?: mastodon.v1.MediaAttachment[]
|
media?: mastodon.v1.MediaAttachment[]
|
||||||
|
threshold?: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'close'): void
|
(event: 'close'): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const modelValue = defineModel<number>({ required: true })
|
const { modelValue } = defineModel<{
|
||||||
|
modelValue: number
|
||||||
|
}>()
|
||||||
|
|
||||||
const slideGap = 20
|
const target = ref()
|
||||||
const doubleTapThreshold = 250
|
|
||||||
|
|
||||||
const view = ref()
|
const animateTimeout = useTimeout(10)
|
||||||
const slider = ref()
|
const reduceMotion = useReducedMotion()
|
||||||
const slide = ref()
|
|
||||||
const image = ref()
|
|
||||||
|
|
||||||
const reduceMotion = import.meta.server ? ref(false) : useReducedMotion()
|
const canAnimate = computed(() => !reduceMotion.value && animateTimeout.value)
|
||||||
const isInitialScrollDone = useTimeout(350)
|
|
||||||
const canAnimate = computed(() => isInitialScrollDone.value && !reduceMotion.value)
|
|
||||||
|
|
||||||
const scale = ref(1)
|
const { width, height } = useElementSize(target)
|
||||||
const x = ref(0)
|
const { isSwiping, lengthX, lengthY, direction } = useSwipe(target, {
|
||||||
const y = ref(0)
|
threshold: 5,
|
||||||
|
passive: false,
|
||||||
const isDragging = ref(false)
|
onSwipeEnd(e, direction) {
|
||||||
const isPinching = ref(false)
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||||
|
if (direction === SwipeDirection.RIGHT && Math.abs(distanceX.value) > threshold)
|
||||||
const maxZoomOut = ref(1)
|
|
||||||
const isZoomedIn = computed(() => scale.value > 1)
|
|
||||||
|
|
||||||
const enableAutoplay = usePreferences('enableAutoplay')
|
|
||||||
|
|
||||||
function goToFocusedSlide() {
|
|
||||||
scale.value = 1
|
|
||||||
x.value = slide.value[modelValue.value].offsetLeft * scale.value
|
|
||||||
y.value = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
const slideGapAsScale = slideGap / view.value.clientWidth
|
|
||||||
maxZoomOut.value = 1 - slideGapAsScale
|
|
||||||
|
|
||||||
goToFocusedSlide()
|
|
||||||
})
|
|
||||||
watch(modelValue, goToFocusedSlide)
|
|
||||||
|
|
||||||
let lastOrigin = [0, 0]
|
|
||||||
let initialScale = 0
|
|
||||||
useGesture({
|
|
||||||
onPinch({ first, initial: [initialDistance], movement: [deltaDistance], da: [distance], origin, touches }) {
|
|
||||||
isPinching.value = true
|
|
||||||
|
|
||||||
if (first) {
|
|
||||||
initialScale = scale.value
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (touches === 0)
|
|
||||||
handleMouseWheelZoom(initialScale, deltaDistance, origin)
|
|
||||||
else
|
|
||||||
handlePinchZoom(initialScale, initialDistance, distance, origin)
|
|
||||||
}
|
|
||||||
|
|
||||||
lastOrigin = origin
|
|
||||||
},
|
|
||||||
onPinchEnd() {
|
|
||||||
isPinching.value = false
|
|
||||||
isDragging.value = false
|
|
||||||
|
|
||||||
if (!isZoomedIn.value)
|
|
||||||
goToFocusedSlide()
|
|
||||||
},
|
|
||||||
onDrag({ movement, delta, pinching, tap, last, swipe, event, xy }) {
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
if (pinching)
|
|
||||||
return
|
|
||||||
|
|
||||||
if (last)
|
|
||||||
handleLastDrag(tap, swipe, movement, xy)
|
|
||||||
else
|
|
||||||
handleDrag(delta, movement)
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
domTarget: view,
|
|
||||||
eventOptions: {
|
|
||||||
passive: false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const shiftRestrictions = computed(() => {
|
|
||||||
const focusedImage = image.value[modelValue.value]
|
|
||||||
const focusedSlide = slide.value[modelValue.value]
|
|
||||||
|
|
||||||
const scaledImageWidth = focusedImage.offsetWidth * scale.value
|
|
||||||
const scaledHorizontalOverflow = scaledImageWidth / 2 - view.value.clientWidth / 2 + slideGap
|
|
||||||
const horizontalOverflow = Math.max(0, scaledHorizontalOverflow / scale.value)
|
|
||||||
|
|
||||||
const scaledImageHeight = focusedImage.offsetHeight * scale.value
|
|
||||||
const scaledVerticalOverflow = scaledImageHeight / 2 - view.value.clientHeight / 2 + slideGap
|
|
||||||
const verticalOverflow = Math.max(0, scaledVerticalOverflow / scale.value)
|
|
||||||
|
|
||||||
return {
|
|
||||||
left: focusedSlide.offsetLeft - horizontalOverflow,
|
|
||||||
right: focusedSlide.offsetLeft + horizontalOverflow,
|
|
||||||
top: focusedSlide.offsetTop - verticalOverflow,
|
|
||||||
bottom: focusedSlide.offsetTop + verticalOverflow,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function handlePinchZoom(initialScale: number, initialDistance: number, distance: number, [originX, originY]: Vector2) {
|
|
||||||
scale.value = initialScale * (distance / initialDistance)
|
|
||||||
scale.value = Math.max(maxZoomOut.value, scale.value)
|
|
||||||
|
|
||||||
const deltaCenterX = originX - lastOrigin[0]
|
|
||||||
const deltaCenterY = originY - lastOrigin[1]
|
|
||||||
|
|
||||||
handleZoomDrag([deltaCenterX, deltaCenterY])
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleMouseWheelZoom(initialScale: number, deltaDistance: number, [originX, originY]: Vector2) {
|
|
||||||
scale.value = initialScale + (deltaDistance / 1000)
|
|
||||||
scale.value = Math.max(maxZoomOut.value, scale.value)
|
|
||||||
|
|
||||||
const deltaCenterX = lastOrigin[0] - originX
|
|
||||||
const deltaCenterY = lastOrigin[1] - originY
|
|
||||||
|
|
||||||
handleZoomDrag([deltaCenterX, deltaCenterY])
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleLastDrag(tap: boolean, swipe: Vector2, movement: Vector2, position: Vector2) {
|
|
||||||
isDragging.value = false
|
|
||||||
|
|
||||||
if (tap)
|
|
||||||
handleTap(position)
|
|
||||||
else if (swipe[0] || swipe[1])
|
|
||||||
handleSwipe(swipe, movement)
|
|
||||||
else if (!isZoomedIn.value)
|
|
||||||
slideToClosestSlide()
|
|
||||||
}
|
|
||||||
|
|
||||||
let lastTapAt = 0
|
|
||||||
function handleTap([positionX, positionY]: Vector2) {
|
|
||||||
const now = Date.now()
|
|
||||||
const isDoubleTap = now - lastTapAt < doubleTapThreshold
|
|
||||||
lastTapAt = now
|
|
||||||
|
|
||||||
if (!isDoubleTap)
|
|
||||||
return
|
|
||||||
|
|
||||||
if (isZoomedIn.value) {
|
|
||||||
goToFocusedSlide()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const focusedSlideBounding = slide.value[modelValue.value].getBoundingClientRect()
|
|
||||||
const slideCenterX = focusedSlideBounding.left + focusedSlideBounding.width / 2
|
|
||||||
const slideCenterY = focusedSlideBounding.top + focusedSlideBounding.height / 2
|
|
||||||
|
|
||||||
scale.value = 3
|
|
||||||
x.value += positionX - slideCenterX
|
|
||||||
y.value += positionY - slideCenterY
|
|
||||||
restrictShiftToInsideSlide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSwipe([horiz, vert]: Vector2, [movementX, movementY]: Vector2) {
|
|
||||||
if (isZoomedIn.value || isPinching.value)
|
|
||||||
return
|
|
||||||
|
|
||||||
const isHorizontalDrag = Math.abs(movementX) >= Math.abs(movementY)
|
|
||||||
|
|
||||||
if (isHorizontalDrag) {
|
|
||||||
if (horiz === 1) // left
|
|
||||||
modelValue.value = Math.max(0, modelValue.value - 1)
|
modelValue.value = Math.max(0, modelValue.value - 1)
|
||||||
if (horiz === -1) // right
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||||
|
if (direction === SwipeDirection.LEFT && Math.abs(distanceX.value) > threshold)
|
||||||
modelValue.value = Math.min(media.length - 1, modelValue.value + 1)
|
modelValue.value = Math.min(media.length - 1, modelValue.value + 1)
|
||||||
}
|
|
||||||
else if (vert === 1 || vert === -1) {
|
|
||||||
emit('close')
|
|
||||||
}
|
|
||||||
|
|
||||||
goToFocusedSlide()
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||||
}
|
if (direction === SwipeDirection.UP && Math.abs(distanceY.value) > threshold)
|
||||||
|
emit('close')
|
||||||
function slideToClosestSlide() {
|
},
|
||||||
const startOfFocusedSlide = slide.value[modelValue.value].offsetLeft * scale.value
|
|
||||||
const slideWidth = slide.value[modelValue.value].offsetWidth * scale.value
|
|
||||||
|
|
||||||
if (x.value > startOfFocusedSlide + slideWidth / 2)
|
|
||||||
modelValue.value = Math.min(media.length - 1, modelValue.value + 1)
|
|
||||||
else if (x.value < startOfFocusedSlide - slideWidth / 2)
|
|
||||||
modelValue.value = Math.max(0, modelValue.value - 1)
|
|
||||||
|
|
||||||
goToFocusedSlide()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDrag(delta: Vector2, movement: Vector2) {
|
|
||||||
isDragging.value = true
|
|
||||||
|
|
||||||
if (isZoomedIn.value)
|
|
||||||
handleZoomDrag(delta)
|
|
||||||
else
|
|
||||||
handleSlideDrag(movement)
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleZoomDrag([deltaX, deltaY]: Vector2) {
|
|
||||||
x.value -= deltaX / scale.value
|
|
||||||
y.value -= deltaY / scale.value
|
|
||||||
|
|
||||||
restrictShiftToInsideSlide()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSlideDrag([movementX, movementY]: Vector2) {
|
|
||||||
goToFocusedSlide()
|
|
||||||
|
|
||||||
if (Math.abs(movementY) > Math.abs(movementX)) // vertical movement is more than horizontal
|
|
||||||
y.value -= movementY / scale.value
|
|
||||||
else
|
|
||||||
x.value -= movementX / scale.value
|
|
||||||
|
|
||||||
if (media.length === 1)
|
|
||||||
x.value = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function restrictShiftToInsideSlide() {
|
|
||||||
x.value = Math.min(shiftRestrictions.value.right, Math.max(shiftRestrictions.value.left, x.value))
|
|
||||||
y.value = Math.min(shiftRestrictions.value.bottom, Math.max(shiftRestrictions.value.top, y.value))
|
|
||||||
}
|
|
||||||
|
|
||||||
const sliderStyle = computed(() => {
|
|
||||||
const style = {
|
|
||||||
transform: `scale(${scale.value}) translate(${-x.value}px, ${-y.value}px)`,
|
|
||||||
transition: 'none',
|
|
||||||
gap: `${slideGap}px`,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canAnimate.value && !isDragging.value && !isPinching.value)
|
|
||||||
style.transition = 'all 0.3s ease'
|
|
||||||
|
|
||||||
return style
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const imageStyle = computed(() => ({
|
const distanceX = computed(() => {
|
||||||
cursor: isDragging.value ? 'grabbing' : 'grab',
|
if (width.value === 0)
|
||||||
}))
|
return 0
|
||||||
|
|
||||||
|
if (!isSwiping.value || (direction.value !== SwipeDirection.LEFT && direction.value !== SwipeDirection.RIGHT))
|
||||||
|
return modelValue.value * 100 * -1
|
||||||
|
|
||||||
|
return (lengthX.value / width.value) * 100 * -1 + (modelValue.value * 100) * -1
|
||||||
|
})
|
||||||
|
|
||||||
|
const distanceY = computed(() => {
|
||||||
|
if (height.value === 0 || !isSwiping.value || direction.value !== SwipeDirection.UP)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
return (lengthY.value / height.value) * 100 * -1
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="view" flex flex-row h-full w-full overflow-hidden>
|
<div ref="target" flex flex-row max-h-full max-w-full overflow-hidden>
|
||||||
<div ref="slider" :style="sliderStyle" w-full h-full flex items-center>
|
<div flex :style="{ transform: `translateX(${distanceX}%) translateY(${distanceY}%)`, transition: isSwiping ? 'none' : canAnimate ? 'all 0.5s ease' : 'none' }">
|
||||||
<div
|
<div v-for="item in media" :key="item.id" p4 select-none w-full flex-shrink-0 flex flex-col place-items-center>
|
||||||
v-for="item in media"
|
<img max-h-full max-w-full :draggable="false" select-none :src="item.url || item.previewUrl" :alt="item.description || ''">
|
||||||
:key="item.id"
|
|
||||||
ref="slide"
|
|
||||||
flex-shrink-0
|
|
||||||
w-full
|
|
||||||
h-full
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
>
|
|
||||||
<component
|
|
||||||
:is="item.type === 'gifv' ? 'video' : 'img'"
|
|
||||||
ref="image"
|
|
||||||
:autoplay="enableAutoplay"
|
|
||||||
controls
|
|
||||||
loop
|
|
||||||
select-none
|
|
||||||
max-w-full
|
|
||||||
max-h-full
|
|
||||||
:style="imageStyle"
|
|
||||||
:draggable="false"
|
|
||||||
:src="item.url || item.previewUrl"
|
|
||||||
:alt="item.description || ''"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// only one icon can be lit up at the same time
|
// only one icon can be lit up at the same time
|
||||||
import { STORAGE_KEY_LAST_ACCESSED_EXPLORE_ROUTE, STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE } from '~/constants'
|
|
||||||
|
|
||||||
const moreMenuVisible = ref(false)
|
const moreMenuVisible = ref(false)
|
||||||
|
|
||||||
const { notifications } = useNotifications()
|
|
||||||
const lastAccessedNotificationRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE, '')
|
|
||||||
const lastAccessedExploreRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_EXPLORE_ROUTE, '')
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -17,44 +11,42 @@ const lastAccessedExploreRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_EXPLO
|
||||||
>
|
>
|
||||||
<!-- These weird styles above are used for scroll locking, don't change it unless you know exactly what you're doing. -->
|
<!-- These weird styles above are used for scroll locking, don't change it unless you know exactly what you're doing. -->
|
||||||
<template v-if="currentUser">
|
<template v-if="currentUser">
|
||||||
<NuxtLink to="/home" :aria-label="$t('nav.home')" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
|
<NuxtLink to="/home" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
|
||||||
<div i-ri:home-5-line />
|
<div i-ri:home-5-line />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink to="/search" :aria-label="$t('nav.search')" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
|
<NuxtLink to="/search" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
|
||||||
<div i-ri:search-line />
|
<div i-ri:search-line />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink :to="`/notifications/${lastAccessedNotificationRoute}`" :aria-label="$t('nav.notifications')" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
|
<NuxtLink to="/notifications" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
|
||||||
<div flex relative>
|
<div i-ri:notification-4-line />
|
||||||
<div class="i-ri:notification-4-line" text-xl />
|
|
||||||
<div v-if="notifications" class="top-[-0.3rem] right-[-0.3rem]" absolute font-bold rounded-full h-4 w-4 text-xs bg-primary text-inverted flex items-center justify-center>
|
|
||||||
{{ notifications < 10 ? notifications : '•' }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink to="/conversations" :aria-label="$t('nav.conversations')" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
|
<NuxtLink to="/conversations" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
|
||||||
<div i-ri:at-line />
|
<div i-ri:at-line />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<NuxtLink :to="`/${currentServer}/explore/${lastAccessedExploreRoute}`" :aria-label="$t('nav.explore')" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
|
<NuxtLink :to="`/${currentServer}/explore`" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
|
||||||
<div i-ri:compass-3-line />
|
<div i-ri:hashtag />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink group :to="`/${currentServer}/public/local`" :aria-label="$t('nav.local')" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
|
<NuxtLink to="/search" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
|
||||||
|
<div i-ri:search-line />
|
||||||
|
</NuxtLink>
|
||||||
|
<NuxtLink group :to="`/${currentServer}/public/local`" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
|
||||||
<div i-ri:group-2-line />
|
<div i-ri:group-2-line />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink :to="`/${currentServer}/public`" :aria-label="$t('nav.federated')" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
|
<NuxtLink :to="`/${currentServer}/public`" :active-class="moreMenuVisible ? '' : 'text-primary'" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
|
||||||
<div i-ri:earth-line />
|
<div i-ri:earth-line />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
<NavBottomMoreMenu v-slot="{ toggleVisible, show }" v-model="moreMenuVisible" flex flex-row items-center place-content-center h-full flex-1 cursor-pointer>
|
<NavBottomMoreMenu v-slot="{ toggleVisible, show }" v-model="moreMenuVisible" flex flex-row items-center place-content-center h-full flex-1 cursor-pointer>
|
||||||
<button
|
<label
|
||||||
flex items-center place-content-center h-full flex-1 class="select-none"
|
flex items-center place-content-center h-full flex-1 class="select-none"
|
||||||
:class="show ? '!text-primary' : ''"
|
:class="show ? '!text-primary' : ''"
|
||||||
aria-label="More menu"
|
|
||||||
@click="toggleVisible"
|
|
||||||
>
|
>
|
||||||
<span :class="show ? 'i-ri:close-fill' : 'i-ri:more-fill'" />
|
<input type="checkbox" z="-1" absolute inset-0 opacity-0 @click="toggleVisible">
|
||||||
</button>
|
<span v-show="show" i-ri:close-fill />
|
||||||
|
<span v-show="!show" i-ri:more-fill />
|
||||||
|
</label>
|
||||||
</NavBottomMoreMenu>
|
</NavBottomMoreMenu>
|
||||||
</nav>
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,27 +1,22 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { invoke } from '@vueuse/core'
|
let { modelValue } = $defineModel<{
|
||||||
|
modelValue: boolean
|
||||||
const modelValue = defineModel<boolean>({ required: true })
|
}>()
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
|
|
||||||
const userSettings = useUserSettings()
|
const userSettings = useUserSettings()
|
||||||
|
|
||||||
const drawerEl = ref<HTMLDivElement>()
|
|
||||||
|
|
||||||
function toggleVisible() {
|
function toggleVisible() {
|
||||||
modelValue.value = !modelValue.value
|
modelValue = !modelValue
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttonEl = ref<HTMLDivElement>()
|
const buttonEl = ref<HTMLDivElement>()
|
||||||
/**
|
/** Close the drop-down menu if the mouse click is not on the drop-down menu button when the drop-down menu is opened */
|
||||||
* Close the drop-down menu if the mouse click is not on the drop-down menu button when the drop-down menu is opened
|
|
||||||
* @param mouse
|
|
||||||
*/
|
|
||||||
function clickEvent(mouse: MouseEvent) {
|
function clickEvent(mouse: MouseEvent) {
|
||||||
if (mouse.target && !buttonEl.value?.children[0].contains(mouse.target as any)) {
|
if (mouse.target && !buttonEl.value?.children[0].contains(mouse.target as any)) {
|
||||||
if (modelValue.value) {
|
if (modelValue) {
|
||||||
document.removeEventListener('click', clickEvent)
|
document.removeEventListener('click', clickEvent)
|
||||||
modelValue.value = false
|
modelValue = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +25,7 @@ function toggleDark() {
|
||||||
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
|
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(modelValue, (val) => {
|
watch($$(modelValue), (val) => {
|
||||||
if (val && typeof document !== 'undefined')
|
if (val && typeof document !== 'undefined')
|
||||||
document.addEventListener('click', clickEvent)
|
document.addEventListener('click', clickEvent)
|
||||||
})
|
})
|
||||||
|
@ -38,80 +33,6 @@ watch(modelValue, (val) => {
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
document.removeEventListener('click', clickEvent)
|
document.removeEventListener('click', clickEvent)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Pull down to close
|
|
||||||
const { dragging, dragDistance } = invoke(() => {
|
|
||||||
const triggerDistance = 120
|
|
||||||
|
|
||||||
let scrollTop = 0
|
|
||||||
let beforeTouchPointY = 0
|
|
||||||
|
|
||||||
const dragDistance = ref(0)
|
|
||||||
const dragging = ref(false)
|
|
||||||
|
|
||||||
useEventListener(drawerEl, 'scroll', (e: Event) => {
|
|
||||||
scrollTop = (e.target as HTMLDivElement).scrollTop
|
|
||||||
|
|
||||||
// Prevent the page from scrolling when the drawer is being dragged.
|
|
||||||
if (dragDistance.value > 0)
|
|
||||||
(e.target as HTMLDivElement).scrollTop = 0
|
|
||||||
}, { passive: true })
|
|
||||||
|
|
||||||
useEventListener(drawerEl, 'touchstart', (e: TouchEvent) => {
|
|
||||||
if (!modelValue.value)
|
|
||||||
return
|
|
||||||
|
|
||||||
beforeTouchPointY = e.touches[0].pageY
|
|
||||||
dragDistance.value = 0
|
|
||||||
}, { passive: true })
|
|
||||||
|
|
||||||
useEventListener(drawerEl, 'touchmove', (e: TouchEvent) => {
|
|
||||||
if (!modelValue.value)
|
|
||||||
return
|
|
||||||
|
|
||||||
// Do not move the entire drawer when its contents are not scrolled to the top.
|
|
||||||
if (scrollTop > 0 && dragDistance.value <= 0) {
|
|
||||||
dragging.value = false
|
|
||||||
beforeTouchPointY = e.touches[0].pageY
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const { pageY } = e.touches[0]
|
|
||||||
|
|
||||||
// Calculate the drag distance.
|
|
||||||
dragDistance.value += pageY - beforeTouchPointY
|
|
||||||
if (dragDistance.value < 0)
|
|
||||||
dragDistance.value = 0
|
|
||||||
beforeTouchPointY = pageY
|
|
||||||
|
|
||||||
// Marked as dragging.
|
|
||||||
if (dragDistance.value > 1)
|
|
||||||
dragging.value = true
|
|
||||||
|
|
||||||
// Prevent the page from scrolling when the drawer is being dragged.
|
|
||||||
if (dragDistance.value > 0) {
|
|
||||||
if (e?.cancelable && e?.preventDefault)
|
|
||||||
e.preventDefault()
|
|
||||||
e?.stopPropagation()
|
|
||||||
}
|
|
||||||
}, { passive: true })
|
|
||||||
|
|
||||||
useEventListener(drawerEl, 'touchend', () => {
|
|
||||||
if (!modelValue.value)
|
|
||||||
return
|
|
||||||
|
|
||||||
if (dragDistance.value >= triggerDistance)
|
|
||||||
modelValue.value = false
|
|
||||||
|
|
||||||
dragging.value = false
|
|
||||||
// code
|
|
||||||
}, { passive: true })
|
|
||||||
|
|
||||||
return {
|
|
||||||
dragDistance,
|
|
||||||
dragging,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -120,12 +41,12 @@ const { dragging, dragDistance } = invoke(() => {
|
||||||
|
|
||||||
<!-- Drawer -->
|
<!-- Drawer -->
|
||||||
<Transition
|
<Transition
|
||||||
enter-active-class="transition duration-250 ease-out"
|
enter-active-class="transition duration-250 ease-out children:(transition duration-250 ease-out)"
|
||||||
enter-from-class="opacity-0 children:(translate-y-full)"
|
enter-from-class="opacity-0 children:(transform translate-y-full)"
|
||||||
enter-to-class="opacity-100 children:(translate-y-0)"
|
enter-to-class="opacity-100 children:(transform translate-y-0)"
|
||||||
leave-active-class="transition duration-250 ease-in"
|
leave-active-class="transition duration-250 ease-in children:(transition duration-250 ease-in)"
|
||||||
leave-from-class="opacity-100 children:(translate-y-0)"
|
leave-from-class="opacity-100 children:(transform translate-y-0)"
|
||||||
leave-to-class="opacity-0 children:(translate-y-full)"
|
leave-to-class="opacity-0 children:(transform translate-y-full)"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-show="modelValue"
|
v-show="modelValue"
|
||||||
|
@ -137,19 +58,10 @@ const { dragging, dragDistance } = invoke(() => {
|
||||||
<!-- corresponding to issue: #106, so please don't remove it. -->
|
<!-- corresponding to issue: #106, so please don't remove it. -->
|
||||||
<div absolute inset-0 opacity-0 h="[calc(100vh+0.5px)]" />
|
<div absolute inset-0 opacity-0 h="[calc(100vh+0.5px)]" />
|
||||||
<div
|
<div
|
||||||
ref="drawerEl"
|
|
||||||
:style="{
|
|
||||||
transform: dragging ? `translateY(${dragDistance}px)` : '',
|
|
||||||
}"
|
|
||||||
:class="{
|
|
||||||
'duration-0': dragging,
|
|
||||||
'duration-250': !dragging,
|
|
||||||
'backdrop-blur-md': !getPreferences(userSettings, 'optimizeForLowPerformanceDevice'),
|
|
||||||
}"
|
|
||||||
transition="transform ease-in"
|
|
||||||
flex-1 min-w-48 py-6 mb="-1px"
|
flex-1 min-w-48 py-6 mb="-1px"
|
||||||
of-y-auto scrollbar-hide overscroll-none max-h="[calc(100vh-200px)]"
|
of-y-auto scrollbar-hide overscroll-none max-h="[calc(100vh-200px)]"
|
||||||
rounded-t-lg bg="white/85 dark:neutral-900/85" backdrop-filter
|
rounded-t-lg bg="white/85 dark:neutral-900/85" backdrop-filter backdrop-blur-md
|
||||||
border-t-1 border-base
|
border-t-1 border-base
|
||||||
>
|
>
|
||||||
<!-- Nav -->
|
<!-- Nav -->
|
||||||
|
@ -181,9 +93,9 @@ const { dragging, dragDistance } = invoke(() => {
|
||||||
transition-colors duration-200 transform
|
transition-colors duration-200 transform
|
||||||
hover="bg-gray-100 dark:(bg-gray-700 text-white)"
|
hover="bg-gray-100 dark:(bg-gray-700 text-white)"
|
||||||
:aria-label="$t('nav.zen_mode')"
|
:aria-label="$t('nav.zen_mode')"
|
||||||
@click="togglePreferences('zenMode')"
|
@click="userSettings.zenMode = !userSettings.zenMode"
|
||||||
>
|
>
|
||||||
<span :class="getPreferences(userSettings, 'zenMode') ? 'i-ri:layout-right-2-line' : 'i-ri:layout-right-line'" class="flex-shrink-0 text-xl me-4 !align-middle" />
|
<span :class="userSettings.zenMode ? 'i-ri:layout-right-2-line' : 'i-ri:layout-right-line'" class="flex-shrink-0 text-xl me-4 !align-middle" />
|
||||||
{{ $t('nav.zen_mode') }}
|
{{ $t('nav.zen_mode') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const buildInfo = useBuildInfo()
|
const buildInfo = useAppConfig().buildInfo
|
||||||
const timeAgoOptions = useTimeAgoOptions()
|
const timeAgoOptions = useTimeAgoOptions()
|
||||||
const config = useRuntimeConfig()
|
|
||||||
const userSettings = useUserSettings()
|
const userSettings = useUserSettings()
|
||||||
|
|
||||||
const buildTimeDate = new Date(buildInfo.time)
|
const buildTimeDate = new Date(buildInfo.time)
|
||||||
|
@ -23,14 +23,11 @@ function toggleDark() {
|
||||||
<button
|
<button
|
||||||
flex
|
flex
|
||||||
text-lg
|
text-lg
|
||||||
:class="getPreferences(userSettings, 'zenMode') ? 'i-ri:layout-right-2-line' : 'i-ri:layout-right-line'"
|
:class="userSettings.zenMode ? 'i-ri:layout-right-2-line' : 'i-ri:layout-right-line'"
|
||||||
:aria-label="$t('nav.zen_mode')"
|
:aria-label="$t('nav.zen_mode')"
|
||||||
@click="togglePreferences('zenMode')"
|
@click="userSettings.zenMode = !userSettings.zenMode"
|
||||||
/>
|
/>
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
<CommonTooltip :content="$t('magic_keys.dialog_header')">
|
|
||||||
<button flex i-ri:keyboard-box-line dark-i-ri:keyboard-box-line text-lg :aria-label="$t('magic_keys.dialog_header')" @click="toggleKeyboardShortcuts" />
|
|
||||||
</CommonTooltip>
|
|
||||||
<CommonTooltip :content="$t('settings.about.sponsor_action')">
|
<CommonTooltip :content="$t('settings.about.sponsor_action')">
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
flex
|
flex
|
||||||
|
@ -68,7 +65,7 @@ function toggleDark() {
|
||||||
target="_blank"
|
target="_blank"
|
||||||
font-mono
|
font-mono
|
||||||
>
|
>
|
||||||
{{ buildInfo.shortCommit }}
|
{{ buildInfo.commit.slice(0, 7) }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
@ -76,9 +73,9 @@ function toggleDark() {
|
||||||
<NuxtLink cursor-pointer hover:underline to="/settings/about">
|
<NuxtLink cursor-pointer hover:underline to="/settings/about">
|
||||||
{{ $t('settings.about.label') }}
|
{{ $t('settings.about.label') }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<template v-if="config.public.privacyPolicyUrl">
|
<template v-if="$config.public.privacyPolicyUrl">
|
||||||
·
|
·
|
||||||
<NuxtLink cursor-pointer hover:underline :to="config.public.privacyPolicyUrl">
|
<NuxtLink cursor-pointer hover:underline :to="$config.public.privacyPolicyUrl">
|
||||||
{{ $t('nav.privacy') }}
|
{{ $t('nav.privacy') }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -3,44 +3,27 @@
|
||||||
xmlns="http://www.w3.org/2000/svg" w-full
|
xmlns="http://www.w3.org/2000/svg" w-full
|
||||||
aspect="1/1" sm:h-8 xl:h-10 sm:w-8 xl:w-10 viewBox="0 0 250 250" fill="none"
|
aspect="1/1" sm:h-8 xl:h-10 sm:w-8 xl:w-10 viewBox="0 0 250 250" fill="none"
|
||||||
>
|
>
|
||||||
<mask
|
<mask id="a" width="240" height="234" x="4" y="1" maskUnits="userSpaceOnUse" style="mask-type:alpha">
|
||||||
id="a"
|
|
||||||
width="240"
|
|
||||||
height="234"
|
|
||||||
x="4"
|
|
||||||
y="1"
|
|
||||||
maskUnits="userSpaceOnUse"
|
|
||||||
style="mask-type:alpha"
|
|
||||||
>
|
|
||||||
<path
|
<path
|
||||||
id="path19"
|
|
||||||
fill="#D9D9D9"
|
fill="#D9D9D9"
|
||||||
d="M244 123c0 64.617-38.383 112-103 112-64.617 0-103-30.883-103-95.5C38 111.194-8.729 36.236 8 16 29.46-9.959 88.689 6 125 6c64.617 0 119 52.383 119 117Z"
|
d="M244 123c0 64.617-38.383 112-103 112-64.617 0-103-30.883-103-95.5C38 111.194-8.729 36.236 8 16 29.46-9.959 88.689 6 125 6c64.617 0 119 52.383 119 117Z"
|
||||||
/>
|
/>
|
||||||
</mask>
|
</mask>
|
||||||
<g
|
<g mask="url(#a)">
|
||||||
id="g28"
|
|
||||||
mask="url(#a)"
|
|
||||||
transform="matrix(0.90923731,0,0,1.0049564,13.520015,-3.1040835)"
|
|
||||||
>
|
|
||||||
<path
|
<path
|
||||||
id="path22"
|
|
||||||
class="body"
|
class="body"
|
||||||
d="m 116.94,88.1 c -13.344,1.552 -20.436,-2.019 -24.706,10.71 0,0 14.336,21.655 52.54,21.112 -2.135,8.848 -1.144,15.368 -1.144,23.207 0,26.079 -20.589,48.821 -65.961,48.821 -23.03,0 -51.015,4.191 -72.367,15.911 -15.175,8.305 -27.048,20.336 -32.302,37.023 l 5.956,8.461 11.4,0.155 v 47.889 l -13.91,21.966 3.998,63.645 H -6.364 L -5.22,335.773 C 1.338,331.892 16.36,321.802 29.171,306.279 46.557,285.4 59.902,255.052 44.193,217.486 l 11.744,-5.045 c 12.887,30.814 8.388,57.514 -2.898,79.013 21.58,-0.698 40.11,-2.095 55.819,-4.734 l -3.584,-43.698 12.659,-1.087 L 129.98,387 h 13.116 l 2.212,-94.459 c 10.447,-4.502 34.239,-21.034 45.372,-78.47 1.372,-6.986 2.135,-12.885 2.516,-17.93 1.754,-12.806 2.745,-27.243 3.051,-43.698 l -18.683,-5.976 h 57.42 l 5.567,-12.807 c -5.414,0.233 -11.896,-2.639 -11.896,-2.639 l 1.297,-6.209 H 242 L 176.801,90.428 c -7.244,2.794 -14.87,6.442 -20.208,10.866 -4.27,-3.105 -19.063,-12.807 -39.653,-13.195 z"
|
d="M116.94 88.1c-13.344 1.552-20.436-2.019-24.706 10.71 0 0 14.336 21.655 52.54 21.112-2.135 8.848-1.144 15.368-1.144 23.207 0 26.079-20.589 48.821-65.961 48.821-23.03 0-51.015 4.191-72.367 15.911-15.175 8.305-27.048 20.336-32.302 37.023l5.956 8.461 11.4.155v47.889l-13.91 21.966L-19.556 387h13.192l1.144-51.227c6.558-3.881 21.58-13.971 34.391-29.494 17.386-20.879 30.731-51.227 15.022-88.793l11.744-5.045c12.887 30.814 8.388 57.514-2.898 79.013 21.58-.698 40.11-2.095 55.819-4.734l-3.584-43.698 12.659-1.087L129.98 387h13.116l2.212-94.459c10.447-4.502 34.239-21.034 45.372-78.47 1.372-6.986 2.135-12.885 2.516-17.93 1.754-12.806 2.745-27.243 3.051-43.698l-18.683-5.976h57.42l5.567-12.807c-5.414.233-11.896-2.639-11.896-2.639l1.297-6.209H242l-65.199-34.384c-7.244 2.794-14.87 6.442-20.208 10.866-4.27-3.105-19.063-12.807-39.653-13.195Z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
id="path24"
|
|
||||||
class="wood"
|
class="wood"
|
||||||
d="M 6.217,24.493 18.494,21 c 5.948,21.577 13.345,33.375 22.648,39.352 8.388,5.099 19.75,5.239 31.799,4.579 C 69.433,63.767 66.154,62.137 63.104,59.886 56.317,54.841 50.522,46.458 46.175,31.246 l 12.201,-3.649 c 3.279,11.488 7.092,18.085 12.201,21.888 5.11,3.726 11.286,4.657 18.606,5.433 13.726,1.553 30.884,2.174 52.312,12.264 2.898,1.086 5.872,2.483 8.769,4.036 -0.381,-0.776 -0.762,-1.553 -1.296,-2.406 -3.66,-5.822 -10.828,-11.953 -24.097,-16.92 l 4.27,-12.109 c 21.581,7.917 30.121,19.171 33.553,28.097 3.965,10.168 1.525,18.124 1.525,18.124 -3.05,1.009 -6.1,2.406 -9.608,3.492 -6.634,-4.579 -12.887,-8.033 -18.835,-10.75 C 113.814,70.442 92.31,76.108 73.246,77.893 58.91,79.213 45.794,78.591 34.432,71.295 23.222,64.155 13.385,50.495 6.217,24.493 Z"
|
d="M6.217 24.493 18.494 21c5.948 21.577 13.345 33.375 22.648 39.352 8.388 5.099 19.75 5.239 31.799 4.579-3.508-1.164-6.787-2.794-9.837-5.045-6.787-5.045-12.582-13.428-16.929-28.64l12.201-3.649c3.279 11.488 7.092 18.085 12.201 21.888 5.11 3.726 11.286 4.657 18.606 5.433 13.726 1.553 30.884 2.174 52.312 12.264 2.898 1.086 5.872 2.483 8.769 4.036-.381-.776-.762-1.553-1.296-2.406-3.66-5.822-10.828-11.953-24.097-16.92l4.27-12.109c21.581 7.917 30.121 19.171 33.553 28.097 3.965 10.168 1.525 18.124 1.525 18.124-3.05 1.009-6.1 2.406-9.608 3.492-6.634-4.579-12.887-8.033-18.835-10.75-21.962-8.304-43.466-2.638-62.53-.853-14.336 1.32-27.452.698-38.814-6.598-11.21-7.14-21.047-20.8-28.215-46.802Z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
id="path26"
|
|
||||||
class="wood"
|
class="wood"
|
||||||
d="M 90.098,45.294 C 87.582,39.55 86.057,32.487 86.743,23.794 l 12.659,0.932 c -0.763,10.555 2.897,17.696 7.015,22.353 -5.338,-0.931 -10.447,-1.04 -16.319,-1.785 z m 80.069,-1.32 8.312,-9.702 c 21.58,19.094 8.159,46.415 8.159,46.415 l -11.819,-1.32 c -0.382,-6.24 -1.144,-17.836 -6.635,-24.371 3.584,1.84 6.635,3.865 9.99,6.908 0,-5.666 -1.754,-12.341 -8.007,-17.93 z"
|
d="M90.098 45.294c-2.516-5.744-4.041-12.807-3.355-21.5l12.659.932c-.763 10.555 2.897 17.696 7.015 22.353-5.338-.931-10.447-1.04-16.319-1.785ZM170.167 43.974l8.312-9.702c21.58 19.094 8.159 46.415 8.159 46.415l-11.819-1.32c-.382-6.24-1.144-17.836-6.635-24.371 3.584 1.84 6.635 3.865 9.99 6.908 0-5.666-1.754-12.341-8.007-17.93Z"
|
||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { STORAGE_KEY_LAST_ACCESSED_EXPLORE_ROUTE, STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE } from '~/constants'
|
|
||||||
|
|
||||||
const { command } = defineProps<{
|
const { command } = defineProps<{
|
||||||
command?: boolean
|
command?: boolean
|
||||||
}>()
|
}>()
|
||||||
const { notifications } = useNotifications()
|
const { notifications } = useNotifications()
|
||||||
const useStarFavoriteIcon = usePreferences('useStarFavoriteIcon')
|
|
||||||
const lastAccessedNotificationRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE, '')
|
|
||||||
const lastAccessedExploreRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_EXPLORE_ROUTE, '')
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<nav sm:px3 flex="~ col gap2" shrink text-size-base leading-normal md:text-lg h-full mt-1 overflow-y-auto>
|
<nav sm:px3 flex="~ col gap2" shrink text-size-base leading-normal md:text-lg>
|
||||||
|
<div shrink hidden sm:block mt-4 />
|
||||||
|
<SearchWidget lg:ms-1 lg:me-5 hidden xl:block />
|
||||||
<NavSideItem :text="$t('nav.search')" to="/search" icon="i-ri:search-line" xl:hidden :command="command" />
|
<NavSideItem :text="$t('nav.search')" to="/search" icon="i-ri:search-line" xl:hidden :command="command" />
|
||||||
|
|
||||||
<div class="spacer" shrink xl:hidden />
|
<div shrink hidden sm:block mt-4 />
|
||||||
<NavSideItem :text="$t('nav.home')" to="/home" icon="i-ri:home-5-line" user-only :command="command" />
|
<NavSideItem :text="$t('nav.home')" to="/home" icon="i-ri:home-5-line" user-only :command="command" />
|
||||||
<NavSideItem :text="$t('nav.notifications')" :to="`/notifications/${lastAccessedNotificationRoute}`" icon="i-ri:notification-4-line" user-only :command="command">
|
<NavSideItem :text="$t('nav.notifications')" to="/notifications" icon="i-ri:notification-4-line" user-only :command="command">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<div flex relative>
|
<div flex relative>
|
||||||
<div class="i-ri:notification-4-line" text-xl />
|
<div class="i-ri:notification-4-line" text-xl />
|
||||||
|
@ -27,31 +24,17 @@ const lastAccessedExploreRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_EXPLO
|
||||||
</template>
|
</template>
|
||||||
</NavSideItem>
|
</NavSideItem>
|
||||||
<NavSideItem :text="$t('nav.conversations')" to="/conversations" icon="i-ri:at-line" user-only :command="command" />
|
<NavSideItem :text="$t('nav.conversations')" to="/conversations" icon="i-ri:at-line" user-only :command="command" />
|
||||||
<NavSideItem :text="$t('nav.favourites')" to="/favourites" :icon="useStarFavoriteIcon ? 'i-ri:star-line' : 'i-ri:heart-3-line'" user-only :command="command" />
|
<NavSideItem :text="$t('nav.favourites')" to="/favourites" icon="i-ri:heart-3-line" user-only :command="command" />
|
||||||
<NavSideItem :text="$t('nav.bookmarks')" to="/bookmarks" icon="i-ri:bookmark-line" user-only :command="command" />
|
<NavSideItem :text="$t('nav.bookmarks')" to="/bookmarks" icon="i-ri:bookmark-line" user-only :command="command" />
|
||||||
|
|
||||||
<div class="spacer" shrink hidden sm:block />
|
|
||||||
<NavSideItem :text="$t('action.compose')" to="/compose" icon="i-ri:quill-pen-line" user-only :command="command" />
|
<NavSideItem :text="$t('action.compose')" to="/compose" icon="i-ri:quill-pen-line" user-only :command="command" />
|
||||||
|
|
||||||
<div class="spacer" shrink hidden sm:block />
|
<div shrink hidden sm:block mt-4 />
|
||||||
<NavSideItem :text="$t('nav.explore')" :to="isHydrated ? `/${currentServer}/explore/${lastAccessedExploreRoute}` : `/explore/${lastAccessedExploreRoute}`" icon="i-ri:compass-3-line" :command="command" />
|
<NavSideItem :text="$t('nav.explore')" :to="isHydrated ? `/${currentServer}/explore` : '/explore'" icon="i-ri:hashtag" :command="command" />
|
||||||
<NavSideItem :text="$t('nav.local')" :to="isHydrated ? `/${currentServer}/public/local` : '/public/local'" icon="i-ri:group-2-line " :command="command" />
|
<NavSideItem :text="$t('nav.local')" :to="isHydrated ? `/${currentServer}/public/local` : '/public/local'" icon="i-ri:group-2-line " :command="command" />
|
||||||
<NavSideItem :text="$t('nav.federated')" :to="isHydrated ? `/${currentServer}/public` : '/public'" icon="i-ri:earth-line" :command="command" />
|
<NavSideItem :text="$t('nav.federated')" :to="isHydrated ? `/${currentServer}/public` : '/public'" icon="i-ri:earth-line" :command="command" />
|
||||||
<NavSideItem :text="$t('nav.lists')" :to="isHydrated ? `/${currentServer}/lists` : '/lists'" icon="i-ri:list-check" user-only :command="command" />
|
<NavSideItem :text="$t('nav.lists')" :to="`/${currentServer}/lists`" icon="i-ri:list-check" :command="command" />
|
||||||
<NavSideItem :text="$t('nav.hashtags')" to="/hashtags" icon="i-ri:hashtag" user-only :command="command" />
|
|
||||||
|
|
||||||
<div class="spacer" shrink hidden sm:block />
|
<div shrink hidden sm:block mt-4 />
|
||||||
<NavSideItem :text="$t('nav.settings')" to="/settings" icon="i-ri:settings-3-line" :command="command" />
|
<NavSideItem :text="$t('nav.settings')" to="/settings" icon="i-ri:settings-3-line" :command="command" />
|
||||||
</nav>
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.spacer {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
}
|
|
||||||
@media screen and ( max-height: 920px ) and ( min-width: 640px ) {
|
|
||||||
.spacer {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ const props = withDefaults(defineProps<{
|
||||||
})
|
})
|
||||||
|
|
||||||
defineSlots<{
|
defineSlots<{
|
||||||
icon: (props: object) => void
|
icon: {}
|
||||||
default: (props: object) => void
|
default: {}
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
@ -28,13 +28,13 @@ useCommand({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const activeClass = ref('text-primary')
|
let activeClass = $ref('text-primary')
|
||||||
onHydrated(async () => {
|
onHydrated(async () => {
|
||||||
// TODO: force NuxtLink to reevaluate, we now we are in this route though, so we should force it to active
|
// TODO: force NuxtLink to reevaluate, we now we are in this route though, so we should force it to active
|
||||||
// we don't have currentServer defined until later
|
// we don't have currentServer defined until later
|
||||||
activeClass.value = ''
|
activeClass = ''
|
||||||
await nextTick()
|
await nextTick()
|
||||||
activeClass.value = 'text-primary'
|
activeClass = 'text-primary'
|
||||||
})
|
})
|
||||||
|
|
||||||
// Optimize rendering for the common case of being logged in, only show visual feedback for disabled user-only items
|
// Optimize rendering for the common case of being logged in, only show visual feedback for disabled user-only items
|
||||||
|
@ -55,23 +55,12 @@ const noUserVisual = computed(() => isHydrated.value && props.userOnly && !curre
|
||||||
>
|
>
|
||||||
<CommonTooltip :disabled="!isMediumOrLargeScreen" :content="text" placement="right">
|
<CommonTooltip :disabled="!isMediumOrLargeScreen" :content="text" placement="right">
|
||||||
<div
|
<div
|
||||||
class="item"
|
|
||||||
flex items-center gap4
|
flex items-center gap4
|
||||||
|
w-fit rounded-3
|
||||||
|
px2 py2 mx3 sm:mxa
|
||||||
xl="ml0 mr5 px5 w-auto"
|
xl="ml0 mr5 px5 w-auto"
|
||||||
:class="isSmallScreen
|
transition-100
|
||||||
? `
|
group-hover="bg-active" group-focus-visible:ring="2 current"
|
||||||
w-full
|
|
||||||
px5 sm:mxa
|
|
||||||
transition-colors duration-200 transform
|
|
||||||
hover-bg-gray-100 hover-dark:(bg-gray-700 text-white)
|
|
||||||
` : `
|
|
||||||
w-fit rounded-3
|
|
||||||
px2 mx3 sm:mxa
|
|
||||||
transition-100
|
|
||||||
elk-group-hover-bg-active
|
|
||||||
group-focus-visible:ring-2
|
|
||||||
group-focus-visible:ring-current
|
|
||||||
`"
|
|
||||||
>
|
>
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<div :class="icon" text-xl />
|
<div :class="icon" text-xl />
|
||||||
|
@ -83,28 +72,3 @@ const noUserVisual = computed(() => isHydrated.value && props.userOnly && !curre
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.item {
|
|
||||||
padding-top: 0.5rem;
|
|
||||||
padding-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
@media screen and ( max-height: 820px ) and ( min-width: 1280px ) {
|
|
||||||
.item {
|
|
||||||
padding-top: 0.25rem;
|
|
||||||
padding-bottom: 0.25rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media screen and ( max-height: 780px ) and ( min-width: 640px ) {
|
|
||||||
.item {
|
|
||||||
padding-top: 0.35rem;
|
|
||||||
padding-bottom: 0.35rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media screen and ( max-height: 780px ) and ( min-width: 1280px ) {
|
|
||||||
.item {
|
|
||||||
padding-top: 0.05rem;
|
|
||||||
padding-bottom: 0.05rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -2,13 +2,6 @@
|
||||||
const { env } = useBuildInfo()
|
const { env } = useBuildInfo()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const back = ref<any>('')
|
const back = ref<any>('')
|
||||||
|
|
||||||
const nuxtApp = useNuxtApp()
|
|
||||||
|
|
||||||
function onClickLogo() {
|
|
||||||
nuxtApp.hooks.callHook('elk-logo:click')
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
back.value = router.options.history.state.back
|
back.value = router.options.history.state.back
|
||||||
})
|
})
|
||||||
|
@ -18,33 +11,32 @@ router.afterEach(() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div flex justify-between sticky top-0 bg-base z-1 py-4 native:py-7 data-tauri-drag-region>
|
<!-- Use external to force refresh page and jump to top of timeline -->
|
||||||
|
<div flex justify-between>
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
flex items-end gap-3
|
flex items-end gap-4
|
||||||
py2 px-5
|
py2 px-5
|
||||||
text-2xl
|
text-2xl
|
||||||
select-none
|
select-none
|
||||||
focus-visible:ring="2 current"
|
focus-visible:ring="2 current"
|
||||||
to="/home"
|
to="/"
|
||||||
@click.prevent="onClickLogo"
|
external
|
||||||
>
|
>
|
||||||
<NavLogo shrink-0 aspect="1/1" sm:h-8 xl:h-10 class="rtl-flip" />
|
<NavLogo shrink-0 aspect="1/1" sm:h-8 xl:h-10 class="rtl-flip" />
|
||||||
<div v-show="isHydrated" hidden xl:block text-secondary>
|
<div hidden xl:block text-secondary>
|
||||||
{{ $t('app_name') }} <sup text-sm italic mt-1>{{ env === 'release' ? 'alpha' : env }}</sup>
|
{{ $t('app_name') }} <sup text-sm italic mt-1>{{ env === 'release' ? 'alpha' : env }}</sup>
|
||||||
</div>
|
</div>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<div
|
<div
|
||||||
hidden xl:flex items-center me-8 mt-2 gap-1
|
hidden xl:flex items-center me-8 mt-2
|
||||||
|
:class="{ 'pointer-events-none op0': !back || back === '/', 'xl:flex': $route.name !== 'tag' }"
|
||||||
>
|
>
|
||||||
<CommonTooltip :content="$t('nav.back')">
|
<NuxtLink
|
||||||
<NuxtLink
|
:aria-label="$t('nav.back')"
|
||||||
:aria-label="$t('nav.back')"
|
@click="$router.go(-1)"
|
||||||
:class="{ 'pointer-events-none op0': !back || back === '/', 'xl:flex': $route.name !== 'tag' }"
|
>
|
||||||
@click="$router.go(-1)"
|
<div i-ri:arrow-left-line class="rtl-flip" btn-text />
|
||||||
>
|
</NuxtLink>
|
||||||
<div text-xl i-ri:arrow-left-line class="rtl-flip" btn-text />
|
|
||||||
</NuxtLink>
|
|
||||||
</CommonTooltip>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
<script setup>
|
|
||||||
const { busy, oauth, singleInstanceServer } = useSignIn()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VDropdown v-if="isHydrated && currentUser" sm:hidden>
|
<VDropdown v-if="isHydrated && currentUser" sm:hidden>
|
||||||
<div style="-webkit-touch-callout: none;">
|
<div style="-webkit-touch-callout: none;">
|
||||||
<AccountAvatar
|
<AccountAvatar
|
||||||
|
ref="avatar"
|
||||||
:account="currentUser.account"
|
:account="currentUser.account"
|
||||||
h-8
|
h-8
|
||||||
w-8
|
w-8
|
||||||
|
@ -15,33 +12,10 @@ const { busy, oauth, singleInstanceServer } = useSignIn()
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #popper="{ hide }">
|
<template #popper="{ hide }">
|
||||||
<UserSwitcher @click="hide()" />
|
<UserSwitcher ref="switcher" @click="hide()" />
|
||||||
</template>
|
</template>
|
||||||
</VDropdown>
|
</VDropdown>
|
||||||
<template v-else>
|
<button v-else btn-solid text-sm px-2 py-1 text-center xl:hidden @click="openSigninDialog()">
|
||||||
<button
|
{{ $t('action.sign_in') }}
|
||||||
v-if="singleInstanceServer"
|
</button>
|
||||||
flex="~ row"
|
|
||||||
gap-x-1 items-center justify-center btn-solid text-sm px-2 py-1 xl:hidden
|
|
||||||
:disabled="busy"
|
|
||||||
@click="oauth()"
|
|
||||||
>
|
|
||||||
<span v-if="busy" aria-hidden="true" block animate animate-spin preserve-3d class="rtl-flip">
|
|
||||||
<span block i-ri:loader-2-fill aria-hidden="true" />
|
|
||||||
</span>
|
|
||||||
<span v-else aria-hidden="true" block i-ri:login-circle-line class="rtl-flip" />
|
|
||||||
<i18n-t keypath="action.sign_in_to">
|
|
||||||
<strong>{{ currentServer }}</strong>
|
|
||||||
</i18n-t>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
v-else
|
|
||||||
flex="~ row"
|
|
||||||
gap-x-1 items-center justify-center btn-solid text-sm px-2 py-1 xl:hidden
|
|
||||||
@click="openSigninDialog()"
|
|
||||||
>
|
|
||||||
<span aria-hidden="true" block i-ri:login-circle-line class="rtl-flip" />
|
|
||||||
{{ $t('action.sign_in') }}
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,13 +4,6 @@ import type { mastodon } from 'masto'
|
||||||
const { notification } = defineProps<{
|
const { notification } = defineProps<{
|
||||||
notification: mastodon.v1.Notification
|
notification: mastodon.v1.Notification
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
// well-known emoji reactions types Elk does not support yet
|
|
||||||
const unsupportedEmojiReactionTypes = ['pleroma:emoji_reaction', 'reaction']
|
|
||||||
if (unsupportedEmojiReactionTypes.includes(notification.type))
|
|
||||||
console.warn(`[DEV] ${t('notification.missing_type')} '${notification.type}' (notification.id: ${notification.id})`)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -22,65 +15,60 @@ if (unsupportedEmojiReactionTypes.includes(notification.type))
|
||||||
ps-3 pe-4 inset-is-0
|
ps-3 pe-4 inset-is-0
|
||||||
rounded-ie-be-3
|
rounded-ie-be-3
|
||||||
py-3 bg-base top-0
|
py-3 bg-base top-0
|
||||||
|
:lang="notification.status?.language ?? undefined"
|
||||||
>
|
>
|
||||||
<div i-ri-user-3-line text-xl me-3 color-blue />
|
<div i-ri:user-follow-fill me-1 color-primary />
|
||||||
<AccountDisplayName :account="notification.account" text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all />
|
<AccountDisplayName :account="notification.account" text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all />
|
||||||
<span ws-nowrap>
|
<span ws-nowrap>
|
||||||
{{ $t('notification.followed_you') }}
|
{{ $t('notification.followed_you') }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<AccountBigCard
|
<AccountBigCard
|
||||||
ms10
|
|
||||||
:account="notification.account"
|
:account="notification.account"
|
||||||
|
:lang="notification.status?.language ?? undefined"
|
||||||
/>
|
/>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="notification.type === 'admin.sign_up'">
|
<template v-else-if="notification.type === 'admin.sign_up'">
|
||||||
<NuxtLink :to="getAccountRoute(notification.account)">
|
<div flex p3 items-center bg-shaded>
|
||||||
<div flex p4 items-center bg-shaded>
|
<div i-ri:admin-fill me-1 color-purple />
|
||||||
<div i-ri:user-add-line text-xl me-2 color-purple />
|
|
||||||
<AccountDisplayName
|
|
||||||
:account="notification.account"
|
|
||||||
text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all
|
|
||||||
/>
|
|
||||||
<span>{{ $t("notification.signed_up") }}</span>
|
|
||||||
</div>
|
|
||||||
</NuxtLink>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="notification.type === 'admin.report'">
|
|
||||||
<NuxtLink :to="getReportRoute(notification.report?.id!)">
|
|
||||||
<div flex p4 items-center bg-shaded>
|
|
||||||
<div i-ri:flag-line text-xl me-2 color-purple />
|
|
||||||
<i18n-t keypath="notification.reported">
|
|
||||||
<AccountDisplayName
|
|
||||||
:account="notification.account"
|
|
||||||
text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all
|
|
||||||
/>
|
|
||||||
<AccountDisplayName
|
|
||||||
:account="notification.report?.targetAccount!"
|
|
||||||
text-purple ms-1 font-bold line-clamp-1 ws-pre-wrap break-all
|
|
||||||
/>
|
|
||||||
</i18n-t>
|
|
||||||
</div>
|
|
||||||
</NuxtLink>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="notification.type === 'follow_request'">
|
|
||||||
<div flex px-3 py-2>
|
|
||||||
<div i-ri-user-shared-line text-xl me-3 color-blue />
|
|
||||||
<AccountDisplayName
|
<AccountDisplayName
|
||||||
:account="notification.account"
|
:account="notification.account"
|
||||||
text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all
|
text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all
|
||||||
/>
|
/>
|
||||||
<span me-1 ws-nowrap>
|
<span>{{ $t("notification.signed_up") }}</span>
|
||||||
{{ $t('notification.request_to_follow') }}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<AccountCard p="s-2 e-4 b-2" hover-card :account="notification.account">
|
</template>
|
||||||
<AccountFollowRequestButton :account="notification.account" />
|
<template v-else-if="notification.type === 'follow_request'">
|
||||||
</AccountCard>
|
<div flex ms-4 items-center class="-top-2.5" absolute inset-ie-2 px-2>
|
||||||
|
<div i-ri:user-follow-fill text-xl me-1 />
|
||||||
|
<AccountInlineInfo :account="notification.account" me1 />
|
||||||
|
</div>
|
||||||
|
<!-- TODO: accept request -->
|
||||||
|
<AccountCard :account="notification.account" />
|
||||||
|
</template>
|
||||||
|
<template v-else-if="notification.type === 'favourite'">
|
||||||
|
<StatusCard :status="notification.status!" :faded="true">
|
||||||
|
<template #meta>
|
||||||
|
<div flex="~" gap-1 items-center mt1>
|
||||||
|
<div i-ri:heart-fill text-xl me-1 color-red />
|
||||||
|
<AccountInlineInfo text-primary font-bold :account="notification.account" me1 />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</StatusCard>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="notification.type === 'reblog'">
|
||||||
|
<StatusCard :status="notification.status!" :faded="true">
|
||||||
|
<template #meta>
|
||||||
|
<div flex="~" gap-1 items-center mt1>
|
||||||
|
<div i-ri:repeat-fill text-xl me-1 color-green />
|
||||||
|
<AccountInlineInfo text-primary font-bold :account="notification.account" me1 />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</StatusCard>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="notification.type === 'update'">
|
<template v-else-if="notification.type === 'update'">
|
||||||
<StatusCard :status="notification.status!" :in-notification="true" :actions="false">
|
<StatusCard :status="notification.status!" :faded="true">
|
||||||
<template #meta>
|
<template #meta>
|
||||||
<div flex="~" gap-1 items-center mt1>
|
<div flex="~" gap-1 items-center mt1>
|
||||||
<div i-ri:edit-2-fill text-xl me-1 text-secondary />
|
<div i-ri:edit-2-fill text-xl me-1 text-secondary />
|
||||||
|
@ -95,9 +83,7 @@ if (unsupportedEmojiReactionTypes.includes(notification.type))
|
||||||
<template v-else-if="notification.type === 'mention' || notification.type === 'poll' || notification.type === 'status'">
|
<template v-else-if="notification.type === 'mention' || notification.type === 'poll' || notification.type === 'status'">
|
||||||
<StatusCard :status="notification.status!" />
|
<StatusCard :status="notification.status!" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="!unsupportedEmojiReactionTypes.includes(notification.type)">
|
<template v-else>
|
||||||
<!-- prevent showing errors for dev for known emoji reaction types -->
|
|
||||||
<!-- type 'favourite' and 'reblog' should always rendered by NotificationGroupedLikes -->
|
|
||||||
<div text-red font-bold>
|
<div text-red font-bold>
|
||||||
[DEV] {{ $t('notification.missing_type') }} '{{ notification.type }}'
|
[DEV] {{ $t('notification.missing_type') }} '{{ notification.type }}'
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,7 +10,7 @@ defineProps<{
|
||||||
defineEmits(['hide', 'subscribe'])
|
defineEmits(['hide', 'subscribe'])
|
||||||
|
|
||||||
defineSlots<{
|
defineSlots<{
|
||||||
error: (props: object) => void
|
error: {}
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const xl = useMediaQuery('(min-width: 1280px)')
|
const xl = useMediaQuery('(min-width: 1280px)')
|
||||||
|
|
|
@ -5,17 +5,17 @@ const { items } = defineProps<{
|
||||||
items: GroupedNotifications
|
items: GroupedNotifications
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const count = computed(() => items.items.length)
|
const count = $computed(() => items.items.length)
|
||||||
const isExpanded = ref(false)
|
const isExpanded = ref(false)
|
||||||
const lang = computed(() => {
|
const lang = $computed(() => {
|
||||||
return (count.value > 1 || count.value === 0) ? undefined : items.items[0].status?.language
|
return count > 1 || count === 0 ? undefined : items.items[0].status?.language
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<article flex flex-col relative :lang="lang ?? undefined">
|
<article flex flex-col relative :lang="lang ?? undefined">
|
||||||
<div flex items-center top-0 left-2 pt-2 px-3>
|
<div flex items-center top-0 left-2 pt-2 px-3>
|
||||||
<div :class="count > 1 ? 'i-ri-group-line' : 'i-ri-user-3-line'" me-3 color-blue text-xl aria-hidden="true" />
|
<div i-ri:user-follow-fill me-3 color-primary aria-hidden="true" />
|
||||||
<template v-if="count > 1">
|
<template v-if="count > 1">
|
||||||
<CommonLocalizedNumber
|
<CommonLocalizedNumber
|
||||||
keypath="notification.followed_you_count"
|
keypath="notification.followed_you_count"
|
||||||
|
@ -32,7 +32,7 @@ const lang = computed(() => {
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div pb-2 ps8>
|
<div pb-2>
|
||||||
<div v-if="isExpanded">
|
<div v-if="isExpanded">
|
||||||
<AccountCard
|
<AccountCard
|
||||||
v-for="item in items.items"
|
v-for="item in items.items"
|
||||||
|
|
|
@ -4,59 +4,21 @@ import type { GroupedLikeNotifications } from '~/types'
|
||||||
const { group } = defineProps<{
|
const { group } = defineProps<{
|
||||||
group: GroupedLikeNotifications
|
group: GroupedLikeNotifications
|
||||||
}>()
|
}>()
|
||||||
const useStarFavoriteIcon = usePreferences('useStarFavoriteIcon')
|
|
||||||
|
|
||||||
const reblogs = computed(() => group.likes.filter(i => i.reblog))
|
|
||||||
const likes = computed(() => group.likes.filter(i => i.favourite && !i.reblog))
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<article flex flex-col relative>
|
<article flex flex-col relative>
|
||||||
<StatusLink :status="group.status!" pb4 pt5>
|
<StatusCard :status="group.status!" :faded="true">
|
||||||
<div flex flex-col gap-3>
|
<template #meta>
|
||||||
<div v-if="reblogs.length" flex="~ gap-1">
|
<div flex flex-col gap-1 mt-1>
|
||||||
<div i-ri:repeat-fill text-xl me-2 color-green />
|
<div v-for="like of group.likes" :key="like.account.id" flex>
|
||||||
<template v-for="i, idx of reblogs" :key="idx">
|
<div v-if="like.reblog" i-ri:repeat-fill text-xl me-2 color-green />
|
||||||
<AccountHoverWrapper :account="i.account">
|
<div v-if="like.favourite && !like.reblog" i-ri:heart-fill text-xl me-2 color-red />
|
||||||
<NuxtLink :to="getAccountRoute(i.account)">
|
<AccountInlineInfo text-primary font-bold :account="like.account" me2 />
|
||||||
<AccountAvatar text-primary font-bold :account="i.account" class="h-1.5em w-1.5em" />
|
<div v-if="like.favourite && like.reblog" i-ri:heart-fill text-xl me-2 color-red />
|
||||||
</NuxtLink>
|
|
||||||
</AccountHoverWrapper>
|
|
||||||
</template>
|
|
||||||
<div ml1>
|
|
||||||
{{ $t('notification.reblogged_post') }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="likes.length" flex="~ gap-1">
|
</template>
|
||||||
<div :class="useStarFavoriteIcon ? 'i-ri:star-line color-yellow' : 'i-ri:heart-line color-red'" text-xl me-2 />
|
</StatusCard>
|
||||||
<template v-for="i, idx of likes" :key="idx">
|
|
||||||
<AccountHoverWrapper :account="i.account">
|
|
||||||
<NuxtLink :to="getAccountRoute(i.account)">
|
|
||||||
<AccountAvatar text-primary font-bold :account="i.account" class="h-1.5em w-1.5em" />
|
|
||||||
</NuxtLink>
|
|
||||||
</AccountHoverWrapper>
|
|
||||||
</template>
|
|
||||||
<div ms1>
|
|
||||||
{{ $t('notification.favourited_post') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div ps9 mt-1>
|
|
||||||
<StatusBody :status="group.status!" text-secondary />
|
|
||||||
<!-- When no text content is presented, we show media instead -->
|
|
||||||
<template v-if="!group.status!.content">
|
|
||||||
<StatusMedia
|
|
||||||
v-if="group.status!.mediaAttachments?.length"
|
|
||||||
:status="group.status!"
|
|
||||||
:is-preview="false"
|
|
||||||
pointer-events-none
|
|
||||||
/>
|
|
||||||
<StatusPoll
|
|
||||||
v-else-if="group.status!.poll"
|
|
||||||
:status="group.status!"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</StatusLink>
|
|
||||||
</article>
|
</article>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,31 +1,21 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// @ts-expect-error missing types
|
// @ts-expect-error missing types
|
||||||
import { DynamicScrollerItem } from 'vue-virtual-scroller'
|
import { DynamicScrollerItem } from 'vue-virtual-scroller'
|
||||||
import type { mastodon } from 'masto'
|
import type { Paginator, WsEvents, mastodon } from 'masto'
|
||||||
import type { GroupedAccountLike, NotificationSlot } from '~/types'
|
import type { GroupedAccountLike, NotificationSlot } from '~/types'
|
||||||
|
|
||||||
const { paginator, stream } = defineProps<{
|
const { paginator, stream } = defineProps<{
|
||||||
paginator: mastodon.Paginator<mastodon.v1.Notification[], mastodon.rest.v1.ListNotificationsParams>
|
paginator: Paginator<mastodon.v1.Notification[], mastodon.v1.ListNotificationsParams>
|
||||||
stream?: mastodon.streaming.Subscription
|
stream?: Promise<WsEvents>
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const virtualScroller = false // TODO: fix flickering issue with virtual scroll
|
const virtualScroller = false // TODO: fix flickering issue with virtual scroll
|
||||||
|
|
||||||
const groupCapacity = Number.MAX_VALUE // No limit
|
const groupCapacity = Number.MAX_VALUE // No limit
|
||||||
|
|
||||||
const includeNotificationTypes: mastodon.v1.NotificationType[] = ['update', 'mention', 'poll', 'status']
|
|
||||||
|
|
||||||
function includeNotificationsForStatusCard({ type, status }: mastodon.v1.Notification) {
|
|
||||||
// Exclude update, mention, pool and status notifications without the status entry:
|
|
||||||
// no makes sense to include them
|
|
||||||
// Those notifications will be shown using StatusCard SFC:
|
|
||||||
// check NotificationCard SFC L68 and L81 => :status="notification.status!"
|
|
||||||
return status || !includeNotificationTypes.includes(type)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Group by type (and status when applicable)
|
// Group by type (and status when applicable)
|
||||||
function groupId(item: mastodon.v1.Notification): string {
|
const groupId = (item: mastodon.v1.Notification): string => {
|
||||||
// If the update is related to a status, group notifications from the same account (boost + favorite the same status)
|
// If the update is related to an status, group notifications from the same account (boost + favorite the same status)
|
||||||
const id = item.status
|
const id = item.status
|
||||||
? {
|
? {
|
||||||
status: item.status?.id,
|
status: item.status?.id,
|
||||||
|
@ -85,12 +75,9 @@ function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else if (group.length && (group[0].type === 'reblog' || group[0].type === 'favourite')) {
|
|
||||||
if (!group[0].status) {
|
const { status } = group[0]
|
||||||
// Ignore favourite or reblog if status is null, sometimes the API is sending these
|
if (status && group.length > 1 && (group[0].type === 'reblog' || group[0].type === 'favourite')) {
|
||||||
// notifications
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// All notifications in these group are reblogs or favourites of the same status
|
// All notifications in these group are reblogs or favourites of the same status
|
||||||
const likes: GroupedAccountLike[] = []
|
const likes: GroupedAccountLike[] = []
|
||||||
for (const notification of group) {
|
for (const notification of group) {
|
||||||
|
@ -101,15 +88,11 @@ function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
|
||||||
}
|
}
|
||||||
like[notification.type === 'reblog' ? 'reblog' : 'favourite'] = notification
|
like[notification.type === 'reblog' ? 'reblog' : 'favourite'] = notification
|
||||||
}
|
}
|
||||||
likes.sort((a, b) => a.reblog
|
likes.sort((a, b) => a.reblog ? !b.reblog || (a.favourite && !b.favourite) ? -1 : 0 : 0)
|
||||||
? (!b.reblog || (a.favourite && !b.favourite))
|
|
||||||
? -1
|
|
||||||
: 0
|
|
||||||
: 0)
|
|
||||||
results.push({
|
results.push({
|
||||||
id: `grouped-${id++}`,
|
id: `grouped-${id++}`,
|
||||||
type: 'grouped-reblogs-and-favourites',
|
type: 'grouped-reblogs-and-favourites',
|
||||||
status: group[0].status,
|
status,
|
||||||
likes,
|
likes,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
@ -118,9 +101,9 @@ function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
|
||||||
results.push(...group)
|
results.push(...group)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const item of items.filter(includeNotificationsForStatusCard)) {
|
for (const item of items) {
|
||||||
const itemId = groupId(item)
|
const itemId = groupId(item)
|
||||||
// Finalize the group if it already has too many notifications
|
// Finalize group if it already has too many notifications
|
||||||
if (currentGroupId !== itemId || currentGroup.length >= groupCapacity)
|
if (currentGroupId !== itemId || currentGroup.length >= groupCapacity)
|
||||||
processGroup()
|
processGroup()
|
||||||
|
|
||||||
|
@ -165,17 +148,17 @@ const { clearNotifications } = useNotifications()
|
||||||
const { formatNumber } = useHumanReadableNumber()
|
const { formatNumber } = useHumanReadableNumber()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- eslint-disable vue/attribute-hyphenation -->
|
|
||||||
<template>
|
<template>
|
||||||
<CommonPaginator
|
<CommonPaginator
|
||||||
:paginator="paginator"
|
:paginator="paginator"
|
||||||
:preprocess="preprocess"
|
:preprocess="preprocess"
|
||||||
:stream="stream"
|
:stream="stream"
|
||||||
eventType="notification"
|
:eager="3"
|
||||||
:virtualScroller="virtualScroller"
|
:virtual-scroller="virtualScroller"
|
||||||
|
event-type="notification"
|
||||||
>
|
>
|
||||||
<template #updater="{ number, update }">
|
<template #updater="{ number, update }">
|
||||||
<button id="elk_show_new_items" py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="() => { update(); clearNotifications() }">
|
<button py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="() => { update(); clearNotifications() }">
|
||||||
{{ $t('timeline.show_new_items', number, { named: { v: formatNumber(number) } }) }}
|
{{ $t('timeline.show_new_items', number, { named: { v: formatNumber(number) } }) }}
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { PushSubscriptionError } from '~/composables/push-notifications/types'
|
||||||
|
|
||||||
defineProps<{ show?: boolean }>()
|
defineProps<{ show?: boolean }>()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -17,86 +19,86 @@ const { t } = useI18n()
|
||||||
|
|
||||||
const pwaEnabled = useAppConfig().pwaEnabled
|
const pwaEnabled = useAppConfig().pwaEnabled
|
||||||
|
|
||||||
const busy = ref<boolean>(false)
|
let busy = $ref<boolean>(false)
|
||||||
const animateSave = ref<boolean>(false)
|
let animateSave = $ref<boolean>(false)
|
||||||
const animateSubscription = ref<boolean>(false)
|
let animateSubscription = $ref<boolean>(false)
|
||||||
const animateRemoveSubscription = ref<boolean>(false)
|
let animateRemoveSubscription = $ref<boolean>(false)
|
||||||
const subscribeError = ref<string>('')
|
let subscribeError = $ref<string>('')
|
||||||
const showSubscribeError = ref<boolean>(false)
|
let showSubscribeError = $ref<boolean>(false)
|
||||||
|
|
||||||
function hideNotification() {
|
const hideNotification = () => {
|
||||||
const key = currentUser.value?.account?.acct
|
const key = currentUser.value?.account?.acct
|
||||||
if (key)
|
if (key)
|
||||||
hiddenNotification.value[key] = true
|
hiddenNotification.value[key] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const showWarning = computed(() => {
|
const showWarning = $computed(() => {
|
||||||
if (!pwaEnabled)
|
if (!pwaEnabled)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
return isSupported
|
return isSupported
|
||||||
&& (!isSubscribed.value || !notificationPermission.value || notificationPermission.value === 'prompt')
|
&& (!isSubscribed.value || !notificationPermission.value || notificationPermission.value === 'prompt')
|
||||||
&& !(hiddenNotification.value[currentUser.value?.account?.acct ?? ''])
|
&& !(hiddenNotification.value[currentUser.value?.account?.acct ?? ''] === true)
|
||||||
})
|
})
|
||||||
|
|
||||||
async function saveSettings() {
|
const saveSettings = async () => {
|
||||||
if (busy.value)
|
if (busy)
|
||||||
return
|
return
|
||||||
|
|
||||||
busy.value = true
|
busy = true
|
||||||
await nextTick()
|
await nextTick()
|
||||||
animateSave.value = true
|
animateSave = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await updateSubscription()
|
const subscription = await updateSubscription()
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// todo: handle error
|
// todo: handle error
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
busy.value = false
|
busy = false
|
||||||
animateSave.value = false
|
animateSave = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doSubscribe() {
|
const doSubscribe = async () => {
|
||||||
if (busy.value)
|
if (busy)
|
||||||
return
|
return
|
||||||
|
|
||||||
busy.value = true
|
busy = true
|
||||||
await nextTick()
|
await nextTick()
|
||||||
animateSubscription.value = true
|
animateSubscription = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await subscribe()
|
const result = await subscribe()
|
||||||
if (result !== 'subscribed') {
|
if (result !== 'subscribed') {
|
||||||
subscribeError.value = t(`settings.notifications.push_notifications.subscription_error.${result === 'notification-denied' ? 'permission_denied' : 'request_error'}`)
|
subscribeError = t(`settings.notifications.push_notifications.subscription_error.${result === 'notification-denied' ? 'permission_denied' : 'request_error'}`)
|
||||||
showSubscribeError.value = true
|
showSubscribeError = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (err instanceof PushSubscriptionError) {
|
if (err instanceof PushSubscriptionError) {
|
||||||
subscribeError.value = t(`settings.notifications.push_notifications.subscription_error.${err.code}`)
|
subscribeError = t(`settings.notifications.push_notifications.subscription_error.${err.code}`)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
subscribeError.value = t('settings.notifications.push_notifications.subscription_error.request_error')
|
subscribeError = t('settings.notifications.push_notifications.subscription_error.request_error')
|
||||||
}
|
}
|
||||||
showSubscribeError.value = true
|
showSubscribeError = true
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
busy.value = false
|
busy = false
|
||||||
animateSubscription.value = false
|
animateSubscription = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function removeSubscription() {
|
const removeSubscription = async () => {
|
||||||
if (busy.value)
|
if (busy)
|
||||||
return
|
return
|
||||||
|
|
||||||
busy.value = true
|
busy = true
|
||||||
await nextTick()
|
await nextTick()
|
||||||
animateRemoveSubscription.value = true
|
animateRemoveSubscription = true
|
||||||
try {
|
try {
|
||||||
await unsubscribe()
|
await unsubscribe()
|
||||||
}
|
}
|
||||||
|
@ -104,11 +106,11 @@ async function removeSubscription() {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
busy.value = false
|
busy = false
|
||||||
animateRemoveSubscription.value = false
|
animateRemoveSubscription = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onActivated(() => (busy.value = false))
|
onActivated(() => (busy = false))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -3,7 +3,9 @@ defineProps<{
|
||||||
title?: string
|
title?: string
|
||||||
message: string
|
message: string
|
||||||
}>()
|
}>()
|
||||||
const modelValue = defineModel<boolean>({ required: true })
|
const { modelValue } = defineModel<{
|
||||||
|
modelValue: boolean
|
||||||
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -34,19 +36,5 @@ const modelValue = defineModel<boolean>({ required: true })
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
</head>
|
</head>
|
||||||
<p>{{ message }}</p>
|
<p>{{ message }}</p>
|
||||||
<p py-2>
|
|
||||||
<i18n-t keypath="settings.notifications.push_notifications.subscription_error.error_hint">
|
|
||||||
<NuxtLink font-bold href="https://docs.elk.zone/pwa#faq" target="_blank" inline-flex="~ row" items-center gap-x-2>
|
|
||||||
https://docs.elk.zone/pwa#faq
|
|
||||||
<span inline-block aria-hidden="true" i-ri:external-link-line class="rtl-flip" />
|
|
||||||
</NuxtLink>
|
|
||||||
</i18n-t>
|
|
||||||
</p>
|
|
||||||
<p py-2>
|
|
||||||
<NuxtLink font-bold text-primary href="https://github.com/elk-zone/elk" target="_blank" flex="~ row" items-center gap-x-2>
|
|
||||||
{{ $t('settings.notifications.push_notifications.subscription_error.repo_link') }}
|
|
||||||
<span inline-block aria-hidden="true" i-ri:external-link-line class="rtl-flip" />
|
|
||||||
</NuxtLink>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -15,21 +15,17 @@ const emit = defineEmits<{
|
||||||
(evt: 'setDescription', description: string): void
|
(evt: 'setDescription', description: string): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
// from https://github.com/mastodon/mastodon/blob/dfa984/app/models/media_attachment.rb#L40
|
|
||||||
const maxDescriptionLength = 1500
|
|
||||||
|
|
||||||
const isEditDialogOpen = ref(false)
|
const isEditDialogOpen = ref(false)
|
||||||
const description = ref(props.attachment.description ?? '')
|
const description = ref(props.attachment.description ?? '')
|
||||||
|
const toggleApply = () => {
|
||||||
function toggleApply() {
|
|
||||||
isEditDialogOpen.value = false
|
isEditDialogOpen.value = false
|
||||||
emit('setDescription', description.value)
|
emit('setDescription', unref(description))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div relative group>
|
<div relative group>
|
||||||
<StatusAttachment :attachment="attachment" w-full is-preview />
|
<StatusAttachment :attachment="attachment" w-full />
|
||||||
<div absolute right-2 top-2>
|
<div absolute right-2 top-2>
|
||||||
<div
|
<div
|
||||||
v-if="removable"
|
v-if="removable"
|
||||||
|
@ -59,10 +55,7 @@ function toggleApply() {
|
||||||
</h1>
|
</h1>
|
||||||
<div flex flex-col gap-2>
|
<div flex flex-col gap-2>
|
||||||
<textarea v-model="description" p-3 h-50 bg-base rounded-2 border-strong border-1 md:w-100 />
|
<textarea v-model="description" p-3 h-50 bg-base rounded-2 border-strong border-1 md:w-100 />
|
||||||
<div flex flex-row-reverse>
|
<button btn-outline @click="toggleApply">
|
||||||
<PublishCharacterCounter :length="description.length" :max="maxDescriptionLength" />
|
|
||||||
</div>
|
|
||||||
<button btn-outline :disabled="description.length > maxDescriptionLength" @click="toggleApply">
|
|
||||||
{{ $t('action.apply') }}
|
{{ $t('action.apply') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,7 +63,7 @@ function toggleApply() {
|
||||||
{{ $t('action.close') }}
|
{{ $t('action.close') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<StatusAttachment :attachment="attachment" w-full is-preview />
|
<StatusAttachment :attachment="attachment" w-full />
|
||||||
</div>
|
</div>
|
||||||
</ModalDialog>
|
</ModalDialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
defineProps<{
|
|
||||||
max: number
|
|
||||||
length: number
|
|
||||||
}>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div dir="ltr" pointer-events-none pe-1 pt-2 text-sm tabular-nums text-secondary flex gap="0.5" :class="{ 'text-rose-500': length > max }">
|
|
||||||
{{ length ?? 0 }}<span text-secondary-light>/</span><span text-secondary-light>{{ max }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
|
@ -1,54 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import type { Editor } from '@tiptap/core'
|
|
||||||
|
|
||||||
const { editor } = defineProps<{
|
|
||||||
editor: Editor
|
|
||||||
}>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<CommonTooltip placement="top" :content="$t('tooltip.open_editor_tools')">
|
|
||||||
<VDropdown v-if="editor" placement="bottom">
|
|
||||||
<button
|
|
||||||
btn-action-icon
|
|
||||||
:aria-label="$t('tooltip.open_editor_tools')"
|
|
||||||
>
|
|
||||||
<div i-ri:font-size-2 />
|
|
||||||
</button>
|
|
||||||
<template #popper>
|
|
||||||
<div flex gap-1>
|
|
||||||
<CommonTooltip placement="top" :content="$t('tooltip.toggle_code_block')">
|
|
||||||
<button
|
|
||||||
btn-action-icon
|
|
||||||
:aria-label="$t('tooltip.toggle_code_block')"
|
|
||||||
:class="editor.isActive('codeBlock') ? 'text-primary' : ''"
|
|
||||||
@click="editor?.chain().focus().toggleCodeBlock().run()"
|
|
||||||
>
|
|
||||||
<div i-ri:code-s-slash-line />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
<CommonTooltip placement="top" :content="$t('tooltip.toggle_bold')">
|
|
||||||
<button
|
|
||||||
btn-action-icon
|
|
||||||
:aria-label="$t('tooltip.toggle_bold')"
|
|
||||||
:class="editor.isActive('bold') ? 'text-primary' : ''"
|
|
||||||
@click="editor?.chain().focus().toggleBold().run()"
|
|
||||||
>
|
|
||||||
<div i-ri:bold />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
<CommonTooltip placement="top" :content="$t('tooltip.toggle_italic')">
|
|
||||||
<button
|
|
||||||
btn-action-icon
|
|
||||||
:aria-label="$t('tooltip.toggle_italic')"
|
|
||||||
:class="editor.isActive('italic') ? 'text-primary' : ''"
|
|
||||||
@click="editor?.chain().focus().toggleItalic().run()"
|
|
||||||
>
|
|
||||||
<div i-ri:italic />
|
|
||||||
</button>
|
|
||||||
</CommonTooltip>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</VDropdown>
|
|
||||||
</CommonTooltip>
|
|
||||||
</template>
|
|
|
@ -1,5 +1,4 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import importEmojiLang from 'virtual:emoji-mart-lang-importer'
|
|
||||||
import type { Picker } from 'emoji-mart'
|
import type { Picker } from 'emoji-mart'
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
|
@ -7,49 +6,41 @@ const emit = defineEmits<{
|
||||||
(e: 'selectCustom', image: any): void
|
(e: 'selectCustom', image: any): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { locale } = useI18n()
|
const el = $ref<HTMLElement>()
|
||||||
|
let picker = $ref<Picker>()
|
||||||
const el = ref<HTMLElement>()
|
|
||||||
const picker = ref<Picker>()
|
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
|
|
||||||
async function openEmojiPicker() {
|
async function openEmojiPicker() {
|
||||||
await updateCustomEmojis()
|
await updateCustomEmojis()
|
||||||
|
if (picker) {
|
||||||
if (picker.value) {
|
picker.update({
|
||||||
picker.value.update({
|
theme: colorMode.value,
|
||||||
theme: colorMode,
|
|
||||||
custom: customEmojisData.value,
|
custom: customEmojisData.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const [Picker, dataPromise, i18n] = await Promise.all([
|
const promise = import('@emoji-mart/data/sets/14/twitter.json').then(r => r.default)
|
||||||
import('emoji-mart').then(({ Picker }) => Picker),
|
const { Picker } = await import('emoji-mart')
|
||||||
import('@emoji-mart/data/sets/14/twitter.json').then((r: any) => r.default).catch(() => {}),
|
picker = new Picker({
|
||||||
importEmojiLang(locale.value.split('-')[0]),
|
data: () => promise,
|
||||||
])
|
|
||||||
|
|
||||||
picker.value = new Picker({
|
|
||||||
data: () => dataPromise,
|
|
||||||
onEmojiSelect({ native, src, alt, name }: any) {
|
onEmojiSelect({ native, src, alt, name }: any) {
|
||||||
native
|
native
|
||||||
? emit('select', native)
|
? emit('select', native)
|
||||||
: emit('selectCustom', { src, alt, 'data-emoji-id': name })
|
: emit('selectCustom', { src, alt, 'data-emoji-id': name })
|
||||||
},
|
},
|
||||||
set: 'twitter',
|
set: 'twitter',
|
||||||
theme: colorMode,
|
theme: colorMode.value,
|
||||||
custom: customEmojisData.value,
|
custom: customEmojisData.value,
|
||||||
i18n,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
await nextTick()
|
await nextTick()
|
||||||
// TODO: custom picker
|
// TODO: custom picker
|
||||||
el.value?.appendChild(picker.value as any as HTMLElement)
|
el?.appendChild(picker as any as HTMLElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideEmojiPicker() {
|
const hideEmojiPicker = () => {
|
||||||
if (picker.value)
|
if (picker)
|
||||||
el.value?.removeChild(picker.value as any as HTMLElement)
|
el?.removeChild(picker as any as HTMLElement)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
defineProps<{ describedBy: string }>()
|
defineProps<{
|
||||||
|
describedBy: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
inheritAttrs: false,
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
role="alert"
|
role="alert"
|
||||||
aria-live="polite"
|
|
||||||
:aria-describedby="describedBy"
|
:aria-describedby="describedBy"
|
||||||
flex="~ col"
|
flex="~ col"
|
||||||
gap-1 text-sm
|
gap-1 text-sm
|
||||||
pt-1 ps-2 pe-1 pb-2
|
pt-1 ps-2 pe-1 pb-2
|
||||||
text-red-600 dark:text-red-400
|
text-red-600 dark:text-red-400
|
||||||
border="~ base rounded red-600 dark:red-400"
|
border="~ base rounded red-600 dark:red-400"
|
||||||
v-bind="$attrs"
|
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue