File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import styled from 'styled-components' ;
3
3
import { Link } from 'react-router-dom' ;
4
+ import { patterns } from '../static/patterns' ;
4
5
5
6
const StyledPatterns = styled . div `` ;
6
7
7
8
const PatternsList = ( ) => {
8
9
return (
9
10
< StyledPatterns >
10
11
< h1 > LIST OF PATTERNS</ h1 >
11
- < Link to = "/patterns/memento" > Memento</ Link >
12
- < Link to = "/patterns/singleton" > Singleton</ Link >
13
- < Link to = "/patterns/command" > Command</ Link >
12
+
13
+ < ul >
14
+ { patterns . map ( pattern => (
15
+ < li key = { pattern . id } >
16
+ < Link to = { `/patterns/${ pattern . id } ` } > { pattern . name } </ Link >
17
+ </ li >
18
+ ) ) }
19
+ </ ul >
14
20
</ StyledPatterns >
15
21
) ;
16
22
} ;
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import STRATEGY from './behavioral_strategy';
22
22
import TEMPLATE from './behavioral_template' ;
23
23
import VISITOR from './behavioral_visitor' ;
24
24
25
- const patterns = [
25
+ export const patterns = [
26
26
ABSTRACT_FACTORY ,
27
27
BUILDER ,
28
28
FACTORY ,
@@ -50,9 +50,10 @@ const patterns = [
50
50
VISITOR
51
51
] ;
52
52
53
- for ( let i = patterns . length - 1 ; i > 0 ; i -- ) {
53
+ const mixed = [ ...patterns ] ;
54
+ for ( let i = mixed . length - 1 ; i > 0 ; i -- ) {
54
55
const rand = Math . floor ( Math . random ( ) * ( i + 1 ) ) ;
55
- [ patterns [ i ] , patterns [ rand ] ] = [ patterns [ rand ] , patterns [ i ] ] ;
56
+ [ mixed [ i ] , mixed [ rand ] ] = [ mixed [ rand ] , mixed [ i ] ] ;
56
57
}
57
58
58
- export default patterns ;
59
+ export default mixed ;
You can’t perform that action at this time.
0 commit comments