Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • intl-whitelabel-app

    • Task 1—Create feature flag

      • enable-resize-hero-component

    • Task 2—Create a method to resize hero component image

      • path: intl-whitelabel-app/workspaces/frontend/src/components/features/components/hero/hero-container.tsx

      • We will change the attribute objectFitContain on Picture component

      • before:

        Code Block
        languagetypescript
        const image = sanityImage && (
          <Picture image={sanityImage} alt={imageAlt} objectFitContain />
        );
      • after:

        Code Block
        languagetypescript
        const image = sanityImage && (
          <Picture image={sanityImage} alt={imageAlt} objectFitContain={false} />
        );
      • On file: intl-whitelabel-app/workspaces/frontend/src/components/picture/index.tsx, we will create a method to resize from hero image

        Code Block
        languagetypescript
        const resizeByHeight = useCallback(
          (img: ISanityImage | IImageFragment, sizeImage: { width: number; height: number }) => {
            const { dimensions } = parseAssetID(img?.asset?._id);
        
            const renderWidth = sizeImage.width;
            const renderHeight = Math.ceil(sizeImage.width * (dimensions.height / dimensions.width));
            setSize({ width: renderWidth, height: renderHeight });
          },
          []
        );
      • And on component return

      • before:

        Code Block
        languagetypescript
        return (
            <Measure
              innerRef={visibilityRef as any}
              onResize={contentRect => {
                if (isLoaded) {
                  return;
                }
        
                const newSize = {
                  width: Math.ceil(delve(contentRect, 'entry.width', 0)),
                  height: Math.ceil(delve(contentRect, 'entry.height', 0)),
                };
        
                if (newSize.width !== size.width || newSize.height !== size.height) {
                  setSize(newSize);
                }
              }}
            >
              {renderContent}
            </Measure>
          );
      • after:

        Code Block
        languagetypescript
        return (
          <Measure
            innerRef={visibilityRef as any}
            onResize={contentRect => {
              if (isLoaded) {
                return;
              }
        
              const newSize = {
                width: Math.ceil(delve(contentRect, 'entry.width', 0)),
                height: Math.ceil(delve(contentRect, 'entry.height', 0)),
              };
        
              if (!<FEATURE_FLAG> && (newSize.width !== size.width || newSize.height !== size.height)) {
                setSize(newSize);
              }
        
              if (<FEATURE_FLAG>) {
                resizeByHeight(image, newSize);
              }
            }}
          >
            {renderContent}
          </Measure>
        );
  • ctg-components-library

    • Task 3—Remove CSS attributes

      • path: ctg-components-library/src/components/hero/hero.styled.ts

        • Remove the value height on attribute ImageWrapper;

        • Remove the value height on @media ${mediaQuery.tablet};

        • Remove the value height on @media ${mediaQuery.desktopLarge};

...