Skip to content

Commit ed221e3

Browse files
committed
Replace tailwind.macro by twin.macro
1 parent 92b0052 commit ed221e3

37 files changed

+127
-107
lines changed

babel-plugin-macros.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
styledComponents: {},
3-
tailwind: {
4-
styled: 'styled-components',
3+
twin: {
4+
autoCssProp: true,
5+
preset: 'styled-components',
56
},
67
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
"react-window": "1.8.5",
8989
"styled-components": "5.1.1",
9090
"styled-tools": "1.7.2",
91-
"tailwind.macro": "1.0.0-alpha.10",
9291
"tailwindcss": "1.4.6",
92+
"twin.macro": "1.7.0",
9393
"typescript": "3.9.5",
9494
"wait-on": "5.0.1",
9595
"wretch": "1.7.2"

src/@types/tailwind.macro/index.d.ts

-17
This file was deleted.

src/@types/twin.macro/index.d.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import 'twin.macro'
2+
3+
import styledComponent, { css as CSSProperty, CSSProp } from 'styled-components'
4+
5+
declare module 'twin.macro' {
6+
const css: typeof CSSProperty
7+
const styled: typeof styledComponent
8+
}
9+
10+
declare module 'react' {
11+
interface HTMLAttributes<T> extends DOMAttributes<T> {
12+
css?: CSSProp
13+
}
14+
}
15+
16+
interface SVGProps<T> extends SVGAttributes<T> {
17+
css?: CSSProp
18+
}

src/components/App.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { observer } from 'mobx-react-lite'
22
import React, { useEffect } from 'react'
3-
import styled from 'styled-components/macro'
43
import { theme } from 'styled-tools'
5-
import tw from 'tailwind.macro'
4+
import tw, { styled } from 'twin.macro'
65

76
import { getDestination } from '../destinations'
87
import { getIpcRenderer, IpcRendererEvent } from '../main/ipc'
@@ -34,10 +33,7 @@ const Wrapper = styled.div`
3433
background-color: ${theme('window.background')};
3534
`
3635

37-
const Main = styled.div`
38-
${tw`flex-1 flex h-full overflow-y-hidden`}
39-
`
40-
36+
const Main = tw.div`flex-1 flex h-full overflow-y-hidden`
4137
const Content = tw.div`h-full flex-1 overflow-y-auto flex flex-col`
4238

4339
const App: React.FC = () => {

src/components/AppSideBar.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { observer } from 'mobx-react-lite'
22
import React from 'react'
3-
import styled from 'styled-components/macro'
43
import { ifProp, theme } from 'styled-tools'
5-
import tw from 'tailwind.macro'
4+
import tw, { styled } from 'twin.macro'
65

76
import { useApp } from '../store'
87
import { Panel } from '../store/app'

src/components/Button.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
3-
import tw from 'tailwind.macro'
2+
import tw, { styled } from 'twin.macro'
43

54
const StyledButton = styled.button`
65
&:focus {

src/components/Checkbox.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
32
import { ifProp, theme } from 'styled-tools'
4-
import tw from 'tailwind.macro'
3+
import tw, { styled } from 'twin.macro'
54

65
const Wrapper = styled.label<WrapperProps>`
76
${tw`block flex items-center relative`}
@@ -22,7 +21,10 @@ const Wrapper = styled.label<WrapperProps>`
2221
`}
2322
`
2423

25-
const Input = tw.input`mr-3 invisible`
24+
const Input = styled.input`
25+
${tw`mr-3 invisible`}
26+
`
27+
2628
const Label = tw.span`cursor-pointer`
2729

2830
const CheckMark = styled.span`

src/components/ColorSelect.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { lighten } from 'polished'
22
import React from 'react'
3-
import styled from 'styled-components/macro'
43
import { theme } from 'styled-tools'
5-
import tw from 'tailwind.macro'
4+
import tw, { styled } from 'twin.macro'
65

76
import Select from './Select'
87
import Svg from './Svg'

src/components/DeleteModal.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import 'styled-components/macro'
2-
31
import React, { useEffect, useState } from 'react'
4-
import tw from 'tailwind.macro'
2+
import tw from 'twin.macro'
53

64
import { getDestination } from '../destinations'
75
import { getIpcRenderer } from '../main/ipc'

src/components/Editor.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { observer } from 'mobx-react-lite'
22
import React, { useCallback, useEffect, useState } from 'react'
3-
import styled from 'styled-components/macro'
4-
import tw from 'tailwind.macro'
3+
import tw, { styled } from 'twin.macro'
54

65
import { getDestination } from '../destinations'
76
import type { DestinationId, ShareOptions, ShareOptionValue } from '../destinations/DestinationBase'

src/components/EditorInfoBar.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
3-
import tw from 'tailwind.macro'
2+
import tw, { styled } from 'twin.macro'
43

54
import ToolBar, { ToolbarLockedProps } from './ToolBar'
65

src/components/EditorToolBar.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { observer } from 'mobx-react-lite'
22
import React from 'react'
33
import { Tools } from 'react-sketch2'
4-
import styled from 'styled-components/macro'
5-
import tw from 'tailwind.macro'
4+
import tw, { styled } from 'twin.macro'
65

76
import { getDestination } from '../destinations'
87
import type { DestinationId, ShareOptions, ShareOptionSetter } from '../destinations/DestinationBase'

src/components/Icon.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
2+
import { styled } from 'twin.macro'
33

44
const Wrapper = styled.span.attrs({ className: 'icon' })`
55
font-family: 'SF Pro Display';

src/components/ImageEditor.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { useEffect, useMemo, useReducer, useRef, useState } from 'react'
22
import { SelectionCreatedEvent, SketchField, Tools } from 'react-sketch2'
3-
import styled from 'styled-components/macro'
43
import { theme } from 'styled-tools'
5-
import tw from 'tailwind.macro'
4+
import tw, { styled } from 'twin.macro'
65

76
import { useShortcut } from '../utils/keyboard'
87
import { usePrevious } from '../utils/react'

src/components/Library.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import 'styled-components/macro'
2-
31
import { observer } from 'mobx-react-lite'
42
import React from 'react'
5-
import tw from 'tailwind.macro'
3+
import tw from 'twin.macro'
64

75
import { useHistory } from '../store'
86
import { useShortcut } from '../utils/keyboard'

src/components/LibraryGrid.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { stripUnit } from 'polished'
33
import React from 'react'
44
import AutoSizer from 'react-virtualized-auto-sizer'
55
import { FixedSizeGrid, GridChildComponentProps } from 'react-window'
6-
import styled from 'styled-components/macro'
76
import { theme } from 'styled-tools'
8-
import tw from 'tailwind.macro'
7+
import tw, { styled } from 'twin.macro'
98

109
import { useHistory } from '../store'
1110
import type { HistoryEntry, SelectEntry } from '../store/history'

src/components/LibraryPanel.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import filesize from 'filesize'
22
import React from 'react'
33
import { CSSTransition } from 'react-transition-group'
4-
import styled from 'styled-components/macro'
54
import { theme } from 'styled-tools'
6-
import tw from 'tailwind.macro'
5+
import tw, { styled } from 'twin.macro'
76

87
import { getDestination } from '../destinations'
98
import { getIpcRenderer } from '../main/ipc'

src/components/LoadingBar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import styled, { keyframes } from 'styled-components/macro'
1+
import { keyframes } from 'styled-components/macro'
22
import { ifProp, theme } from 'styled-tools'
3-
import tw from 'tailwind.macro'
3+
import tw, { styled } from 'twin.macro'
44

55
const LoadingBarAnimation = keyframes`
66
0% {

src/components/Modal.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React, { useCallback, useRef, useState } from 'react'
22
import { createPortal } from 'react-dom'
33
import { CSSTransition } from 'react-transition-group'
4-
import styled from 'styled-components/macro'
54
import { ifProp, theme } from 'styled-tools'
6-
import tw from 'tailwind.macro'
5+
import tw, { styled } from 'twin.macro'
76

87
import { useShortcut } from '../utils/keyboard'
98
import { useOnClickOutside, usePortal } from '../utils/react'

src/components/Path.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
3-
import tw from 'tailwind.macro'
2+
import tw, { styled } from 'twin.macro'
43

54
import { getPathComponents } from '../utils/string'
65
import Icon, { IconSymbol } from './Icon'

src/components/Select.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { useSelect, UseSelectStateChange } from 'downshift'
22
import React from 'react'
3-
import styled from 'styled-components/macro'
43
import { ifProp, theme } from 'styled-tools'
5-
import tw from 'tailwind.macro'
4+
import tw, { styled } from 'twin.macro'
65

76
import Icon, { IconSymbol } from './Icon'
87

src/components/Settings.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import 'styled-components/macro'
2-
31
import { observer } from 'mobx-react-lite'
42
import React from 'react'
5-
import tw from 'tailwind.macro'
3+
import tw from 'twin.macro'
64

75
import { getDestinations } from '../destinations'
86
import { getIpcRenderer } from '../main/ipc'

src/components/SettingsPanel.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
3-
import tw from 'tailwind.macro'
2+
import tw, { styled } from 'twin.macro'
43

54
import type { DestinationSettingSetter, DestinationSettingsGetter } from '../destinations/DestinationBase'
65
import { Button, Group } from './SettingsUi'

src/components/SettingsSideBar.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { observer } from 'mobx-react-lite'
22
import React from 'react'
3-
import styled from 'styled-components/macro'
43
import { theme } from 'styled-tools'
5-
import tw from 'tailwind.macro'
4+
import tw, { styled } from 'twin.macro'
65

76
import { useApp } from '../store'
87
import { SettingsPanelId } from '../store/app'

src/components/SettingsUi.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
32
import { theme } from 'styled-tools'
4-
import tw from 'tailwind.macro'
3+
import tw, { styled } from 'twin.macro'
54

65
import Button from './Button'
76
import Path, { PathProps } from './Path'

src/components/Shortcut.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
32
import { theme } from 'styled-tools'
4-
import tw from 'tailwind.macro'
3+
import tw, { styled } from 'twin.macro'
54

65
import { parseShortcut } from '../utils/keyboard'
76
import type { ButtonProps } from './Button'

src/components/SideBar.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import clsx from 'clsx'
22
import React from 'react'
3-
import styled from 'styled-components/macro'
43
import { ifProp } from 'styled-tools'
5-
import tw from 'tailwind.macro'
4+
import tw, { styled } from 'twin.macro'
65

76
import Button from './Button'
87

src/components/Svg.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
32
import { prop } from 'styled-tools'
3+
import { styled } from 'twin.macro'
44

55
const Wrapper = styled.div<StyleProps>`
66
svg {

src/components/TitleBar.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { observer } from 'mobx-react-lite'
22
import React, { useState } from 'react'
3-
import styled from 'styled-components/macro'
43
import { ifProp, theme } from 'styled-tools'
5-
import tw from 'tailwind.macro'
4+
import tw, { styled } from 'twin.macro'
65

76
import { getIpcRenderer } from '../main/ipc'
87
import { useApp } from '../store'

src/components/TitleBarButton.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
32
import { theme } from 'styled-tools'
4-
import tw from 'tailwind.macro'
3+
import tw, { styled } from 'twin.macro'
54

65
import Button, { ButtonProps } from './Button'
76
import Icon, { IconSymbol } from './Icon'

src/components/ToolBar.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react'
2-
import styled from 'styled-components/macro'
32
import { ifProp, theme } from 'styled-tools'
4-
import tw from 'tailwind.macro'
3+
import tw, { styled } from 'twin.macro'
54

65
import type { DestinationSettingsGetter, ShareOptions, ShareOptionSetter } from '../destinations/DestinationBase'
76
import type Select from './Select'

src/components/ToolBarButton.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useCallback } from 'react'
2-
import styled from 'styled-components/macro'
32
import { theme } from 'styled-tools'
4-
import tw from 'tailwind.macro'
3+
import tw, { styled } from 'twin.macro'
54

65
import Button, { ButtonProps } from './Button'
76
import Icon, { IconSymbol } from './Icon'

src/index.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// Even tho `_types` looks unused, it is used to provide TS typings for the `css` prop through styled-components.
2-
// eslint-disable-next-line
3-
import * as _types from 'styled-components/cssprop'
4-
5-
import './styles.css'
1+
import 'tailwindcss/dist/base.min.css'
62

73
import React from 'react'
84
import ReactDOM from 'react-dom'

src/store/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { action, computed, observable } from 'mobx'
22
import { ignore } from 'mobx-sync'
33

4-
import { GeneralSettingsConfiguration } from '../components/GeneralSettings'
4+
// import { GeneralSettingsConfiguration } from '../components/GeneralSettings'
55
import { ShortcutsSettingConfiguration } from '../components/ShortcutsSettings'
66

77
/**

src/styles.css

-1
This file was deleted.

0 commit comments

Comments
 (0)