Skip to content

Conversation

itssharmasandeep
Copy link
Contributor

Description

This will give the flexibility to use custom dimensions for modal.
width/height can be set as expression as well - calc(100vw - 100px)

@itssharmasandeep itssharmasandeep requested a review from a team as a code owner August 25, 2021 15:27
@codecov
Copy link

codecov bot commented Aug 25, 2021

Codecov Report

Merging #1087 (f3dc565) into main (ada938a) will increase coverage by 0.01%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1087      +/-   ##
==========================================
+ Coverage   85.12%   85.13%   +0.01%     
==========================================
  Files         821      821              
  Lines       16965    16993      +28     
  Branches     2044     2056      +12     
==========================================
+ Hits        14441    14467      +26     
- Misses       2493     2495       +2     
  Partials       31       31              
Impacted Files Coverage Δ
projects/components/src/modal/modal.ts 90.00% <88.23%> (-10.00%) ⬇️
.../components/src/modal/modal-container.component.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ada938a...f3dc565. Read the comment docs.

@github-actions

This comment has been minimized.

content: TemplateRef<unknown> | Type<unknown>;
size?: ModalSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

it should only be size OR dimension right? can we put them into the same parameter (alternatively, using a union - but seems like overkill). Basically just size: ModalSize | ModalDimension

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we need to make these many changes. Can we follow the approach in with Sheet module. It has a responsive sheet size enum, can we build something similar here?

  &.sheet-size-responsive-extra-large {
    width: 100%;
  }

check hypertrace-ui/projects/components/src/overlay/sheet/sheet-overlay.component.ts

Copy link
Contributor

Choose a reason for hiding this comment

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

ofcourse, above class would have height: 100% as well and we would be setting 100% for width and height in popover trigger

Copy link
Contributor Author

Choose a reason for hiding this comment

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

&.sheet-size-responsive-extra-large {
width: 100%;
}

This is for full size , right?
But it is different from custom size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it should only be size OR dimension right? can we put them into the same parameter (alternatively, using a union - but seems like overkill). Basically just size: ModalSize | ModalDimension

For this, is there any way for us to check, value is type of ModalSize or ModalDimension

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, but can we do something similar and let the content size drive the modal size? Meaning, we shouldn't need to pass width/height as parameters, but can the modal adjust its size based on the content dom dimensions?

@anandtiwary
Copy link
Contributor

how come you so many merge commits in this branch? :P

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

content: TemplateRef<unknown> | Type<unknown>;
size: ModalSize | ModalDimension;
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm... this kind of makes the design weird. The same property is trying to do two things.

What if, we introduce a new enum in ModalSize called CustomSize and then add another optional property for dimension inputs? Then we can keep the code cleaner.

Alternatively, the config itself can change for custom size.

@aaron-steinfeld thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree. It's serving the same role in either case - a way to specify the size. Every other option is the same, so it doesn't make sense to have two versions of the config or an optional property (since the optional property is meaningless depending on the enum value). This is the beauty of unions - it's a strictly easier API for the caller to work with. Any messiness is internal to the implementation, and disambiguating between types should really just be a one liner.

Copy link
Contributor

Choose a reason for hiding this comment

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

fine. I don't have strong feelings. I find it weird when we put type based logic in the code. IMO, keeping separate properties makes it cleaner from API perspective. But it is a preference

@github-actions

This comment has been minimized.

@@ -19,6 +19,33 @@ export const enum ModalSize {
MediumWide = 'medium-wide'
}

export interface ModalDimension {
// Number => without unit (considered px) and String => with units (expression included)
width: number | string;
Copy link
Contributor

@anandtiwary anandtiwary Aug 30, 2021

Choose a reason for hiding this comment

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

What if I pass a random string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean, it won't work at that time. And I think this should be the case. Like suppose if we do this in the css (putting wrong value for width), then it doesn't work. So It is developer's responsibility to put correct value and I think developer can handle this.

Copy link
Contributor

@aaron-steinfeld aaron-steinfeld Aug 31, 2021

Choose a reason for hiding this comment

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

If you want to get really fancy, TS supports this kind of thing now. I'd also be fine just taking in any string, we don't validate to nearly this level elsewhere.

type Unit = "px" | "em" | "fr" | "%"; // probably some others too

type SizeWithUnit = `${number}${Unit}`;

Copy link
Contributor

Choose a reason for hiding this comment

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

in action:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we could do this, but my intention of using string, to use these kind of expression as well, not only simple units - calc(100vh - 100px)

Copy link
Contributor

Choose a reason for hiding this comment

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

type SizeExpression = SizeWithUnit | `calc(${SizeWithUnit} - ${SizeWithUnit})`

Typescript type system is turing complete 😉

But seriously, yes I agree, overkill.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah!!!

Copy link
Contributor

Choose a reason for hiding this comment

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

I will let you guys decide :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to me, It is good enough and as @aaron-steinfeld said doing this, is an overkill.
I think we can merge this.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@itssharmasandeep itssharmasandeep merged commit 8c3fc8e into main Sep 1, 2021
@itssharmasandeep itssharmasandeep deleted the custom-modal-dimension branch September 1, 2021 17:24
@github-actions
Copy link

github-actions bot commented Sep 1, 2021

Unit Test Results

    4 files  ±0  265 suites  ±0   18m 2s ⏱️ +36s
957 tests +6  957 ✔️ +6  0 💤 ±0  0 ❌ ±0 
964 runs  +6  964 ✔️ +6  0 💤 ±0  0 ❌ ±0 

Results for commit 8c3fc8e. ± Comparison against base commit ada938a.

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