Skip to content

Commit

Permalink
Export hack for reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
jzempel committed Nov 10, 2020
1 parent b211357 commit a82f80c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
12 changes: 6 additions & 6 deletions packages/theming/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"index.cjs.js": {
"bundled": 22843,
"minified": 14373,
"gzipped": 5280
"bundled": 22854,
"minified": 14411,
"gzipped": 5292
},
"index.esm.js": {
"bundled": 21984,
"minified": 13592,
"gzipped": 5159,
"bundled": 21995,
"minified": 13630,
"gzipped": 5171,
"treeshaked": {
"rollup": {
"code": 3408,
Expand Down
3 changes: 1 addition & 2 deletions packages/theming/src/utils/arrowStyles.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import React from 'react';
import { render } from 'garden-test-utils';
import styled, { ThemeProps, DefaultTheme } from 'styled-components';
import { math } from 'polished';
import exponentialSymbols from 'polished/lib/math/presets/exponentialSymbols';
import arrowStyles, { ARROW_POSITION } from './arrowStyles';
import arrowStyles, { ARROW_POSITION, exponentialSymbols } from './arrowStyles';

interface IStyledDivProps extends ThemeProps<DefaultTheme> {
arrowPosition: ARROW_POSITION;
Expand Down
35 changes: 19 additions & 16 deletions packages/theming/src/utils/arrowStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ export type ARROW_OPTIONS = {
animationModifier?: string;
};

// Workaround for https://github.com/styled-components/polished/issues/550
export const exponentialSymbols = {
symbols: {
sqrt: {
func: {
symbol: 'sqrt',
f: (a: number) => Math.sqrt(a),
notation: 'func',
precedence: 0,
rightToLeft: 0,
argCount: 1
},
symbol: 'sqrt',
regSymbol: 'sqrt\\b'
}
}
};

const animationStyles = (position: ARROW_POSITION, modifier: string) => {
const property = position.split('-')[0];
/**
Expand Down Expand Up @@ -147,22 +165,7 @@ const positionStyles = (position: ARROW_POSITION, size: string, inset: string) =
export default function arrowStyles(position: ARROW_POSITION, options: ARROW_OPTIONS = {}) {
const size = options.size || '6px';
const inset = options.inset || '0';
const squareSize = math(`${size} * 2 / sqrt(2)`, {
symbols: {
sqrt: {
func: {
symbol: 'sqrt',
f: (a: number) => Math.sqrt(a),
notation: 'func',
precedence: 0,
rightToLeft: 0,
argCount: 1
},
symbol: 'sqrt',
regSymbol: 'sqrt\\b'
}
}
});
const squareSize = math(`${size} * 2 / sqrt(2)`, exponentialSymbols);

/**
* 1. Set base positioning for an element with an arrow.
Expand Down

0 comments on commit a82f80c

Please sign in to comment.