Add per viz-type card template sizes in x-rays (#38836) (#38884)
* Add per viz-type card template sizes in x-rays Previously, any card without a size (width or height) set in their yaml definition was set to a default of `default-card-width` or `default-card-width`, respectively. This PR adds a map of default and min dimensions per viz type (the `:display`) key and fills that in for each template. The template is merged into this result, keeping anything that already existed in the yaml file. Before merging this we should consider if we want to use the min values and where this data should be stored. It is currently in `metabase.automagic-dashboards.dashboard-templates`, but was lifted from [sizes.ts](https://github.com/metabase/metabase/blob/master/frontend/src/metabase/visualizations/shared/utils/sizes.ts ). * Moving card sizing constants to cljc The default card sizes were found in `sizes.ts` and were duplicated into `metabase.automagic-dashboards.dashboard-templates`. This PR consolidates those changes into `metabase.shared.automagic-dashboards.constants`. Note that @kulyk and @JesseSDevaney might want to consider further consolidation of dashboard related constants into this namespace. * Incorporating Feedback Changes - Explicitly defined two constants in the shared file that are clj and js friendly - Set case to CARD_SIZE_DEFAULTS_JSON - Updated `metabase.automagic-dashboards.dashboard-templates/set-default-card-dimensions` to use a helper * Update src/metabase/shared/automagic_dashboards/constants.cljc * Updating ns name per Jesse --------- Co-authored-by:Mark Bastian <markbastian@gmail.com> Co-authored-by:
Jesse Devaney <22608765+JesseSDevaney@users.noreply.github.com>
Showing
- frontend/src/metabase/visualizations/shared/utils/sizes.ts 3 additions, 91 deletionsfrontend/src/metabase/visualizations/shared/utils/sizes.ts
- shadow-cljs.edn 1 addition, 0 deletionsshadow-cljs.edn
- src/metabase/automagic_dashboards/dashboard_templates.clj 17 additions, 0 deletionssrc/metabase/automagic_dashboards/dashboard_templates.clj
- src/metabase/automagic_dashboards/populate.clj 2 additions, 2 deletionssrc/metabase/automagic_dashboards/populate.clj
- src/metabase/shared/dashboards/constants.cljc 34 additions, 0 deletionssrc/metabase/shared/dashboards/constants.cljc
Please register or sign in to comment