Skip to content

Commit

Permalink
Merge pull request #1159 from data-for-change/dev
Browse files Browse the repository at this point in the history
merge dev into master
  • Loading branch information
atalyaalon authored Nov 3, 2024
2 parents 70f316d + 63cc5e4 commit 5d53c83
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/molecules/card/AnyWayCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const AnyWayCard: FC<IProps> = ({

const imgDownloadHandler = () => {
if (element && element instanceof HTMLElement) {
if (widgetType === CardType.Map) {
if (widgetType === CardType.MapAndDesigns) {
widgetToImageH2C(widgetName, element);
} else {
widgetToImageH2I(widgetName, element);
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/CardEditorDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const CardEditor: FC<IProps> = ({ isOpen, onClose, widgetName, text }) => {
const widgetType = getWidgetType(widgetName);
const imgDownloadHandler = () => {
if (cardElement && cardElement instanceof HTMLElement) {
if (widgetType === CardType.Map) {
if (widgetType === CardType.MapAndDesigns) {
widgetToImageH2C(widgetName, cardElement);
} else {
widgetToImageH2I(widgetName, cardElement);
Expand Down
4 changes: 2 additions & 2 deletions src/services/to-image.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { saveAs } from 'file-saver';
import * as htmlToImage from 'html-to-image';
import html2canvas from 'html2canvas';

const DEFAULT_SCALE = 3;
const DEFAULT_SCALE = 4;

const removeMapControllers = (el: Document) => {
const elementList = el.querySelectorAll(
Expand All @@ -16,7 +16,7 @@ export const widgetToImageH2I = (fileName: string, widgetElement: HTMLElement) =
};

// https://github.com/bubkoo/html-to-image
const usingHtml2Image = (fileName: string, widgetElement: HTMLElement, scale = DEFAULT_SCALE) => {
const usingHtml2Image = (fileName: string, widgetElement: HTMLElement) => {
const canvasWidth = 3300;
const canvasHeight = 3300;

Expand Down
11 changes: 8 additions & 3 deletions src/services/widgets.style.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export enum FooterVariant {

export enum CardType {
None,
Map,
MapAndDesigns,
}
export interface CardVariant {
header: HeaderVariant;
Expand Down Expand Up @@ -74,8 +74,13 @@ export function getWidgetVariant(widgetName: string) {

const widgetTypes: { [index: string]: CardType } = {
defaultType: CardType.None,
[WidgetName.most_severe_accidents]: CardType.Map ,
[WidgetName.accidents_heat_map]:CardType.Map,
[WidgetName.most_severe_accidents]: CardType.MapAndDesigns ,
[WidgetName.accidents_heat_map]:CardType.MapAndDesigns,
[WidgetName.injured_count_by_severity]:CardType.MapAndDesigns,
[WidgetName.accident_count_by_severity]:CardType.MapAndDesigns,
[WidgetName.vision_zero_2_plus_1]:CardType.MapAndDesigns,
[WidgetName.vision_zero_10_50_90]:CardType.MapAndDesigns,
[WidgetName.vision_zero_bike]:CardType.MapAndDesigns,
};

export function getWidgetType(widgetName: string) {
Expand Down

0 comments on commit 5d53c83

Please sign in to comment.