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

"Run" button position #208

Open
rotten77 opened this issue Jan 13, 2023 · 11 comments
Open

"Run" button position #208

rotten77 opened this issue Jan 13, 2023 · 11 comments

Comments

@rotten77
Copy link

Please add position of the "Run" button into the settings. In case of short (one or two-line) snippet/code it overlays the "Copy" button:

image

@chlohal
Copy link
Collaborator

chlohal commented Jan 20, 2023

I see, thank you for reporting this.

I can think of a few options for the positioning. Which one of these do you think is the best for you?

  • below the code block (inside code block)
    image
    -below the code block (outside code block)
    image
  • to the right of the code block (as an icon) -- might misbehave with themes that have minimal page margin
    image
  • Another option-- please feel free to propose something! :)

I'm not sure if we'll change the default behaviour, but it's always good to offer other choices. Thank you! :)

@rotten77
Copy link
Author

rotten77 commented Jan 21, 2023

Hi, I tried your options 1 and 2 by custom CSS just after I send this issue and I was not happy with the result :-)

I like the third option - the "play" icon but maybe place it at the left (before the code block).

My proposals are there. I think that the first one is most "easy to do", the second one looks nice but it can break the design. The third one is good because you can put the position in the settings (left top, left bottom, ...) but it looks different and may make users upset :-) On the other hand, the third option can be always displayed (not just by hovering).

Screenshot 2023-01-21 at 7 41 54

As you wrote - the default option should be still available because a lot of users can be familiar/happy with this. Maybe not many users use one-line snippets. I have some powershells scripts for automating my daily tasks so I have some of them.

@chlohal
Copy link
Collaborator

chlohal commented Jan 21, 2023

Thanks for your proposals!

I worry that the first one would hide the code. Maybe that's not as much of an issue if it's only visible on hover?

The second one would be a good match with the running indicator!

I think that the third option's positioning versatility is good, but I agree that users might dislike it because of the styling. We should also worry about accessibility -- to me, at least, they don't appear to be buttons, and that's very important to keep consistency across themes (i.e. we should be able to use the theme's "button" style)

@chlohal
Copy link
Collaborator

chlohal commented Jan 21, 2023

I just realized that we could also make an option to allow double-clicking on the box itself to run, rather than a visible button. What do you think?

@rotten77
Copy link
Author

I thought about this too but I don't think it's a good idea. You can accidentally double-click and in that case, it would be unexpected behavior.

@hthuong09
Copy link

I would prefer something like rust by example site
image

Can take a look here: https://doc.rust-lang.org/stable/rust-by-example/primitives/literals.html#literals-and-operators

@rotten77
Copy link
Author

I would prefer something like rust ...

I agree but this will change also the default behavior and design of Obsidian's copy button.

@rotten77
Copy link
Author

I made a temporary solution with custom CSS for myself. It's ugly (I am too lazy to solve all CSS issues so I override them by "!important") but I can live with it :-)

image

button.run-code-button, button.copy-code-button, button.clear-button {
    border:1px solid #888;
    box-shadow: none !important;
    background: #333 !important;
    margin:0 !important;
    padding:0 !important;
    width:32px !important;
    height:24px !important;
    line-height: 24px;
    font-size:0.6em !important;
    text-align: center;
    position: absolute !important;

}
button.run-code-button, button.copy-code-button {
    top: 8px !important;
}
button.copy-code-button {right:16px !important;}
button.run-code-button {right:53px !important;}
button.clear-button {
    position: absolute !important;
    left: 16px !important;
    bottom: 8px !important;
}

button.run-code-button:hover, button.copy-code-button:hover, button.clear-button:hover {
    background:#555 !important;
}

@chlohal
Copy link
Collaborator

chlohal commented Jan 24, 2023

I agree but this will change also the default behavior and design of Obsidian's copy button.

That's true-- we can always make it available as an option, but maybe not a recommended one?

@hannesdelbeke
Copy link
Contributor

hannesdelbeke commented Jan 29, 2023

I agree but this will change also the default behavior and design of Obsidian's copy button.

would changing the default copy be a bad thing? default copy overlaps with code sometimes. which is not ideal for readability. If the copy button had a solid background if would already be cleaner, even if it still overlapped.
image

e.g. when hoverring the copy button, it's cleaner
image

@rotten77
Copy link
Author

I discovered that some other extensions also change the default copy button style so it can be messy in general :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants