1
+ 'use strict' ;
2
+
3
+ Object . defineProperty ( exports , "__esModule" , {
4
+ value : true
5
+ } ) ;
6
+
7
+ var _assign = require ( 'babel-runtime/core-js/object/assign' ) ;
8
+
9
+ var _assign2 = _interopRequireDefault ( _assign ) ;
10
+
11
+ var _extends2 = require ( 'babel-runtime/helpers/extends' ) ;
12
+
13
+ var _extends3 = _interopRequireDefault ( _extends2 ) ;
14
+
15
+ var _getPrototypeOf = require ( 'babel-runtime/core-js/object/get-prototype-of' ) ;
16
+
17
+ var _getPrototypeOf2 = _interopRequireDefault ( _getPrototypeOf ) ;
18
+
19
+ var _classCallCheck2 = require ( 'babel-runtime/helpers/classCallCheck' ) ;
20
+
21
+ var _classCallCheck3 = _interopRequireDefault ( _classCallCheck2 ) ;
22
+
23
+ var _createClass2 = require ( 'babel-runtime/helpers/createClass' ) ;
24
+
25
+ var _createClass3 = _interopRequireDefault ( _createClass2 ) ;
26
+
27
+ var _possibleConstructorReturn2 = require ( 'babel-runtime/helpers/possibleConstructorReturn' ) ;
28
+
29
+ var _possibleConstructorReturn3 = _interopRequireDefault ( _possibleConstructorReturn2 ) ;
30
+
31
+ var _inherits2 = require ( 'babel-runtime/helpers/inherits' ) ;
32
+
33
+ var _inherits3 = _interopRequireDefault ( _inherits2 ) ;
34
+
35
+ var _react = require ( 'react' ) ;
36
+
37
+ var _react2 = _interopRequireDefault ( _react ) ;
38
+
39
+ var _reactRemarkable = require ( 'react-remarkable' ) ;
40
+
41
+ var _reactRemarkable2 = _interopRequireDefault ( _reactRemarkable ) ;
42
+
43
+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
44
+
45
+ var Story = function ( _React$Component ) {
46
+ ( 0 , _inherits3 . default ) ( Story , _React$Component ) ;
47
+
48
+ function Story ( ) {
49
+ var _Object$getPrototypeO ;
50
+
51
+ ( 0 , _classCallCheck3 . default ) ( this , Story ) ;
52
+
53
+ for ( var _len = arguments . length , args = Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
54
+ args [ _key ] = arguments [ _key ] ;
55
+ }
56
+
57
+ var _this = ( 0 , _possibleConstructorReturn3 . default ) ( this , ( _Object$getPrototypeO = ( 0 , _getPrototypeOf2 . default ) ( Story ) ) . call . apply ( _Object$getPrototypeO , [ this ] . concat ( args ) ) ) ;
58
+
59
+ _this . stylesheet = {
60
+ link : {
61
+ base : {
62
+ fontFamily : 'sans-serif' ,
63
+ fontSize : 12 ,
64
+ display : 'block' ,
65
+ position : 'absolute' ,
66
+ textDecoration : 'none' ,
67
+ background : '#eee' ,
68
+ color : '#333' ,
69
+ padding : '5px 15px' ,
70
+ cursor : 'pointer'
71
+ } ,
72
+ topRight : {
73
+ top : 0 ,
74
+ right : 0 ,
75
+ borderRadius : '0 0 0 5px'
76
+ }
77
+ } ,
78
+ info : {
79
+ position : 'absolute' ,
80
+ background : 'white' ,
81
+ top : 0 ,
82
+ bottom : 0 ,
83
+ left : 0 ,
84
+ right : 0 ,
85
+ padding : '0 40px' ,
86
+ overflow : 'auto'
87
+ }
88
+ } ;
89
+
90
+ _this . state = { open : false } ;
91
+ return _this ;
92
+ }
93
+
94
+ ( 0 , _createClass3 . default ) ( Story , [ {
95
+ key : 'openInfo' ,
96
+ value : function openInfo ( ) {
97
+ this . setState ( { open : true } ) ;
98
+ return false ;
99
+ }
100
+ } , {
101
+ key : 'closeInfo' ,
102
+ value : function closeInfo ( ) {
103
+ this . setState ( { open : false } ) ;
104
+ return false ;
105
+ }
106
+ } , {
107
+ key : 'render' ,
108
+ value : function render ( ) {
109
+ var _this2 = this ;
110
+
111
+ var linkStyle = ( 0 , _extends3 . default ) ( { } , this . stylesheet . link . base , this . stylesheet . link . topRight ) ;
112
+ var infoStyle = ( 0 , _assign2 . default ) ( { } , this . stylesheet . info ) ;
113
+ if ( ! this . state . open ) {
114
+ infoStyle . display = 'none' ;
115
+ }
116
+
117
+ return _react2 . default . createElement (
118
+ 'div' ,
119
+ null ,
120
+ this . props . children ,
121
+ _react2 . default . createElement (
122
+ 'a' ,
123
+ { style : linkStyle , onClick : function onClick ( ) {
124
+ return _this2 . openInfo ( ) ;
125
+ } } ,
126
+ '?'
127
+ ) ,
128
+ _react2 . default . createElement (
129
+ 'div' ,
130
+ { style : infoStyle } ,
131
+ _react2 . default . createElement (
132
+ 'a' ,
133
+ { style : linkStyle , onClick : function onClick ( ) {
134
+ return _this2 . closeInfo ( ) ;
135
+ } } ,
136
+ '×'
137
+ ) ,
138
+ _react2 . default . createElement (
139
+ 'div' ,
140
+ { className : 'storybook-story-info-page' } ,
141
+ _react2 . default . createElement (
142
+ 'div' ,
143
+ { className : 'storybook-story-info-body' } ,
144
+ _react2 . default . createElement ( _reactRemarkable2 . default , { source : this . _deindent ( this . props . info ) } )
145
+ )
146
+ )
147
+ )
148
+ ) ;
149
+ }
150
+ } , {
151
+ key : '_deindent' ,
152
+ value : function _deindent ( input ) {
153
+ if ( ! input ) {
154
+ return '' ;
155
+ }
156
+ var lines = input . split ( '\n' ) ;
157
+ while ( lines [ 0 ] . trim ( ) === '' ) {
158
+ lines . shift ( ) ;
159
+ }
160
+ var padding = 0 ;
161
+ var matches = lines [ 0 ] . match ( / ^ * / ) ;
162
+ if ( matches ) {
163
+ padding = matches [ 0 ] . length ;
164
+ }
165
+ var trimmed = lines . map ( function ( s ) {
166
+ return s . slice ( padding ) ;
167
+ } ) ;
168
+ return trimmed . join ( '\n' ) ;
169
+ }
170
+ } ] ) ;
171
+ return Story ;
172
+ } ( _react2 . default . Component ) ;
173
+
174
+ Story . propTypes = {
175
+ info : _react2 . default . PropTypes . string
176
+ } ;
177
+ exports . default = Story ;
0 commit comments