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

Add option for fit to screen #721

Closed

Conversation

bluemir
Copy link

@bluemir bluemir commented Jan 26, 2023

Add CLI option for disable fit to screen script. ( --disable-fit-to-screen )

It might be solution for this issue #659 (comment)

Test failed when I run ./ci/test.sh in my laptop, but it looks like not related to this change.
(I have no idea to fix it)

Copy link
Contributor

@gavin-ts gavin-ts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me but I wonder if we should have it inverted (--fit-to-screen / --fit) to enable as mentioned in #659. related discussion #601 (comment)
I also wonder if we could do the fitting with just css instead of js

@bluemir
Copy link
Author

bluemir commented Jan 30, 2023

I think the '--fit-to-screen' option is better, too.
so I change it.

main.go Outdated Show resolved Hide resolved
@gavin-ts
Copy link
Contributor

gavin-ts commented Jan 31, 2023

Since the default behavior no longer adds the js, the test svgs need to be updated with TESTDATA_ACCEPT=1 ./ci/test.sh see

@alixander
Copy link
Collaborator

hold off on this for a sec, need to think about this whole fit to screen thing

@alixander
Copy link
Collaborator

now that the resizing is done with CSS, i wonder if anyone would still want to turn this off. i'll leave this up for a little longer to wait and see, but i suspect that #725 solves all resizing woes.

This was referenced Feb 28, 2023
@gavin-ts
Copy link
Contributor

#1080

@alixander
Copy link
Collaborator

hey @bluemir sorry for the looong delay. had to see if anyone was still interested in this after a bunch of fixes. #1080 is motivating enough. do you still have interest in making this change? if so, perhaps it'd be easier to just start a new PR given all the merge conflicts.

bluemir and others added 3 commits March 23, 2023 11:13
Co-authored-by: gavin-ts <85081687+gavin-ts@users.noreply.github.com>
@bluemir bluemir force-pushed the add-option-disable-fit-to-screen branch from 0c4de64 to a9da41d Compare March 23, 2023 02:38
Comment on lines 1849 to 1851
if !opts.FitScreen {
fitScreenWrapper = ""
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be the same as setDimensions above now. setting dimensions disables the fit to screen behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also want to rename the option to --no-fit or --sized since we want the fit behavior as default now

d2cli/main.go Outdated
Comment on lines 424 to 425
SetDimensions: toPNG,
FitScreen: fitScreen,
NoFit: noFit,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since NoFit does the same thing as SetDimensions, I think it is better to just have SetDimensions: toPNG || noFit, without another RenderOpt

Comment on lines 1834 to 1836
if setDimensions && !opts.NoFit {
dimensions = fmt.Sprintf(` width="%d" height="%d"`, w, h)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I experimented with applying this change in a diagram and learned that it does not do what I expected. Please see the note here: #1080 (comment)

d2cli/watch.go Show resolved Hide resolved
Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bluemir if you want to fix the merge conflicts, we can get this merged, thank you!

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

Successfully merging this pull request may close these issues.

4 participants