File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import React from 'react' ;
22import styled from 'styled-components' ;
33import { Link } from 'react-router-dom' ;
4+ import { patterns } from '../static/patterns' ;
45
56const StyledPatterns = styled . div `` ;
67
78const PatternsList = ( ) => {
89 return (
910 < StyledPatterns >
1011 < 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 >
1420 </ StyledPatterns >
1521 ) ;
1622} ;
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import STRATEGY from './behavioral_strategy';
2222import TEMPLATE from './behavioral_template' ;
2323import VISITOR from './behavioral_visitor' ;
2424
25- const patterns = [
25+ export const patterns = [
2626 ABSTRACT_FACTORY ,
2727 BUILDER ,
2828 FACTORY ,
@@ -50,9 +50,10 @@ const patterns = [
5050 VISITOR
5151] ;
5252
53- for ( let i = patterns . length - 1 ; i > 0 ; i -- ) {
53+ const mixed = [ ...patterns ] ;
54+ for ( let i = mixed . length - 1 ; i > 0 ; i -- ) {
5455 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 ] ] ;
5657}
5758
58- export default patterns ;
59+ export default mixed ;
You can’t perform that action at this time.
0 commit comments