ãããŠããã®ãããªããããã¯ãè€éã§ãã¯ã¬ã€ãžãŒã§ãããéåžžã«æ¥œãããã¯ãããžãŒã®äžçã§éåžžã«ããèµ·ãããŸãã ç§ã®ç¹å®ã®ã±ãŒã¹ã§ã¯ãWebéçºã®äžçã§ã
æšæ¥ã¯JQã§ããã ãŸãã圌女ã®ç¥ã«åœ¹ç«ã€å°ããªãã®ã ããããå°é家ã¯JQãJavaScriptã®äžéšã§ãããããããªããšã€ãã³ããããŒãã«ãã€ã³ãããããšã¯å®å šã«äžå¯èœã§ãããšå¿ããä¿¡ãå§ããŸããïŒèŽè¡ã®ããããïŒã¯ãã¹ãã©ãŠã¶ã®äºææ§ãcssssã«ããã€ãã®åé¡ãããããïŒã ãããŠã寺é¢ãåããæäŒã建èšããå§ããJQã¯ç§ãã¡ã®çœªäººãã¢ã€ã³ã³ããçºãå§ããŸããããããŠãæ¬ã¯ãProgramming JQueryãïŒJQãprogrammingããKarlïŒïŒãšããååã§æžãããŸããã
ãããŠæšæ¥ã¯AngularJSã§ããã ãããŠã圌ã¯åœŒã®åŸãã«ç«ã£ãŠããã®ã§ã圌ã¯çŽ æŽãããã£ã...ããã圌èªèº«ãç«ã£ãŠããŸãã
ãããŠä»æ¥ã¯ReactJSã§ãã äžè¬çã«ãç§ãã¡ã®ãã¹ãŠã ãªãã§ïŒ DOMãžã®çŽæ¥ã¢ã¯ã»ã¹ã«åããŠãããããããã¯æ£ããããã§ãã ãªãã§ïŒ ãããŠãDOMã«ã¢ã¯ã»ã¹ããã®ã¯ééã£ãŠããããã§ãïŒ ãªãã§ïŒ ç·ã®åãwïŒpooã«è¡ããŸãïŒ
ãããããã¬ã³ãºãããã«ã€ããŠèããªãã§ãã ãã-ç§ã¯ããããŸã£ããæã£ãŠããŸãã-ç§ãä¿¡ããŠãç§ã¯ãã€ã€ã«ãã£ã³ã³ãã¹ãã§è³ãåè³ããŸããã ãŸãã«ãã¹ãŠã«ãã®å Žæãšç®çããããŸãã ã¿ã³ã¯ããæã¡ãããšããããããšããããšã¯ãã©ããããããæ·±å»ã§ã¯ãããŸããã ããããããæç¹ã§ããããæ£ç¢ºã«éå§ããJavaScriptã®ååã®ã¡ã¬ãã€ããåçŽãªãããžã§ã¯ãïŒTypeScriptã®ãœãŒã¹ã³ãŒãã䜿çšããŠãJSã«æžã蟌ã¿ãããããçç±ããèããªããã-çãã¯äžã®æ®µèœã§ããïŒ
ReactJSã¯æ¬åœã«çŽ æŽããããã®ã§ãã ãããŠã
ãã®éãç§ã¯ããŒã ã§å¹žéã§ããã ãããŠã以åã®æçš¿ã§ãã§ã«è¿°ã¹ãããã«ãç§ã¯åçŽãªãã³ãã¬ãŒããšã³ãžã³ã䞊è¡ããŠéçºããããšãèš±å¯ãããŸããã ãã®ç¹ã§äŒç€Ÿã¯ç¬èªã®çŽç²ã«å©å·±çãªå©çãæã£ãŠããããšãæããŠãããŸããïŒã
äžè¬ã«ã圌ã®æåã®å ¬éãã€ãŸã5ãæåŸããããã³ãã¬ãŒããšã³ãžã³ã¯å€§å¹ ã«å€æŽãããŸããã ãã®ã¡ã¢ã®å 容ïŒå¯Ÿè±¡èªè ã®è©±é¡ïŒæèŠãäžèŽããŸãããããã¯ReactJSã«ã€ããŠã§ã¯ãªããAngularã«ã€ããŠãã§ãïŒã åŸ ã£ãŠïŒ ãReactããšããèšèãäœåºŠãééããªãèšããŸãã
ãã®ããã è¡ãããäž»ãªããšã¯ã䞊åãããžã§ã¯ãã®å€§ããªããŒã«ã§ãã çŸåšã1ã€ã®ïŒããªã倧ããªïŒã©ã€ãã©ãªãçµåãããŠããŸãã
- ã¢ããã°RequireJS
- ãªãœãŒã¹ããŒããŒïŒCSSãã¡ã€ã«ãªã©ïŒ
- ãã£ãã·ã¥ã³ã³ãããŒã©ãŒ
- åºæ¬çãªæ©èœïŒAJAXãªã¯ãšã¹ããDOMãæäœããããã®ããŒã«ãCSSãªã©ïŒ
- ããŠããã³ãã¬ãŒããšã³ãžã³ãããã¯åœŒã«ã€ããŠã§ã
決ããŠä¹Ÿããã€ãŸããªããã®ã®å±±ã§ããªããéå±ãããã€ããã¯ãããŸãããããããäœã§ãããã瀺ãããã«ãåçŽãªäŸã®ãã«ããã«ãã ããäžããŸãã
ããšãã°ãå¹³å¡ãªããŒãã«ãå¿ èŠã§ãã ãŸããJSONã§ããŒã¿ãåºåããç¹å®ã®APIããããŸãã ãã³ãã¬ãŒãã䜿çšããŠå¥åã®HTMLãã¡ã€ã«ãååŸããŠæç»ããŸãã ãããŠãå¿ èŠãªã¹ã¿ã€ã«ãæ·»ä»ããããšãå¿ããªãã§ãã ããã
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Flex.Template</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="pattern.css" /> </head> <body> <table data-type="Demo.Table"> <tr> <th>{{titles.column_0}}</th> <th>{{titles.column_1}}</th> <th>{{titles.column_2}}</th> <th>{{titles.column_3}}</th> </tr> <tr {{[rows]}}> <td>{{column_0}}</td> <td>{{column_1}}</td> <td>{{column_2}}</td> <td>{{column_3}}</td> </tr> </table> </body> </html>
ãããå¿ èŠãªå Žåããã³ãã¬ãŒããã¬ã³ããªã³ã°ããŸã
_patterns.get({ // url : '/components/table.simple/component.html', // "" node : document.body, // hooks : { titles : { column_0: 'Column #0', column_1: 'Column #1', column_2: 'Column #2', column_3: 'Column #3', }, // rows: _patterns.url('/examples/json/table.json') }, }).render();
ããã ãã§ããå®éïŒçµæã¯ããã«ãããŸãïŒã ãããŠãç¹ã«çŽ æŽãããã®ã¯ããã³ãã¬ãŒããããŒã«ã«ã§éããŠãïŒç©ããã§ããã£ãããšãæ°ãæ£ããããšãªãïŒã¹ã¿ã€ã«ããããã°ã§ããããšã§ããããã¯ãå¹³å¡ãªHTMLããŒãžãããããã§ãã
ãã¡ãããããŒã¿ãšãã³ãå ¥åã§ããŸãã
var data_source = []; for (var i = 0; i < 100; i += 1) { data_source.push({ column_0: (Math.random() * 1000).toFixed(4), column_1: (Math.random() * 1000).toFixed(4), column_2: (Math.random() * 1000).toFixed(4), column_3: (Math.random() * 1000).toFixed(4), }); } _patterns.get({ url : '/patterns/table/single/pattern.html', node : document.body, hooks : { titles: { column_0: 'Column #0', column_1: 'Column #1', column_2: 'Column #2', column_3: 'Column #3', }, rows: data_source } }).render();
ãããŠãããªãã¯ãããããŒã¯ã¢ããã«çŽæ¥æŒã蟌ãããšãã§ããŸã-äž»ãªãã®ã¯æããããšãªã®ã§ãäœãçŠæ¢ãããŠããŸããã
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!--BEGIN: Patterns definitions--> <link rel="pattern" name="my_table" src="/html/table/template.html" data-hooks="rows, c_0, c_1, c_2, c_3" /> <!--END: Patterns definitions--> </head> <body> <my_table> <rows> <c_0>0.0</c_0> <c_1>0.1</c_1> <c_2>0.2</c_2> <c_3>0.3</c_3> <c_0>1.0</c_0> <c_1>1.1</c_1> <c_2>1.2</c_2> <c_3>1.3</c_3> <c_0>2.0</c_0> <c_1>2.1</c_1> <c_2>2.2</c_2> <c_3>2.3</c_3> <c_0>3.0</c_0> <c_1>3.1</c_1> <c_2>3.2</c_2> <c_3>3.3</c_3> <c_0>4.0</c_0> <c_1>4.1</c_1> <c_2>4.2</c_2> <c_3>4.3</c_3> </rows> </my_table> </body>
ããŒã¯ã¢ããã䜿çšãããšãäžè¬çã«éåžžã«äŸ¿å©ãªããšãã§ããŸãã ããšãã°ã次ã®ãããªéåžžã«éèŠãªã¿ãã®ã³ã¬ã¯ã·ã§ã³ããããŸãã
<div class="tabs-container"> <div class="tabs-buttons"> <a class="tab-button">Tab 0</a> <a class="tab-button">Tab 1</a> <a class="tab-button">Tab 2</a> </div> <div class="tabs-content"> <div class="tab-content"> <p class="tab-content">Tab content 0</p> </div> <div class="tab-content"> <p class="tab-content">Tab content 1</p> </div> <div class="tab-content"> <p class="tab-content">Tab content 2</p> </div> </div> </div>
ããããã³ãã¬ãŒããã€ãŸãå¥ã®HTMLãã¡ã€ã«ã«é 眮ããŸãã
<div class="tabs-container"> <div class="tabs-buttons"> <a class="tab-button" {{[buttons]}} onclick="{{@onClick}}">{{button}}</a> </div> <div class="tabs-content"> <div class="tab-content" {{[tabs]}}>{{tab}}</div> </div> </div>
ãã®ãã³ãã¬ãŒãã䜿çšããããŒã¯ã¢ããïŒããŒãžäžïŒã§ã次ã®ããšãã§ããŸãã
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!--BEGIN: Patterns definitions--> <link rel="pattern" name="tabs" src="/html/tabs/template.html" data-hooks="buttons, tabs, button, tab" /> <!--END: Patterns definitions--> </head> <body> <tabs> <buttons> <button>Tab 0</button> <button>Tab 2</button> <button>Tab 3</button> </buttons> <tabs> <tab><p>Content of tab 0</p></tab> <tab><p>Content of tab 1</p></tab> <tab><p>Content of tab 2</p></tab> </tabs> </tabs> </body>
ãŸããçŽæçã«èªã¿ããããç解ããããã§ãã ããã¢ãŒã·ã§ã³ãµã€ãã®ã¿ãã¯å®éã«è¡ãããŸãã
çŸããã¯ããã³ãã¬ãŒãããã¹ãŠã¯ã©ã€ã¢ã³ãäžã§ããŒã«ã«ã«ä¿åãããããšã§ã ã ã€ãŸããããŒãžããªããŒãããããšããã®ããŒãžèªäœã®ã¬ã€ã¢ãŠãã®äžéšã¯åã«ããŒãããããã¯ã©ã€ã¢ã³ãããååŸãããŸãã ããã¯ãJSãCSSãã¡ã€ã«ãªã©ã®ãªãœãŒã¹ã«ãåœãŠã¯ãŸããŸãã å®éšãšããŠã®ã¿ãããŒãžãå®å šã«ãã£ãã·ã¥ããæ©èœããããŸããããããã¯åãªãå®éšã§ãã
ãã¡ããããã³ãã¬ãŒãçšã«ç¬èªã®ã³ã³ãããŒã©ãŒãäœæããããã€ãã®æ©èœãä»äžããããšãã§ããŸãã ãã³ãã¬ãŒãå ã®å€ããã©ã€ããå€æŽã§ããŸãïŒè¡šã®äŸã§ã¯ãã»ã«ã®å€ãå€æŽããŸãïŒã ã¢ãã«ãã€ãã³ãïŒç¢ºãã«æšæºïŒããããŸãã ãããŠãã¡ããããåç¥ã®ããã«DOMã«ã¢ã¯ã»ã¹ããŠæ¥œããããšãã§ããŸãã
å€ãã®ããšãããã§è¡ãããšãã§ããŸãã ããã§èªãããšã¯çŠæ¢ãããŠããŸããïŒãããèªç±ãªæéãããã°ïŒã
ãã ããéçºäžã«Flex-Patternã«èšå®ãããèŠä»¶ã«åå¥ã«æ³šæããŸããããã¯ããã®äœ¿çšã®å¯èœæ§ãéšåçã«åæ ããŠããŸãã
- æåã§æãéèŠãªã®ã¯æšæºHTMLã®ã¿ã§ãããçŸåšã®JSæšæºã®ã¿ã§ãã ã€ãŸãããã³ãã¬ãŒãã¯HTMLãã¡ã€ã«ã§ãããããªãªãŒã«ã§ã¯ãããŸããã
- ããã¯ã¯ãªãŒã³ãªããã³ããšã³ããœãªã¥ãŒã·ã§ã³ã§ããããã³ãã¬ãŒãã¯ã¬ã€ã¢ãŠãã«ããŠã³ãã§ããŸãããFlex-Patternã¯ãµãŒããŒãœãªã¥ãŒã·ã§ã³ã§ã¯ãªãã¯ã©ã€ã¢ã³ããœãªã¥ãŒã·ã§ã³ã§ãã
- äœãããå®å šã«ç¬ç«ã Flex-Patternã ããæ¥ç¶ããŠäœæ¥ãéå§ããè¿œå ã®åºæ¬æ©èœïŒåè¿°ïŒãååŸããã ãã§ååã§ãã
å®éããããã¯ã¢ã€ãã¢ã®å ã«ãªã£ãŠãã3ã€ã®ã¯ãžã©ã§ãã
ç¹°ãè¿ããŸãããReactã«ã€ããŠïŒçŽæããŸããïŒãååã¯åœŒãšæ¯èŒããããã®å€ãã®åç §ãšããªã¯ãšã¹ããããããŸãããããããã¯ééã«ããŽãªãç°ãªãããæ¯èŒãããŸããã éãã«ã€ããŠã®ã¿èª¬æããŸãã
- Reactã«
ã¯ãè¿œå ã®ç°å¢ã§ïŒéåžžã®å¿«é©ãªäœæ¥ã®ããã«ïŒå€æ°ã®ä¿å®èŠå¡ãå¿ èŠã§ãã Flex-Patternsã¯å®å šã«èªçµŠèªè¶³ã§ãïŒã¢ãžã¥ãŒã«ãäœæããæ©èœãšã¯å¥ã«ãJQã®ãããªåºæ¬çãªæ©èœã®ååšã«ãä»ã®å©ç¹ããããŸãïŒ-ããã¯ã¢ããããŠåäœããŸãã
- Reactã¯npmã«æ
£ããŠãããFlex-Patternsã¯ãããäœã§ãããããç¥ããŸããã
- Reactã¯HTMLã«äŒŒããã®ã䜿çšããŸãããHTMLã¯äœ¿çšããŸããã Flex-Patternsã¯HTMLã®ã¿ã§ãããdefaultValueã®ç¥èã¯å¿
èŠãããŸããã
- Reactå
šäœã¯ãéçºè
ã«å¯ŸããŠããªãäžä¿¡æãæ±ããŠãããå€ãã®ç¹ã§å¶éãããŠããŸãïŒããããå©ç¹ããããŸãïŒã Flex-Patternsã¯ãããŒãž
ã«æ¥ç¶ãããŠããã·ã§ã«ãä¿è·ãã人ãå®å šã«ä¿¡é ŒããŸãã
- Reactã¯ããé«éã«åäœããŸãã Flex-Patternsã¯å
šäœãšããŠ25ã35ïŒ
é
ããªããŸãããReact 100ã®ã¬ã³ããªã³ã°é床ã120ããªç§ã§ããå°ããªãã¿ãŒã³ïŒããšãã°ã1000è¡ã®ããŒãã«ïŒã§ãé¡èãã§ããFlex-Patterns150ã®ã¬ã³ããªã³ã°é床ã¯200ããªç§ã§ãã 巚倧ãªãªããžã§ã¯ãïŒ10,000è¡ã®ããŒãã«ãªã©ïŒã«ã€ããŠè©±ãå Žåãçµæã¯ã»ãšãã©åãã§ãã
- èšæ¶ã¯äž¡æ¹ãšãé£ãåã£ãŠããŸãã
- Reactã¯ããŒã¯ã¢ãããšããžãã¯ãã劚害ãããŸãããFlex-Patternsã¯ç©æ¥µçã«ãããåå²ããŠãã¡ã€ã«ã®åšãã«åæ£ããïŒäžå¿«ã«æãããããããŸããïŒãHTMLå
ã®ã³ãŒããåé¿ããããšããŸãã
- Reactã¯ãã©ãŠã¶ãŒã®ãã£ãã·ã¥ãä¿¡é ŒããFlex-Patternsã¯ãã¿ãŒã³ãã²ããããã£ãã·ã¥ããŸãã
- Reactã¯ãå°ããå€ãã®äººã«åããããFlex-Patternã§ã¯ãå°ããå°ãªãã
- Reactã«ã¯ãç¶æ ã®ç¥èãªæŠå¿µããããFlex-Patternsã¯ç¡ç¥è«è ã§ããã眪ãèš±ããŸãã
ãããŠæåŸã«ããããžã§ã¯ãã®å°æ¥ã«ã€ããŠã®ããã€ãã®èšèïŒãã誰ãããã¡ããèå³ããããªãïŒã ãããžã§ã¯ãã¯æé·ããŠããããã®éçºã¯ãŸããŸã骚ã®æããäœæ¥ã§ãã è¿ãå°æ¥-ç§ã®æšå®ã«ãããšãäœéãçŽ200 kbãã120ãã170 kbïŒæåã¯æ¥œèŠ³äž»çŸ©è ã®å£°ïŒã«æžããããšãã§ããå³ããé£äºçæ³ã ãŸãã空äžã«åãããšãè¡ããšããã¢ã€ãã¢ããããŸãããJQã§ã¯ããµã€ãºã70ã100 kbã®ã©ã€ãã©ãªãååŸã§ããŸãïŒãã³ãã¬ãŒããšã³ãžã³ã ãã§ãªããJQã®æ©èœãæ¬è³ªçã«è€è£œããããå€ãã®ãã®ãå¿ããªãã§ãã ããïŒã
ãã ãããµããŒããªãã§ã§ããããšã¯ã»ãšãã©ãããŸããã ãïŒ ãã³ããïŒïŒïŒããããããã¯è²¡æ¿ã«ã€ããŠã§ã¯ãããŸããã ã¢ã¹ã¿ãªã¹ã¯ãããã°ã圌ãã¯ç§ã«ãã®å šäœã®æéãããå°ãäžããŠãããã ãã§ãïŒç§ã¯åãã€ããŠããŸãããããã¯ç¶æ ã§ãããå±éãããŠããŸãïŒã ããªãã«ãšã£ãŠ-ããã¯ã¯ãªãã¯ã§ãããç§ã«ãšã£ãŠã¯-ãã®åµé ãçºå±ãããããã®äœåãªæéã§ãã äºåã«æè¬ããŸãã
ãã¹ãŠã®å¹žçŠãåãšå ã
è åšã ReactãåŠã¶;ïŒ