- {rules.map((block, sectionIndex) => (
-
-
-
{block.title}
+export default class RulesPage extends Component {
+ static propTypes = {
+ location: PropTypes.shape({
+ hash: PropTypes.string
+ })
+ };
-
- {block.description ? (
-
- {block.description}
-
- ) : ''}
-
- {block.items.map((item, ruleIndex) => (
- -
-
- {item}
-
- ))}
-
+ static contextTypes = {
+ router: PropTypes.shape({
+ createLocation: PropTypes.func.required,
+ replace: PropTypes.func.required
+ }).isRequired
+ };
+
+ render() {
+ let {hash} = this.props.location;
+ if (hash) {
+ hash = hash.substring(1);
+ }
+
+ return (
+
+
+ {(pageTitle) => (
+
+ )}
+
+
+
+ {rules.map((block, sectionIndex) => (
+
+
+ {block.title}
+
+
+
+ {block.description ? (
+
+ {block.description}
+
+ ) : ''}
+
+ {block.items.map((item, ruleIndex) => (
+ -
+ {item}
+
+ ))}
+
+
-
- ))}
+ ))}
+
+
+
+
-
-
-
-
- );
+ );
+ }
+
+ onRuleClick(event) {
+ const {id} = event.currentTarget;
+ const {router} = this.context;
+ const newLocation = router.createLocation({...location, hash: `#${id}`});
+ router.replace(newLocation);
+ }
+
+ static getTitleHash(sectionIndex) {
+ return `rule-${sectionIndex + 1}`;
+ }
+
+ static getRuleHash(sectionIndex, ruleIndex) {
+ return `${RulesPage.getTitleHash(sectionIndex)}-${ruleIndex + 1}`;
+ }
}
RulesPage.displayName = 'RulesPage';
diff --git a/src/pages/rules/rules.scss b/src/pages/rules/rules.scss
index 5bcb342..cf2e72f 100644
--- a/src/pages/rules/rules.scss
+++ b/src/pages/rules/rules.scss
@@ -25,6 +25,10 @@
}
.rulesBody {
+ position: relative;
+ // z-index, чтобы положить :before ниже текста, но выше фона блока
+ z-index: 0;
+
padding: 20px;
background: #fff;
font-size: 14px;
@@ -53,20 +57,40 @@
@extend %rulesTextFormat;
list-style: decimal;
+ position: relative;
+ cursor: pointer;
&:last-of-type {
margin-bottom: 0;
}
+ &.target {
+ &:before {
+ cursor: default;
+ $border: 8px solid #ddd8ce;
+ content: '';
+ position: absolute;
+ top: -10px;
+ left: -40px;
+ width: calc(100% + 60px);
+ height: calc(100% + 20px);
+ background: $light;
+ border-left: $border;
+ border-right: $border;
+ box-sizing: border-box;
+ z-index: -1;
+ }
+ }
+
a {
color: #444;
border-bottom: 1px dotted #aaa;
text-decoration: none;
- transition: .25s
- }
+ transition: .25s;
- a:hover {
- border-bottom-color: #444
+ &:hover {
+ border-bottom-color: #444
+ }
}
}