Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit76ac5ee

Browse files
authored
refactor(works-card): adjust style && re-org (#1055)
* refactor(works-cards): adjust style & idea* refactor(works-cards): extract to common Cards* test(cypress): skip shortcut test* fix(ci): remove videoCount && run migration before test
1 parent5b3821b commit76ac5ee

File tree

22 files changed

+270
-293
lines changed

22 files changed

+270
-293
lines changed

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
-name:(Backend) Install Packages
4343
working-directory:./backend_server
4444
run:mix deps.get > /dev/null
45+
-name:(Backend) run migration
46+
working-directory:./backend_server
47+
run:MIX_ENV=ci MIX_ENV=ci mix ecto.migrate > /dev/null
4548
-name:(Backend) set up test DB
4649
working-directory:./backend_server
4750
run:MIX_ENV=ci mix ecto.setup > /dev/null

‎cypress/integration/home/layout.spec.js‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@ describe('home page: ', () => {
3232
})
3333

3434
// TODO: modify keys not working ..
35-
it.skip('doramon Comp should close after shortcut pressed',()=>{
36-
// ctrl + C pressed
37-
cy.id('header-search').click()
38-
cy.id('doraemon-inputer').should('be.visible')
39-
cy.id('doraemon-inputer').type('{ctrl}C',{release:true})
40-
cy.id('doraemon-inputer').should('not.be.visible')
41-
42-
// ctrl + G pressed
43-
cy.id('header-search').click()
44-
cy.id('doraemon-inputer').should('be.visible')
45-
cy.id('doraemon-inputer').type('{ctrl}G')
46-
cy.id('doraemon-inputer').should('not.be.visible')
47-
48-
// esc pressed
49-
cy.id('header-search').click()
50-
cy.id('doraemon-inputer').should('be.visible')
51-
cy.id('doraemon-inputer').type('{esc}')
52-
cy.id('doraemon-inputer').should('not.be.visible')
53-
})
35+
//it.skip('doramon Comp should close after shortcut pressed', () => {
36+
// // ctrl + C pressed
37+
// cy.id('header-search').click()
38+
// cy.id('doraemon-inputer').should('be.visible')
39+
// cy.id('doraemon-inputer').type('{ctrl}C', { release: true })
40+
// cy.id('doraemon-inputer').should('not.be.visible')
41+
42+
// // ctrl + G pressed
43+
// cy.id('header-search').click()
44+
// cy.id('doraemon-inputer').should('be.visible')
45+
// cy.id('doraemon-inputer').type('{ctrl}G')
46+
// cy.id('doraemon-inputer').should('not.be.visible')
47+
48+
// // esc pressed
49+
// cy.id('header-search').click()
50+
// cy.id('doraemon-inputer').should('be.visible')
51+
// cy.id('doraemon-inputer').type('{esc}')
52+
// cy.id('doraemon-inputer').should('not.be.visible')
53+
//})
5454

5555
it('user-related area should be seen',()=>{
5656
cy.id('header-unlogin-user').should('be.visible')

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"test:dev":"cross-env NODE_ENV=test jest --config .jest.config.js",
2929
"test:watch":"npm run test -- --watch",
3030
"test:cover":"npm run test -- --coverage",
31-
"test:e2e":"cypress open",
31+
"test:e2e":"./node_modules/.bin/cypress open",
3232
"cy:run":"./node_modules/.bin/cypress run --key 60eb2dd7-724d-4b39-bd12-f434f3465866 --record",
3333
"cy:run:free":"./node_modules/.bin/cypress run",
3434
"test:ci":"start-server-and-test ci http://localhost:3000 cy:run:free",
@@ -153,7 +153,7 @@
153153
"bundlewatch":"^0.2.7",
154154
"commitizen":"3.1.2",
155155
"coveralls":"3.0.14",
156-
"cypress":"6.2.0",
156+
"cypress":"^7.0.0",
157157
"cz-conventional-changelog":"^3.0.0",
158158
"enzyme":"3.11.0",
159159
"enzyme-adapter-react-16":"1.15.2",

‎src/components/WorksCard/index.js‎renamed to ‎src/components/Cards/WorksCard.tsx‎

Lines changed: 33 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
*/
66

77
importReactfrom'react'
8-
importTfrom'prop-types'
98

109
import{ICON,ICON_CMD}from'@/config'
11-
import{buildLog,cutRest,nilOrEmpty}from'@/utils'
10+
import{buildLog,cutRest}from'@/utils'
1211

1312
importDigestSentencefrom'@/components/DigestSentence'
1413
import{SpaceGrow}from'@/components/Common'
@@ -28,36 +27,47 @@ import {
2827
TechIcon,
2928
Divider,
3029
GithubIcon,
31-
}from'./styles'
30+
}from'./styles/works_card'
3231

3332
/* eslint-disable-next-line */
3433
constlog=buildLog('c:WorksCard:index')
3534

36-
constgetSafeValue=(mode,value,defaultValue)=>{
37-
returnmode==='preview'&&nilOrEmpty(value) ?defaultValue :value
35+
typeTProps={
36+
testid?:string
37+
withBg?:boolean
38+
mode?:'default'|'preview'
39+
item:{
40+
cover:string
41+
title:string
42+
desc:string
43+
tag:{
44+
title:string
45+
}
46+
platform:{
47+
title:string
48+
}
49+
techStack:{
50+
icon:string
51+
raw:string
52+
}[]
53+
insertedAt:string
54+
upvote:number
55+
commentsCount:number
56+
isOSS:boolean
57+
ossAddr?:boolean
58+
}
3859
}
3960

40-
constWorksCard=({
41-
withBg,
42-
testid,
43-
mode,
61+
constWorksCard:React.FC<TProps>=({
62+
testid='works-card',
4463
item,
45-
defaultTitle,
46-
defaultDesc,
47-
defaultUpvote,
48-
defaultCommentsCount,
64+
withBg=false,
65+
mode='default',
66+
// item,
4967
})=>{
5068
constdescLimit=mode==='default' ?30 :20
5169

52-
consttitle=getSafeValue(mode,item.title,defaultTitle)
53-
constdesc=getSafeValue(mode,item.desc,defaultDesc)
54-
55-
constupvote=getSafeValue(mode,item.upvote,defaultUpvote)
56-
constcommentsCount=getSafeValue(
57-
mode,
58-
item.commentsCount,
59-
defaultCommentsCount,
60-
)
70+
const{ title, desc, upvote, commentsCount}=item
6171

6272
return(
6373
<Wrappertestid={testid}withBg={withBg}>
@@ -71,7 +81,7 @@ const WorksCard = ({
7181
<Header>
7282
<div>
7383
<Title>{title}</Title>
74-
<DigestSentencetop={5}bottom={15}>
84+
<DigestSentencetop={5}bottom={15}onPreview={()=>log}>
7585
{cutRest(desc,descLimit)}
7686
</DigestSentence>
7787
</div>
@@ -127,47 +137,4 @@ const WorksCard = ({
127137
)
128138
}
129139

130-
WorksCard.propTypes={
131-
testid:T.string,
132-
withBg:T.bool,
133-
mode:T.oneOf(['default','preview']),
134-
item:T.shape({
135-
cover:T.string,
136-
title:T.string,
137-
desc:T.string,
138-
tag:T.shape({
139-
title:T.string,
140-
}),
141-
platform:T.shape({
142-
title:T.string,
143-
}),
144-
techStack:T.arrayOf(
145-
T.shape({
146-
icon:T.string,
147-
}),
148-
),
149-
insertedAt:T.string,
150-
upvote:T.number,
151-
commentsCount:T.number,
152-
isOSS:T.bool,
153-
ossAddr:T.bool,
154-
}).isRequired,
155-
156-
defaultTitle:T.string,
157-
defaultDesc:T.string,
158-
defaultUpvote:T.number,
159-
defaultCommentsCount:T.number,
160-
}
161-
162-
WorksCard.defaultProps={
163-
testid:'works-card',
164-
withBg:false,
165-
mode:'default',
166-
defaultTitle:'作品名称',
167-
defaultDesc:'作品简介',
168-
defaultUpvote:99,
169-
defaultCommentsCount:66,
170-
// item,
171-
}
172-
173140
exportdefaultReact.memo(WorksCard)

‎src/components/WorksCard/styles/index.ts‎renamed to ‎src/components/Cards/styles/works_card.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,24 @@ export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({
1414
height: 118px;
1515
width: 100%;
1616
padding: 6px 20px;
17-
padding-right:25px;
18-
border-radius:8px;
17+
padding-right:15px;
18+
border-radius:3px;
1919
2020
border-bottom: 1px solid;
2121
border-bottom-color: #0b3b4a;
22+
border-left: 1px solid transparent;
23+
border-right: 1px solid transparent;
2224
2325
:last-child {
2426
border-bottom: none;
2527
}
26-
transition: all 0.25s;
28+
29+
&:hover {
30+
background: #0d3440;
31+
border-left-color: #0b3b4a;
32+
border-right-color: #0b3b4a;
33+
}
34+
transition: all 0.1s;
2735
`
2836
exportconstIntroImg=styled(Img)`
2937
${css.size(70)};

‎src/components/CommunityStatesPad/index.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ const CommunityStatesPad = ({
3636
editorsCount,
3737
subscribersCount,
3838
postsCount,
39-
videosCount,
4039
reposCount,
4140
jobsCount,
4241
viewerHasSubscribed,
4342
}=community
4443
const{ isMobile}=useDevice()
4544

46-
constcontentsCount=postsCount+videosCount+reposCount+jobsCount
45+
constcontentsCount=postsCount+reposCount+jobsCount
4746

4847
return(
4948
<Wrapper>
@@ -89,7 +88,6 @@ CommunityStatesPad.propTypes = {
8988
subscribersCount:T.number,
9089
editorsCount:T.number,
9190
postsCount:T.number,
92-
videosCount:T.number,
9391
reposCount:T.number,
9492
jobsCount:T.number,
9593
viewerHasSubscribed:T.bool,
@@ -104,7 +102,6 @@ CommunityStatesPad.defaultProps = {
104102
subscribersCount:0,
105103
editorsCount:0,
106104
postsCount:0,
107-
videosCount:0,
108105
reposCount:0,
109106
jobsCount:0,
110107
viewerHasSubscribed:false,

‎src/components/WorksCard/tests/index.test.ts‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎src/containers/content/WorksContent/Brand.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
importReactfrom'react'
22

3-
import{Wrapper,Title,Desc}from'./styles/brand'
3+
import{Wrapper,Title,Desc,Divider}from'./styles/brand'
44

55
typeTProps={
66
testid?:string
@@ -11,6 +11,7 @@ const Brand: React.FC<TProps> = ({ testid = 'works-content-brand' }) => {
1111
<Wrappertestid={testid}>
1212
<Title>作品集市</Title>
1313
<Desc>by makers, for makers.</Desc>
14+
<Divider/>
1415
</Wrapper>
1516
)
1617
}

‎src/containers/content/WorksContent/FilterBar.tsx‎

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,39 @@ import React from 'react'
33
import{mockNaviCatalogMenu}from'@/utils'
44

55
import{Br}from'@/components/Common'
6-
import{OrButton}from'@/components/Buttons'
7-
importFiltersMenufrom'@/components/FiltersMenu'
6+
// import FiltersMenu from '@/components/FiltersMenu'
87
importNaviCatalogfrom'@/components/NaviCatalog'
98

10-
import{VIEW}from'./constant'
9+
//import { VIEW } from './constant'
1110

12-
importfakeFilterItemsfrom'./fakeFilterItems'
11+
//import fakeFilterItems from './fakeFilterItems'
1312
import{Wrapper,FilterWrapper}from'./styles/filter_bar'
1413

15-
import{changeView}from'./logic'
14+
//import { changeView } from './logic'
1615

1716
typeTProps={
18-
activeView:string
17+
activeView?:string
1918
}
2019

2120
constFilterBar:React.FC<TProps>=({ activeView})=>{
2221
return(
2322
<Wrapper>
24-
<OrButton
25-
size="small"
26-
activeKey={activeView}
27-
group={[
28-
{
29-
key:VIEW.WORKS,
30-
title:'作品',
31-
},
32-
{
33-
key:VIEW.MILESTONE,
34-
title:'动态',// 里面再成 里程碑,和讨论
35-
},
36-
]}
37-
onClick={changeView}
38-
/>
39-
<Brbottom={30}/>
4023
<FilterWrapper>
4124
<NaviCatalog
4225
title="类别筛选"
4326
withDivider={false}
4427
items={mockNaviCatalogMenu()}
4528
/>
4629
</FilterWrapper>
47-
<Brbottom={40}/>
48-
<FilterWrapper>
30+
{/*<Br bottom={40} /> */}
31+
{/*<FilterWrapper>
4932
<FiltersMenu
5033
title="高级搜索"
5134
items={fakeFilterItems}
5235
withDivider
5336
revert
5437
/>
55-
</FilterWrapper>
38+
</FilterWrapper> */}
5639
</Wrapper>
5740
)
5841
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp