Skip to content

Commit

Permalink
add custom ID arg
Browse files Browse the repository at this point in the history
  • Loading branch information
shabegom committed Mar 27, 2021
1 parent 1ce47c3 commit b0d3f22
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ Buttons have 4 arguments: name, type, action, color

| argument | description | options | example |
-----------|--------------------------------------------|----------------------------------------------|------------|
| name | the name of the button | any string | My Button |
| type | run a command or open a url | command, link | command |
| action | the command to run or link to open | any command from the command palette or url | Toggle Pin |
| color | optional arg to change color of the button | blue, green, red, purple. yellow | blue |
| customClass | add a class to the button for more customized styling | a string representing your custom class | myClass |
| name | the name of the button | any string | My Button |
| type | run a command or open a url | command, link | command |
| action | the command to run or link to open | any command from the command palette or url | Toggle Pin |
| color | optional: arg to change color of the button | blue, green, red, purple. yellow | blue |
| customClass | optional: add a class to the button for more customized styling | a string representing your custom class | myClass |
| customId | optional: add a custom id to the button for styling | a string representing your custom id | myId |


You create a button using a `button` codeblock

Expand All @@ -43,7 +45,7 @@ type link
action https://booked.email
\`\`\`

### Custom Class
### Custom Class & ID

You can add an optional `customClass` argument to target the button with any css styling tweaks you'd want to add

Expand All @@ -52,6 +54,7 @@ name My Round Link Button
type link
action https://booked.email
customClass roundButton
customId myId
\`\`\`

then in your css tweaks:
Expand All @@ -60,6 +63,10 @@ then in your css tweaks:
.roundButton {
border-radius: 100% !important;
}
#myId {
color: rebeccapurple;
}
```

use `!important` to override any existing styling from `.default-button`
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "buttons",
"name": "Buttons",
"description": "Create Buttons in your Obsidian notes to run commands",
"version": "0.0.2",
"version": "0.0.3",
"author": "shabegom",
"authorUrl": "https://shbgm.ca",
"isDesktopOnly": false,
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Arguments {
action?: string;
color?: string;
customClass?: string;
customId?: string;
}

export default class ReactStarterPlugin extends Plugin {
Expand Down Expand Up @@ -51,6 +52,7 @@ export default class ReactStarterPlugin extends Plugin {
args.customClass ? args.customClass : ""
}`,
});
args.customId ? button.setAttribute("id", args.customId) : "";
button.on("click", "button", () => {
clickHandler(args);
});
Expand Down

0 comments on commit b0d3f22

Please sign in to comment.