Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ids & classes to make it easier to customize Memos with CSS and Javascript #4481

Open
samglover opened this issue Mar 8, 2025 · 2 comments · May be fixed by #4490
Open

Ids & classes to make it easier to customize Memos with CSS and Javascript #4481

samglover opened this issue Mar 8, 2025 · 2 comments · May be fixed by #4490
Labels
enhancement New feature or request PR welcome Good for new contributor

Comments

@samglover
Copy link

samglover commented Mar 8, 2025

Describe the solution you'd like

It would be great if the div for each memo/note contained a unique id and classes to make it easier to target them.

Right now this is how the div container for a note renders:

<div class="group relative flex flex-col justify-start items-start w-full px-4 py-3 mb-2 gap-2 bg-white dark:bg-zinc-800 rounded-lg border border-white dark:border-zinc-800 hover:border-gray-200 dark:hover:border-zinc-700">
  [note]
</div>

I'd like it if the note included a unique id and classes like "memo" and "tagged-warning" for easier targeting. It would be great if the div looked something like this:

<div id="memo-123456" class="memo tagged-personal tagged-warning tagged-web-dev …">
  <div class="memo-header"><div>
  <div class="memo-body"></div>
</div>

Then it would be easy to customize notes with CSS and Javascript like these:

.memo {
  background: lightgray;
}

.tagged-warning {
  border-left: 5px solid red;
}
let memo123456 = document.getElementById('memo-123456');

let memos = document.querySelectorAll('.memo');
let warnings = document.querySelectorAll('.tagged-warning');

Type of feature

Other

Additional context

No response

@samglover samglover added the enhancement New feature or request label Mar 8, 2025
@samglover
Copy link
Author

samglover commented Mar 9, 2025

In fact I couldn't come up with a reliable selector for the memo body. This works on the front page:

main > section > div > :first-child > div > :last-child > div > div > :last-child {
  background-color: red;
}

But it's a pretty ridiculous selector. It also doesn't work on the profile page and grabs random elements in the settings page.

@johnnyjoygh johnnyjoygh added the PR welcome Good for new contributor label Mar 9, 2025
@samglover
Copy link
Author

I'd be happy to submit a pull request, but please see #4485 for a bug that's preventing me from working on the code.

samglover added a commit to samglover/memos that referenced this issue Mar 11, 2025
@samglover samglover linked a pull request Mar 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR welcome Good for new contributor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants