Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

feat: use measure text #65

Merged
merged 5 commits into from
Sep 29, 2023
Merged

feat: use measure text #65

merged 5 commits into from
Sep 29, 2023

Conversation

cbt1
Copy link
Collaborator

@cbt1 cbt1 commented Sep 29, 2023

Use the same logic in both table and pivot table to measure text

@@ -4,3 +4,9 @@ export { default as useFetch } from './use-fetch';
export { default as useWaitForFonts } from './use-wait-for-fonts';
export { default as useReactRoot } from './use-react-root';
export { default as useExtendedTheme } from './use-extended-theme';
export {
default as useMeasureText,
type UseMeasureTextProps,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Might want to export types from a single location instead? Ex. src/types @a-m-dev

Copy link
Contributor

Choose a reason for hiding this comment

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

if you create a type file within use-measure-text folder (which will export all types within the scope of that hook + export everything from that type file from index file of use-measure-text) it will be bundled and also will be accessible through:

import useMeasureText, { your, types, here } from '@qlik/nebula-table-utils/lib/hooks/use-measure-text';

Currently this is the case for HeadCellMenu component as well (but it only exports the flag types from index file, in your case it will be export * from './types')

The reason behind it:
if you only wants to use the component -> you have two solutions:

  1. pull it from .../lib/components (which is the best case for only component use)
  2. be more explicit and pull it from index file of the component directory .../lib/componsnts/MYComponent (the optional way of importing component, but it has a purpose why it exists 👇)

In your case (+ head cell menu case as well) since we need some extra information from that component (take more types info for example) we have to be more explicit and call it directly from where it is located.

Alternate:
Of course you can import component from .../lib/components and for it's required types you can be more explicit and retrieve them from components index file, but that is optional (why have 2 lines of import when you can have one -> like HeadCellMenu import in PVT)

So having a global src/types is not a good idea since in terms of packaging (IMO) because then -> it might include all types from different modules/components/utils and it will ignore the scope of each of them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will keep it as it's then

@@ -4,3 +4,9 @@ export { default as useFetch } from './use-fetch';
export { default as useWaitForFonts } from './use-wait-for-fonts';
export { default as useReactRoot } from './use-react-root';
export { default as useExtendedTheme } from './use-extended-theme';
export {
default as useMeasureText,
type UseMeasureTextProps,
Copy link
Contributor

Choose a reason for hiding this comment

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

if you create a type file within use-measure-text folder (which will export all types within the scope of that hook + export everything from that type file from index file of use-measure-text) it will be bundled and also will be accessible through:

import useMeasureText, { your, types, here } from '@qlik/nebula-table-utils/lib/hooks/use-measure-text';

Currently this is the case for HeadCellMenu component as well (but it only exports the flag types from index file, in your case it will be export * from './types')

The reason behind it:
if you only wants to use the component -> you have two solutions:

  1. pull it from .../lib/components (which is the best case for only component use)
  2. be more explicit and pull it from index file of the component directory .../lib/componsnts/MYComponent (the optional way of importing component, but it has a purpose why it exists 👇)

In your case (+ head cell menu case as well) since we need some extra information from that component (take more types info for example) we have to be more explicit and call it directly from where it is located.

Alternate:
Of course you can import component from .../lib/components and for it's required types you can be more explicit and retrieve them from components index file, but that is optional (why have 2 lines of import when you can have one -> like HeadCellMenu import in PVT)

So having a global src/types is not a good idea since in terms of packaging (IMO) because then -> it might include all types from different modules/components/utils and it will ignore the scope of each of them.

@cbt1 cbt1 merged commit 33ed1df into main Sep 29, 2023
@cbt1 cbt1 deleted the cbt/feat/use-measure-text branch September 29, 2023 09:07
qlikossbuild pushed a commit that referenced this pull request Sep 29, 2023
# [2.4.0](v2.3.0...v2.4.0) (2023-09-29)

### Features

* use measure text ([#65](#65)) ([33ed1df](33ed1df))
@qlikossbuild
Copy link

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants