Добавил переход по якорю правил безе занесения в историю

Исправлен баг с невозможностью выделения элементов правил
This commit is contained in:
ErickSkrauch 2016-06-01 01:27:20 +03:00
parent 18fe80248e
commit d9309662f2
2 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router'; import { Link, browserHistory } from 'react-router';
import { FormattedMessage as Message } from 'react-intl'; import { FormattedMessage as Message } from 'react-intl';
import { FooterMenu } from 'components/footerMenu'; import { FooterMenu } from 'components/footerMenu';
@ -98,6 +98,7 @@ export default class RulesPage extends Component {
})} })}
key={ruleIndex} key={ruleIndex}
id={this.getRuleHash(sectionIndex, ruleIndex)} id={this.getRuleHash(sectionIndex, ruleIndex)}
onClick={this.onRuleClick}
> >
{item} {item}
</li> </li>
@ -114,6 +115,12 @@ export default class RulesPage extends Component {
); );
} }
onRuleClick(event) {
const id = event.currentTarget.id;
const newLocation = browserHistory.createLocation({...location, hash: `#${id}`});
browserHistory.replace(newLocation);
}
getTitleHash(sectionIndex) { getTitleHash(sectionIndex) {
return `rule-${sectionIndex + 1}`; return `rule-${sectionIndex + 1}`;
} }

View File

@ -26,7 +26,8 @@
.rulesBody { .rulesBody {
position: relative; position: relative;
z-index: -2; // z-index, чтобы положить :before ниже текста, но выше фона блока
z-index: 0;
padding: 20px; padding: 20px;
background: #fff; background: #fff;
@ -57,6 +58,7 @@
list-style: decimal; list-style: decimal;
position: relative; position: relative;
cursor: pointer;
&:last-of-type { &:last-of-type {
margin-bottom: 0; margin-bottom: 0;
@ -64,6 +66,7 @@
&.target { &.target {
&:before { &:before {
cursor: default;
$border: 8px solid #ddd8ce; $border: 8px solid #ddd8ce;
content: ''; content: '';
position: absolute; position: absolute;