Skip to content

Commit

Permalink
style: linter auto-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshTheWanderer committed Jan 29, 2024
1 parent 4c54231 commit 01b53b2
Show file tree
Hide file tree
Showing 16 changed files with 249 additions and 228 deletions.
8 changes: 4 additions & 4 deletions example/next.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const withSourceMaps = require('@zeit/next-source-maps')()
const withSourceMaps = require('@zeit/next-source-maps')();

const isProd = (process.env.NODE_ENV || 'production') === 'production'
const isProd = (process.env.NODE_ENV || 'production') === 'production';

module.exports = withSourceMaps({
assetPrefix: isProd ? '/next-pagination' : undefined,
basePath: isProd ? '/next-pagination' : undefined
})
basePath: isProd ? '/next-pagination' : undefined,
});
6 changes: 3 additions & 3 deletions example/pages/[dynamic].js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import Pagination from '@etchteam/next-pagination/dist'
import Pagination from '@etchteam/next-pagination/dist';
import React from 'react';

export default function Dynamic() {
return (
Expand All @@ -13,5 +13,5 @@ export default function Dynamic() {

<Pagination total={1000} />
</main>
)
);
}
12 changes: 6 additions & 6 deletions example/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import Head from 'next/head'
import Head from 'next/head';
import React from 'react';

import '@etchteam/next-pagination/dist/index.css'
import '../styles/main.css'
import '@etchteam/next-pagination/dist/index.css';
import '../styles/main.css';

function MyApp({ Component, pageProps }) {
return (
Expand All @@ -12,7 +12,7 @@ function MyApp({ Component, pageProps }) {
</Head>
<Component {...pageProps} />
</div>
)
);
}

export default MyApp
export default MyApp;
17 changes: 8 additions & 9 deletions example/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react'
import Link from 'next/link'
import Pagination from '@etchteam/next-pagination/dist';
import Link from 'next/link';
import React from 'react';

import Pagination from '@etchteam/next-pagination/dist'

import theme from '../styles/theme.module.scss'
import theme from '../styles/theme.module.scss';

export default function Home() {
return (
Expand Down Expand Up @@ -52,16 +51,16 @@ export default function Home() {
<h2>Custom labels</h2>
<Pagination
total={1000}
perPageText='por página'
setPageSizeText='Establecer tamaño de página'
perPageText="por página"
setPageSizeText="Establecer tamaño de página"
/>

<h2>Other examples</h2>
<p>
<Link href='[dynamic]' as='dynamic-test'>
<Link href="[dynamic]" as="dynamic-test">
Dynamic pagination
</Link>
</p>
</main>
)
);
}
43 changes: 27 additions & 16 deletions example/styles/theme.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ $next-pagination-select-border-color-hover: $next-pagination-interative-color;
}

&__item {
border: $next-pagination-border-width solid $next-pagination-item-border-color;
border: $next-pagination-border-width solid
$next-pagination-item-border-color;
border-left-color: transparent;
display: none;
margin-right: -$next-pagination-border-width;
Expand All @@ -61,26 +62,31 @@ $next-pagination-select-border-color-hover: $next-pagination-interative-color;

&:first-child {
border-left-color: $next-pagination-item-border-color;
border-radius: $next-pagination-border-radius 0 0 $next-pagination-border-radius;
border-radius: $next-pagination-border-radius 0 0
$next-pagination-border-radius;

.next-pagination__link {
border-radius: $next-pagination-border-radius 0 0 $next-pagination-border-radius;
border-radius: $next-pagination-border-radius 0 0
$next-pagination-border-radius;
}
}

&:last-child {
border-radius: 0 $next-pagination-border-radius $next-pagination-border-radius 0;
border-radius: 0 $next-pagination-border-radius
$next-pagination-border-radius 0;
border-right-width: $next-pagination-border-width;
margin-right: 0;

.next-pagination__link {
border-radius: 0 $next-pagination-border-radius $next-pagination-border-radius 0;
border-radius: 0 $next-pagination-border-radius
$next-pagination-border-radius 0;
}
}

&--hellip {
min-width: 2.5em;
padding: $next-pagination-spacing-vertical-sm $next-pagination-spacing-horizontal-sm;
padding: $next-pagination-spacing-vertical-sm
$next-pagination-spacing-horizontal-sm;
text-align: center;
}
}
Expand All @@ -91,10 +97,11 @@ $next-pagination-select-border-color-hover: $next-pagination-interative-color;
display: block;
min-width: 2.5em;
outline: $next-pagination-border-width solid transparent;
padding: $next-pagination-spacing-vertical-sm $next-pagination-spacing-horizontal-sm;
padding: $next-pagination-spacing-vertical-sm
$next-pagination-spacing-horizontal-sm;
text-align: center;
text-decoration: none;
transition: outline-color .2s ease-in-out;
transition: outline-color 0.2s ease-in-out;

&:hover,
&:focus {
Expand Down Expand Up @@ -133,15 +140,16 @@ $next-pagination-select-border-color-hover: $next-pagination-interative-color;

&__select {
background-color: $next-pagination-select-background;
border: $next-pagination-border-width solid $next-pagination-select-border-color;
border: $next-pagination-border-width solid
$next-pagination-select-border-color;
border-radius: $next-pagination-border-radius;
color: inherit;
display: block;
font-size: 1em;
line-height: $next-pagination-line-height;
position: relative;
text-overflow: ellipsis;
transition: border-color .2s ease-in-out;
transition: border-color 0.2s ease-in-out;
width: 100%;

&:focus-within,
Expand All @@ -155,14 +163,18 @@ $next-pagination-select-border-color-hover: $next-pagination-interative-color;
background: transparent;
border: 0 none;
display: block;
height: calc(#{$next-pagination-spacing-vertical-sm * 2} + #{$next-pagination-line-height} + #{$next-pagination-border-width * 2});
font-size: 1em;
height: calc(
#{$next-pagination-spacing-vertical-sm * 2} + #{$next-pagination-line-height} +
#{$next-pagination-border-width * 2}
);
line-height: $next-pagination-line-height;
padding: $next-pagination-spacing-vertical-sm $next-pagination-spacing-horizontal-sm;
padding: $next-pagination-spacing-vertical-sm
$next-pagination-spacing-horizontal-sm;
padding-right: 2.5em;
text-indent: $next-pagination-spacing-horizontal-sm;
text-overflow: ellipsis;
transition: border-color .2s ease-in-out;
transition: border-color 0.2s ease-in-out;
width: 100%;
z-index: 1;

Expand All @@ -176,11 +188,11 @@ $next-pagination-select-border-color-hover: $next-pagination-interative-color;
}

&-suffix {
height: 100%;
pointer-events: none;
position: absolute;
right: 0;
top: 0;
height: 100%;
pointer-events: none;
width: 2em;

svg {
Expand Down Expand Up @@ -208,4 +220,3 @@ $next-pagination-select-border-color-hover: $next-pagination-interative-color;
width: 1px;
}
}

48 changes: 24 additions & 24 deletions src/components/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
import React from 'react'
import PropTypes from 'prop-types'
import PropTypes from 'prop-types';
import React from 'react';

// Icons from: https://material.io/resources/icons/?style=round

type IconName = 'chevron-left' | 'chevron-right' | 'expand-more'
type IconName = 'chevron-left' | 'chevron-right' | 'expand-more';

function path(icon: IconName) {
switch (icon) {
case 'chevron-left':
return (
<React.Fragment>
<path d='M0 0h24v24H0V0z' fill='none' />
<path d="M0 0h24v24H0V0z" fill="none" />
<path
fill='currentColor'
d='M14.71 6.71c-.39-.39-1.02-.39-1.41 0L8.71 11.3c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L10.83 12l3.88-3.88c.39-.39.38-1.03 0-1.41z'
fill="currentColor"
d="M14.71 6.71c-.39-.39-1.02-.39-1.41 0L8.71 11.3c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L10.83 12l3.88-3.88c.39-.39.38-1.03 0-1.41z"
/>
</React.Fragment>
)
);
case 'chevron-right':
return (
<React.Fragment>
<path d='M0 0h24v24H0V0z' fill='none' />
<path d="M0 0h24v24H0V0z" fill="none" />
<path
fill='currentColor'
d='M9.29 6.71c-.39.39-.39 1.02 0 1.41L13.17 12l-3.88 3.88c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41L10.7 6.7c-.38-.38-1.02-.38-1.41.01z'
fill="currentColor"
d="M9.29 6.71c-.39.39-.39 1.02 0 1.41L13.17 12l-3.88 3.88c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41L10.7 6.7c-.38-.38-1.02-.38-1.41.01z"
/>
</React.Fragment>
)
);
case 'expand-more':
return (
<React.Fragment>
<path d='M24 24H0V0h24v24z' fill='none' opacity='.87' />
<path d="M24 24H0V0h24v24z" fill="none" opacity=".87" />
<path
fill='currentColor'
d='M15.88 9.29L12 13.17 8.12 9.29c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0z'
fill="currentColor"
d="M15.88 9.29L12 13.17 8.12 9.29c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0z"
/>
</React.Fragment>
)
);
default:
return ''
return '';
}
}

export default function Icon({ icon }: { icon: IconName }) {
return (
<svg
className='next-pagination__icon'
aria-hidden='true'
viewBox='0 0 24 24'
width='24'
height='24'
className="next-pagination__icon"
aria-hidden="true"
viewBox="0 0 24 24"
width="24"
height="24"
>
{path(icon)}
</svg>
)
);
}

Icon.propTypes = {
icon: PropTypes.string.isRequired
}
icon: PropTypes.string.isRequired,
};
10 changes: 5 additions & 5 deletions src/components/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react'
import React from 'react';

interface ItemProps {
children: React.ReactNode
theme: { [key: string]: any }
[key: string]: any
readonly children: React.ReactNode;
readonly theme: { [key: string]: any };
[key: string]: any;
}

export default function Item({ children, theme }: ItemProps) {
return <li className={theme['next-pagination__item']}>{children}</li>
return <li className={theme['next-pagination__item']}>{children}</li>;
}
24 changes: 12 additions & 12 deletions src/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import React from 'react'
import classNames from 'classnames'
import classNames from 'classnames';
import React from 'react';

interface LinkProps {
children: React.ReactNode
label: string
theme: { [key: string]: any }
current?: boolean
disabled?: boolean
[key: string]: any
readonly children: React.ReactNode;
readonly label: string;
readonly theme: { [key: string]: any };
readonly current?: boolean;
readonly disabled?: boolean;
[key: string]: any;
}

export default class Link extends React.Component<LinkProps> {
render() {
const { children, current, disabled, label, theme, ...props } = this.props
const { children, current, disabled, label, theme, ...props } = this.props;
const cx = classNames(theme['next-pagination__link'], {
[`${theme['next-pagination__link--current']}`]: current,
[`${theme['next-pagination__link--disabled']}`]: disabled
})
[`${theme['next-pagination__link--disabled']}`]: disabled,
});

return (
<a className={cx} aria-label={label} aria-current={current} {...props}>
{children}
</a>
)
);
}
}
9 changes: 4 additions & 5 deletions src/components/List.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react'
import PropTypes from 'prop-types'
import React from 'react';

interface ListProps {
children: React.ReactNode
theme: { [key: string]: any }
readonly children: React.ReactNode;
readonly theme: { [key: string]: any };
}

export default function List({ children, theme }: ListProps) {
return <ul className={theme['next-pagination__list']}>{children}</ul>
return <ul className={theme['next-pagination__list']}>{children}</ul>;
}
18 changes: 9 additions & 9 deletions src/components/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React from 'react'
import PropTypes from 'prop-types'
import Icon from './Icon'
import React from 'react';

import Icon from './Icon';

interface SelectProps {
children: React.ReactNode
theme: { [key: string]: any }
[key: string]: any
readonly children: React.ReactNode;
readonly theme: { [key: string]: any };
[key: string]: any;
}

const Select = ({ children, theme, ...props }: SelectProps) => (
<div className={theme['next-pagination__select']}>
<select {...props}>{children}</select>
<span className={theme['next-pagination__select-suffix']}>
<Icon icon='expand-more' />
<Icon icon="expand-more" />
</span>
</div>
)
);

export default Select
export default Select;
2 changes: 1 addition & 1 deletion src/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
declare module '*.scss'
declare module '*.scss';
Loading

0 comments on commit 01b53b2

Please sign in to comment.