fixes and lint

This commit is contained in:
Igor Lobanov 2022-11-10 13:50:47 +01:00
parent 31d837eca2
commit a169fc3b81
21 changed files with 75 additions and 76 deletions

2
public/icons/expand.svg Normal file
View File

@ -0,0 +1,2 @@
<svg width="20" height="13" viewBox="0 0 20 13" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 12.8999L0.100098 3L2.57507 0.525024L10.0002 7.95013L17.4246 0.525716L19.8996 3.00069L12.4747 10.4256L12.4745 10.4254L10 12.8999Z" fill="#000"/></svg>

After

Width:  |  Height:  |  Size: 259 B

View File

@ -61,7 +61,7 @@
padding-top: 1.6rem; padding-top: 1.6rem;
a { a {
color: rgba(255, 255, 255, 0.7); color: rgb(255 255 255 / 70%);
&:hover { &:hover {
color: #fff; color: #fff;

View File

@ -1,4 +1,4 @@
import { createSignal, onMount } from 'solid-js' import { createSignal } from 'solid-js'
import styles from './Subscribe.module.scss' import styles from './Subscribe.module.scss'
import { t } from '../../utils/intl' import { t } from '../../utils/intl'
import { clsx } from 'clsx' import { clsx } from 'clsx'

View File

@ -9,7 +9,6 @@ import { clsx } from 'clsx'
import styles from './Sidebar.module.scss' import styles from './Sidebar.module.scss'
import { useOutsideClickHandler } from '../../../utils/useOutsideClickHandler' import { useOutsideClickHandler } from '../../../utils/useOutsideClickHandler'
import { useEscKeyDownHandler } from '../../../utils/useEscKeyDownHandler' import { useEscKeyDownHandler } from '../../../utils/useEscKeyDownHandler'
import { hideModal } from '../../../stores/ui'
const Off = (props) => <div class={styles.sidebarOff}>{props.children}</div> const Off = (props) => <div class={styles.sidebarOff}>{props.children}</div>

View File

@ -1,21 +1,15 @@
import { createSignal, onMount } from 'solid-js' import { onMount } from 'solid-js'
import { EditorState, Transaction } from 'prosemirror-state' import { EditorState, Transaction } from 'prosemirror-state'
import { EditorView, MarkViewConstructor, NodeViewConstructor } from 'prosemirror-view' import { EditorView, MarkViewConstructor, NodeViewConstructor } from 'prosemirror-view'
import './prosemirror/styles/ProseMirror.scss' import './prosemirror/styles/ProseMirror.scss'
import type { Nodes, Marks } from './prosemirror/schema' import type { Nodes, Marks } from './prosemirror/schema'
import { createImageView } from './prosemirror/views/image' import { createImageView } from './prosemirror/views/image'
import { MarkdownSerializer } from 'prosemirror-markdown'
import { schema } from './prosemirror/schema' import { schema } from './prosemirror/schema'
import { createPlugins } from './prosemirror/plugins' import { createPlugins } from './prosemirror/plugins'
import debounce from 'lodash/debounce'
import { DOMSerializer } from 'prosemirror-model' import { DOMSerializer } from 'prosemirror-model'
import { clsx } from 'clsx' import { clsx } from 'clsx'
import styles from '../Nav/AuthModal/AuthModal.module.scss'
import { t } from '../../utils/intl'
import { apiClient } from '../../utils/apiClient'
import { createArticle } from '../../stores/zine/articles' import { createArticle } from '../../stores/zine/articles'
import type { InputMaybe, Scalars, ShoutInput } from '../../graphql/types.gen' import type { ShoutInput } from '../../graphql/types.gen'
import { Sidebar } from './Sidebar' import { Sidebar } from './Sidebar'
const htmlContainer = typeof document === 'undefined' ? null : document.createElement('div') const htmlContainer = typeof document === 'undefined' ? null : document.createElement('div')
@ -27,9 +21,6 @@ const getHtml = (state: EditorState) => {
} }
export const Editor = () => { export const Editor = () => {
const [markdown, setMarkdown] = createSignal('')
const [html, setHtml] = createSignal('')
const editorElRef: { const editorElRef: {
current: HTMLDivElement current: HTMLDivElement
} = { } = {
@ -38,19 +29,9 @@ export const Editor = () => {
const editorViewRef: { current: EditorView } = { current: null } const editorViewRef: { current: EditorView } = { current: null }
const update = (state: EditorState) => {
const newHtml = getHtml(state)
setHtml(newHtml)
// setMarkdown(state.toJSON())
// const el = document.createElement('div')
}
const debouncedUpdate = debounce(update, 500)
const dispatchTransaction = (tr: Transaction) => { const dispatchTransaction = (tr: Transaction) => {
const newState = editorViewRef.current.state.apply(tr) const newState = editorViewRef.current.state.apply(tr)
editorViewRef.current.updateState(newState) editorViewRef.current.updateState(newState)
debouncedUpdate(newState)
} }
onMount(async () => { onMount(async () => {
@ -88,12 +69,8 @@ export const Editor = () => {
<div class="container" style={{ display: 'flex' }}> <div class="container" style={{ display: 'flex' }}>
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<div ref={(el) => (editorElRef.current = el)} /> <div ref={(el) => (editorElRef.current = el)} />
<div>Markdown:</div>
<div>{markdown()}</div>
<div>HTML:</div>
<div>{html()}</div>
<button class={clsx('button')} onClick={handleSaveButtonClick}> <button class={clsx('button')} onClick={handleSaveButtonClick}>
Опубликовать Опубликовать WIP
</button> </button>
</div> </div>
<Sidebar editorViewRef={editorViewRef} /> <Sidebar editorViewRef={editorViewRef} />

View File

@ -1,4 +1,4 @@
import { For, Show, createEffect, createSignal, onCleanup, onMount } from 'solid-js' import { For, createEffect, createSignal, onCleanup, onMount } from 'solid-js'
import type { JSX } from 'solid-js' import type { JSX } from 'solid-js'
import { undo, redo } from 'prosemirror-history' import { undo, redo } from 'prosemirror-history'
import { clsx } from 'clsx' import { clsx } from 'clsx'

View File

@ -1,5 +1,3 @@
import { keymap } from 'prosemirror-keymap'
import { baseKeymap } from 'prosemirror-commands'
import { history } from 'prosemirror-history' import { history } from 'prosemirror-history'
import { dropCursor } from 'prosemirror-dropcursor' import { dropCursor } from 'prosemirror-dropcursor'
import { placeholder } from './placeholder' import { placeholder } from './placeholder'

View File

@ -12,6 +12,8 @@
} }
li { li {
margin-bottom: 1em;
&.top { &.top {
border-bottom: 1px solid #e1e1e1; border-bottom: 1px solid #e1e1e1;
display: flex; display: flex;

View File

@ -1,11 +1,12 @@
.modalwrap { .modalwrap {
pointer-events: all;
align-items: center; align-items: center;
background: rgb(20 20 20 / 70%); background: rgb(20 20 20 / 70%);
display: flex; display: flex;
justify-content: center; justify-content: center;
height: 100%; height: 100%;
left: 0; left: 0;
overflow: auto;
pointer-events: all;
position: fixed; position: fixed;
top: 0; top: 0;
width: 100%; width: 100%;

View File

@ -1,4 +1,4 @@
import { createEffect, createSignal, onCleanup, onMount, Show } from 'solid-js' import { createEffect, createSignal, Show } from 'solid-js'
import type { JSX } from 'solid-js' import type { JSX } from 'solid-js'
import { getLogger } from '../../utils/logger' import { getLogger } from '../../utils/logger'
import './Modal.scss' import './Modal.scss'

View File

@ -1,4 +1,4 @@
import { createEffect, createSignal, JSX, onCleanup, onMount, Show } from 'solid-js' import { createEffect, createSignal, JSX, Show } from 'solid-js'
import styles from './Popup.module.scss' import styles from './Popup.module.scss'
import { clsx } from 'clsx' import { clsx } from 'clsx'
import { useOutsideClickHandler } from '../../utils/useOutsideClickHandler' import { useOutsideClickHandler } from '../../utils/useOutsideClickHandler'

View File

@ -15,6 +15,7 @@ export default () => {
const author = createMemo<Author>(() => { const author = createMemo<Author>(() => {
const a: Author = { const a: Author = {
id: null,
name: 'anonymous', name: 'anonymous',
userpic: '', userpic: '',
slug: '' slug: ''

View File

@ -82,6 +82,7 @@
.topicDetailsItem { .topicDetailsItem {
@include font-size(1.5rem); @include font-size(1.5rem);
margin-right: 1.6rem; margin-right: 1.6rem;
white-space: nowrap; white-space: nowrap;

View File

@ -1,11 +1,19 @@
.topic__header { .topicHeader {
@include font-size(1.7rem); @include font-size(1.7rem);
padding-top: 5.8rem; padding-top: 5.8rem;
text-align: center; text-align: center;
h1 {
color: #2638d9;
font-weight: 500;
text-transform: uppercase;
@include font-size(2rem);
}
} }
.topic__actions { .topicActions {
margin-top: 2.8rem; margin-top: 2.8rem;
button, button,

View File

@ -1,10 +1,11 @@
import { createMemo, Show } from 'solid-js' import { createMemo, Show } from 'solid-js'
import type { Topic } from '../../graphql/types.gen' import type { Topic } from '../../graphql/types.gen'
import { FollowingEntity } from '../../graphql/types.gen' import { FollowingEntity } from '../../graphql/types.gen'
import './Full.scss' import styles from './Full.module.scss'
import { useAuthStore } from '../../stores/auth' import { useAuthStore } from '../../stores/auth'
import { follow, unfollow } from '../../stores/zine/common' import { follow, unfollow } from '../../stores/zine/common'
import { t } from '../../utils/intl' import { t } from '../../utils/intl'
import { clsx } from 'clsx'
type Props = { type Props = {
topic: Topic topic: Topic
@ -15,37 +16,35 @@ export const FullTopic = (props: Props) => {
const subscribed = createMemo(() => session()?.news?.topics?.includes(props.topic?.slug)) const subscribed = createMemo(() => session()?.news?.topics?.includes(props.topic?.slug))
return ( return (
<div class="topic-full container"> <div class={styles.topicFull}>
<div class="row"> <Show when={!!props.topic?.slug}>
<Show when={!!props.topic?.slug}> <div class={clsx(styles.topicHeader, 'col-md-8 offset-md-2')}>
<div class="topic__header col-md-8 offset-md-2"> <h1>#{props.topic.title}</h1>
<h1>#{props.topic.title}</h1> <p>{props.topic.body}</p>
<p>{props.topic.body}</p> <div class={clsx(styles.topicActions)}>
<div class="topic__actions"> <Show when={!subscribed()}>
<Show when={!subscribed()}> <button
<button onClick={() => follow({ what: FollowingEntity.Topic, slug: props.topic.slug })}
onClick={() => follow({ what: FollowingEntity.Topic, slug: props.topic.slug })} class="button"
class="button" >
> {t('Follow the topic')}
{t('Follow the topic')} </button>
</button>
</Show>
<Show when={subscribed()}>
<button
onClick={() => unfollow({ what: FollowingEntity.Topic, slug: props.topic.slug })}
class="button"
>
{t('Unfollow the topic')}
</button>
</Show>
<a href={`/create/${props.topic.slug}`}>{t('Write about the topic')}</a>
</div>
<Show when={props.topic.pic}>
<img src={props.topic.pic} alt={props.topic.title} />
</Show> </Show>
<Show when={subscribed()}>
<button
onClick={() => unfollow({ what: FollowingEntity.Topic, slug: props.topic.slug })}
class="button"
>
{t('Unfollow the topic')}
</button>
</Show>
<a href={`/create/${props.topic.slug}`}>{t('Write about the topic')}</a>
</div> </div>
</Show> <Show when={props.topic.pic}>
</div> <img src={props.topic.pic} alt={props.topic.title} />
</Show>
</div>
</Show>
</div> </div>
) )
} }

View File

@ -7,7 +7,6 @@ import { t } from '../../utils/intl'
import { useAuthorsStore } from '../../stores/zine/authors' import { useAuthorsStore } from '../../stores/zine/authors'
import { loadAuthorArticles, useArticlesStore } from '../../stores/zine/articles' import { loadAuthorArticles, useArticlesStore } from '../../stores/zine/articles'
import '../../styles/Topic.scss'
import { useTopicsStore } from '../../stores/zine/topics' import { useTopicsStore } from '../../stores/zine/topics'
import { useRouter } from '../../stores/router' import { useRouter } from '../../stores/router'
import { Beside } from '../Feed/Beside' import { Beside } from '../Feed/Beside'

View File

@ -3,7 +3,6 @@ import type { Shout, Topic } from '../../graphql/types.gen'
import { Row3 } from '../Feed/Row3' import { Row3 } from '../Feed/Row3'
import { Row2 } from '../Feed/Row2' import { Row2 } from '../Feed/Row2'
import { Beside } from '../Feed/Beside' import { Beside } from '../Feed/Beside'
import { ArticleCard } from '../Feed/Card'
import styles from '../../styles/Topic.module.scss' import styles from '../../styles/Topic.module.scss'
import { FullTopic } from '../Topic/Full' import { FullTopic } from '../Topic/Full'
import { t } from '../../utils/intl' import { t } from '../../utils/intl'

View File

@ -24,6 +24,7 @@ export type AuthResult = {
export type Author = { export type Author = {
bio?: Maybe<Scalars['String']> bio?: Maybe<Scalars['String']>
caption?: Maybe<Scalars['String']> caption?: Maybe<Scalars['String']>
id: Scalars['Int']
links?: Maybe<Array<Maybe<Scalars['String']>>> links?: Maybe<Array<Maybe<Scalars['String']>>>
name: Scalars['String'] name: Scalars['String']
slug: Scalars['String'] slug: Scalars['String']
@ -69,6 +70,7 @@ export type Collection = {
createdAt: Scalars['DateTime'] createdAt: Scalars['DateTime']
createdBy: User createdBy: User
desc?: Maybe<Scalars['String']> desc?: Maybe<Scalars['String']>
id: Scalars['Int']
publishedAt?: Maybe<Scalars['DateTime']> publishedAt?: Maybe<Scalars['DateTime']>
slug: Scalars['String'] slug: Scalars['String']
title: Scalars['String'] title: Scalars['String']
@ -84,6 +86,7 @@ export type Community = {
createdAt: Scalars['DateTime'] createdAt: Scalars['DateTime']
createdBy: User createdBy: User
desc?: Maybe<Scalars['String']> desc?: Maybe<Scalars['String']>
id: Scalars['Int']
name: Scalars['String'] name: Scalars['String']
pic: Scalars['String'] pic: Scalars['String']
slug: Scalars['String'] slug: Scalars['String']
@ -329,10 +332,12 @@ export type ProfileInput = {
export type Query = { export type Query = {
authorsAll: Array<Maybe<User>> authorsAll: Array<Maybe<User>>
collectionsAll: Array<Maybe<Collection>> collectionsAll: Array<Maybe<Collection>>
getAuthor: User
getCollabs: Array<Maybe<Collab>> getCollabs: Array<Maybe<Collab>>
getCommunities: Array<Maybe<Community>> getCommunities: Array<Maybe<Community>>
getCommunity: Community getCommunity: Community
getShoutBySlug: Shout getShoutBySlug: Shout
getTopic: Topic
getUserCollections: Array<Maybe<Collection>> getUserCollections: Array<Maybe<Collection>>
getUserRoles: Array<Maybe<Role>> getUserRoles: Array<Maybe<Role>>
getUsersBySlugs: Array<Maybe<User>> getUsersBySlugs: Array<Maybe<User>>
@ -371,6 +376,10 @@ export type Query = {
userReactedShouts: Array<Maybe<Shout>> userReactedShouts: Array<Maybe<Shout>>
} }
export type QueryGetAuthorArgs = {
slug: Scalars['String']
}
export type QueryGetCommunityArgs = { export type QueryGetCommunityArgs = {
slug?: InputMaybe<Scalars['String']> slug?: InputMaybe<Scalars['String']>
} }
@ -379,6 +388,10 @@ export type QueryGetShoutBySlugArgs = {
slug: Scalars['String'] slug: Scalars['String']
} }
export type QueryGetTopicArgs = {
slug: Scalars['String']
}
export type QueryGetUserCollectionsArgs = { export type QueryGetUserCollectionsArgs = {
author: Scalars['String'] author: Scalars['String']
} }

View File

@ -1,11 +1,11 @@
.topic-page { .topicPage {
.group__controls { .groupControls {
align-items: baseline; align-items: baseline;
margin-bottom: 4rem; margin-bottom: 4rem;
margin-top: 7rem; margin-top: 7rem;
} }
.floor--important { .floorImportant {
a:hover { a:hover {
background: #fff; background: #fff;
color: #000 !important; color: #000 !important;

View File

@ -487,7 +487,7 @@ figcaption {
a { a {
border-bottom: 2px solid #fff; border-bottom: 2px solid #fff;
color: rgba(0, 0, 0, 0.5); color: rgb(0 0 0 / 50%);
&:hover { &:hover {
color: #fff; color: #fff;
@ -746,7 +746,7 @@ details {
cursor: pointer; cursor: pointer;
margin-bottom: 0; margin-bottom: 0;
&:before { &::before {
content: ''; content: '';
background: url(/icons/expand.svg) no-repeat; background: url(/icons/expand.svg) no-repeat;
background-size: contain; background-size: contain;
@ -762,7 +762,7 @@ details {
} }
&[open] { &[open] {
h3:before { h3::before {
transform: rotate(180deg); transform: rotate(180deg);
} }
} }

View File

@ -17,7 +17,7 @@ export const useOutsideClickHandler = (options: Options) => {
return return
} }
options.handler() handler()
} }
onMount(() => { onMount(() => {